koel/tests/ArtistTest.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2015-12-17 07:02:44 +00:00
<?php
use App\Models\Artist;
use Illuminate\Foundation\Testing\DatabaseTransactions;
2015-12-17 07:16:36 +00:00
class ArtistTest extends TestCase
2015-12-17 07:02:44 +00:00
{
use DatabaseTransactions;
public function setUp()
{
parent::setUp();
}
public function testShouldBeCreatedWithUniqueNames()
{
$name = 'Foo Fighters';
$artist = Artist::get($name);
$this->assertEquals($name, $artist->name);
2016-04-17 15:38:06 +00:00
// Should be only 3 records: UNKNOWN_ARTIST, VARIOUS_ARTISTS, and our Dave Grohl's band
$this->assertEquals(3, Artist::all()->count());
2015-12-17 07:02:44 +00:00
Artist::get($name);
2016-04-17 15:38:06 +00:00
// Should still be 3.
$this->assertEquals(3, Artist::all()->count());
2015-12-17 07:02:44 +00:00
}
public function testArtistWithEmptyNameShouldBeUnknown()
{
$this->assertEquals(Artist::UNKNOWN_NAME, Artist::get('')->name);
}
2015-12-17 17:56:48 +00:00
public function testUtf16Names()
2015-12-17 07:02:44 +00:00
{
$name = file_get_contents(dirname(__FILE__).'/blobs/utf16');
2015-12-17 17:56:48 +00:00
$artist = Artist::get($name);
$artist = Artist::get($name); // to make sure there's no constraint exception
2015-12-17 07:02:44 +00:00
$this->assertEquals($artist->id, Artist::get($name)->id);
}
}