|
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\LastFm\Tests\Builder; |
|
11
|
|
|
|
|
12
|
|
|
use Core23\LastFm\Builder\SimilarTrackBuilder; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
|
|
15
|
|
|
class SimilarTrackBuilderTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
public function testForMbid(): void |
|
18
|
|
|
{ |
|
19
|
|
|
$builder = SimilarTrackBuilder::forMbid('a466c2a2-6517-42fb-a160-1087c3bafd9f'); |
|
20
|
|
|
|
|
21
|
|
|
$expected = [ |
|
22
|
|
|
'mbid' => 'a466c2a2-6517-42fb-a160-1087c3bafd9f', |
|
23
|
|
|
]; |
|
24
|
|
|
$this->assertSame($expected, $builder->getQuery()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testForTrack(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$builder = SimilarTrackBuilder::forTrack('Slipknot', 'Before I Forget'); |
|
30
|
|
|
|
|
31
|
|
|
$expected = [ |
|
32
|
|
|
'artist' => 'Slipknot', |
|
33
|
|
|
'track' => 'Before I Forget', |
|
34
|
|
|
]; |
|
35
|
|
|
$this->assertSame($expected, $builder->getQuery()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testAutocorrect(): void |
|
39
|
|
|
{ |
|
40
|
|
|
$builder = SimilarTrackBuilder::forMbid('a466c2a2-6517-42fb-a160-1087c3bafd9f') |
|
41
|
|
|
->autocorrect(true) |
|
42
|
|
|
; |
|
43
|
|
|
|
|
44
|
|
|
$expected = [ |
|
45
|
|
|
'mbid' => 'a466c2a2-6517-42fb-a160-1087c3bafd9f', |
|
46
|
|
|
'autocorrect' => 1, |
|
47
|
|
|
]; |
|
48
|
|
|
$this->assertSame($expected, $builder->getQuery()); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testNoAutocorrect(): void |
|
52
|
|
|
{ |
|
53
|
|
|
$builder = SimilarTrackBuilder::forMbid('a466c2a2-6517-42fb-a160-1087c3bafd9f') |
|
54
|
|
|
->autocorrect(false) |
|
55
|
|
|
; |
|
56
|
|
|
|
|
57
|
|
|
$expected = [ |
|
58
|
|
|
'mbid' => 'a466c2a2-6517-42fb-a160-1087c3bafd9f', |
|
59
|
|
|
'autocorrect' => 0, |
|
60
|
|
|
]; |
|
61
|
|
|
$this->assertSame($expected, $builder->getQuery()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testLimit(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$builder = SimilarTrackBuilder::forMbid('a466c2a2-6517-42fb-a160-1087c3bafd9f') |
|
67
|
|
|
->limit(13) |
|
68
|
|
|
; |
|
69
|
|
|
|
|
70
|
|
|
$expected = [ |
|
71
|
|
|
'mbid' => 'a466c2a2-6517-42fb-a160-1087c3bafd9f', |
|
72
|
|
|
'limit' => 13, |
|
73
|
|
|
]; |
|
74
|
|
|
$this->assertSame($expected, $builder->getQuery()); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|