GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( dd680f...a61514 )
by Christian
01:32
created

ArtistServiceTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 68
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testItIsInstantiable() 0 6 1
A testGetArtist() 0 22 1
A testSearch() 0 28 1
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\Service;
11
12
use Core23\SetlistFm\Builder\ArtistSearchBuilder;
13
use Core23\SetlistFm\Connection\ConnectionInterface;
14
use Core23\SetlistFm\Service\ArtistService;
15
use PHPUnit\Framework\TestCase;
16
17
class ArtistServiceTest extends TestCase
18
{
19
    private $connection;
20
21
    protected function setUp()
22
    {
23
        $this->connection =  $this->prophesize(ConnectionInterface::class);
24
    }
25
26
    public function testItIsInstantiable(): void
27
    {
28
        $service = new ArtistService($this->connection->reveal());
29
30
        $this->assertNotNull($service);
31
    }
32
33
    public function testGetArtist(): void
34
    {
35
        $rawResponse = <<<'EOD'
36
                        {
37
                          "mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d",
38
                          "tmid" : 735610,
39
                          "name" : "The Beatles",
40
                          "sortName" : "Beatles, The",
41
                          "disambiguation" : "John, Paul, George and Ringo",
42
                          "url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html"
43
                        }
44
EOD;
45
46
        $this->connection->call('artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d')
47
            ->willReturn(json_decode($rawResponse, true))
48
        ;
49
50
        $service = new ArtistService($this->connection->reveal());
51
        $result  = $service->getArtist('b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d');
52
53
        $this->assertNotNull($result);
54
    }
55
56
    public function testSearch(): void
57
    {
58
        $rawResponse = <<<'EOD'
59
                    {
60
                      "artist" : [ {
61
                        "mbid" : "b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d",
62
                        "tmid" : 735610,
63
                        "name" : "The Beatles",
64
                        "sortName" : "Beatles, The",
65
                        "disambiguation" : "John, Paul, George and Ringo",
66
                        "url" : "https://www.setlist.fm/setlists/the-beatles-23d6a88b.html"
67
                      }],
68
                      "total" : 1,
69
                      "page" : 1,
70
                      "itemsPerPage" : 20
71
                    }
72
EOD;
73
74
        $this->connection->call('search/artists', ['p' => 1, 'artistName' => 'The Beatles'])
75
            ->willReturn(json_decode($rawResponse, true))
76
        ;
77
78
        $service = new ArtistService($this->connection->reveal());
79
        $result  = $service->search(ArtistSearchBuilder::create()
80
            ->withName('The Beatles'));
81
82
        $this->assertCount(1, $result);
83
    }
84
}
85