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);
// Should be only 2 records: UNKNOWN_ARTIST, and our Dave Grohl's band
$this->assertEquals(2, Artist::all()->count());
Artist::get($name);
// Should still be 2.
$this->assertEquals(2, Artist::all()->count());
}
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);
}
}