1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Christian Gripp <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Core23\SetlistFm\Tests\Model; |
11
|
|
|
|
12
|
|
|
use Core23\SetlistFm\Model\Song; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
final class SongTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testFromApi(): void |
18
|
|
|
{ |
19
|
|
|
$data = <<<'EOD' |
20
|
|
|
{ |
21
|
|
|
"name" : "Roll Over Beethoven", |
22
|
|
|
"info": "This is a song", |
23
|
|
|
"tape": 1, |
24
|
|
|
"cover" : { |
25
|
|
|
"mbid" : "592a3b6d-c42b-4567-99c9-ecf63bd66499", |
26
|
|
|
"tmid" : 734540, |
27
|
|
|
"name" : "Chuck Berry", |
28
|
|
|
"sortName" : "Berry, Chuck", |
29
|
|
|
"disambiguation" : "", |
30
|
|
|
"url" : "https://www.setlist.fm/setlists/chuck-berry-63d6a2b7.html" |
31
|
|
|
}, |
32
|
|
|
"with" : { |
33
|
|
|
"mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d", |
34
|
|
|
"tmid" : 735610, |
35
|
|
|
"name" : "The Beatles", |
36
|
|
|
"sortName" : "Beatles, The", |
37
|
|
|
"disambiguation" : "", |
38
|
|
|
"url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html" |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
EOD; |
42
|
|
|
|
43
|
|
|
$song = Song::fromApi(json_decode($data, true)); |
44
|
|
|
static::assertSame('Roll Over Beethoven', $song->getName()); |
45
|
|
|
static::assertSame('This is a song', $song->getInfo()); |
46
|
|
|
static::assertNotNull($song->getCover()); |
47
|
|
|
static::assertCount(1, $song->getFeaturings()); |
48
|
|
|
static::assertTrue($song->isTaped()); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|