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

CityServiceTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 80
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 testGetCity() 0 28 1
A testSearch() 0 34 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\CitySearchBuilder;
13
use Core23\SetlistFm\Connection\ConnectionInterface;
14
use Core23\SetlistFm\Service\CityService;
15
use PHPUnit\Framework\TestCase;
16
17
class CityServiceTest 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 CityService($this->connection->reveal());
29
30
        $this->assertNotNull($service);
31
    }
32
33
    public function testGetCity(): void
34
    {
35
        $rawResponse = <<<'EOD'
36
                        {
37
                          "id" : "5357527",
38
                          "name" : "Hollywood",
39
                          "stateCode" : "CA",
40
                          "state" : "California",
41
                          "coords" : {
42
                            "long" : -118.3267434,
43
                            "lat" : 34.0983425
44
                          },
45
                          "country" : {
46
                            "code" : "US",
47
                            "name" : "United States"
48
                          }
49
                        }
50
EOD;
51
52
        $this->connection->call('city/5357527')
53
            ->willReturn(json_decode($rawResponse, true))
54
        ;
55
56
        $service = new CityService($this->connection->reveal());
57
        $result  = $service->getCity(5357527);
58
59
        $this->assertNotNull($result);
60
    }
61
62
    public function testSearch(): void
63
    {
64
        $rawResponse = <<<'EOD'
65
                   {
66
                     "cities" : [ {
67
                       "id" : "5357527",
68
                       "name" : "Hollywood",
69
                       "stateCode" : "CA",
70
                       "state" : "California",
71
                       "coords" : {
72
                         "long" : -118.3267434,
73
                         "lat" : 34.0983425
74
                       },
75
                       "country" : {
76
                         "code" : "US",
77
                         "name" : "United States"
78
                       }
79
                     } ],
80
                     "total" : 1,
81
                     "page" : 1,
82
                     "itemsPerPage" : 20
83
                   }
84
EOD;
85
86
        $this->connection->call('search/cities', ['p' => 1, 'name' => 'Hollywood'])
87
            ->willReturn(json_decode($rawResponse, true))
88
        ;
89
90
        $service = new CityService($this->connection->reveal());
91
        $result  = $service->search(CitySearchBuilder::create()
92
            ->withName('Hollywood'));
93
94
        $this->assertCount(1, $result);
95
    }
96
}
97