GetCitiesTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assertIsCity() 0 5 1
A setUp() 0 4 1
A testGetCities() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SergeyNezbritskiy\NovaPoshta\Tests\Integration\Models\Address;
6
7
use PHPUnit\Framework\TestCase;
8
use SergeyNezbritskiy\NovaPoshta\Models\Address;
9
use SergeyNezbritskiy\NovaPoshta\NovaPoshtaApiException;
10
use SergeyNezbritskiy\NovaPoshta\Tests\UsesConnectionTrait;
11
12
class GetCitiesTest extends TestCase
13
{
14
    use UsesConnectionTrait;
15
16
    private Address $model;
17
18
    protected function setUp(): void
19
    {
20
        $connection = $this->getConnection();
21
        $this->model = new Address($connection);
22
    }
23
24
25
    /**
26
     * @return void
27
     * @throws NovaPoshtaApiException
28
     */
29
    public function testGetCities(): void
30
    {
31
        $actualResult = $this->model->getCities(1, 10);
32
        $this->assertIsArray($actualResult);
33
        $this->assertIsCity(array_shift($actualResult));
34
    }
35
36
    /**
37
     * @param array $city
38
     * @return void
39
     */
40
    private function assertIsCity(array $city): void
41
    {
42
        $this->assertArrayHasKey('Ref', $city);
43
        $this->assertArrayHasKey('Description', $city);
44
        $this->assertArrayHasKey('CityID', $city);
45
    }
46
}
47