2015-12-17 07:02:44 +00:00
|
|
|
<?php
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
namespace Tests\Feature;
|
|
|
|
|
2015-12-17 07:02:44 +00:00
|
|
|
use App\Models\Artist;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2017-02-14 06:53:02 +00:00
|
|
|
use Tests\BrowserKitTestCase;
|
2015-12-17 07:02:44 +00:00
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
class ArtistTest extends BrowserKitTestCase
|
2015-12-17 07:02:44 +00:00
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2017-02-14 06:53:02 +00:00
|
|
|
$name = file_get_contents(__DIR__.'../../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);
|
|
|
|
}
|
|
|
|
}
|