mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Add artist test
This commit is contained in:
parent
06f16350b0
commit
f19afff184
1 changed files with 46 additions and 0 deletions
46
tests/ArtistTest.php
Normal file
46
tests/ArtistTest.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Artist;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class InteractionTest extends TestCase
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public function testNameWithWeirdCharacters()
|
||||
{
|
||||
// Don't really think this is even necessary if the user has set a proper utf8 encoding
|
||||
// for the database.
|
||||
$name = '<27><>Ой°Ы&囧rz';
|
||||
$artist = factory(Artist::class)->create(['name' => $name]);
|
||||
|
||||
$this->assertEquals($artist->id, Artist::get($name)->id);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue