Passed
Pull Request — master (#12)
by Sergey
02:32
created

GetCitiesTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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