GetSettlementsTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assertIsSettlement() 0 4 1
A setUp() 0 4 1
A testGetSettlements() 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 GetSettlementsTest 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
     * @return void
26
     * @throws NovaPoshtaApiException
27
     */
28
    public function testGetSettlements(): void
29
    {
30
        $actualResult = $this->model->getSettlements(['FindByString' => 'Київ'], true, 1, 10);
31
        $this->assertNotEmpty($actualResult);
32
        $this->assertIsSettlement(array_shift($actualResult));
33
    }
34
35
    /**
36
     * @param array $settlement
37
     * @return void
38
     */
39
    private function assertIsSettlement(array $settlement): void
40
    {
41
        $this->assertArrayHasKey('Ref', $settlement);
42
        $this->assertArrayHasKey('SettlementType', $settlement);
43
    }
44
}
45