GetWarehousesListTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A assertIsWarehouse() 0 8 1
A testGetWarehouses() 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
/**
13
 * Class GetWarehousesListTest
14
 * Integration test for \SergeyNezbritskiy\NovaPoshta\Models\Address
15
 *
16
 * @see Address::getWarehouses
17
 */
18
class GetWarehousesListTest extends TestCase
19
{
20
    use UsesConnectionTrait;
21
22
    private Address $model;
23
24
    protected function setUp(): void
25
    {
26
        $connection = $this->getConnection();
27
        $this->model = new Address($connection);
28
    }
29
30
31
    /**
32
     * @return void
33
     * @throws NovaPoshtaApiException
34
     */
35
    public function testGetWarehouses(): void
36
    {
37
        $actualResult = $this->model->getWarehouses([], 1, 10);
38
        $this->assertIsArray($actualResult);
39
        $this->assertIsWarehouse(array_shift($actualResult));
40
    }
41
42
    /**
43
     * @param array $warehouse
44
     * @return void
45
     */
46
    private function assertIsWarehouse(array $warehouse): void
47
    {
48
        $this->assertArrayHasKey('Ref', $warehouse);
49
        $this->assertArrayHasKey('Description', $warehouse);
50
        $this->assertArrayHasKey('CityRef', $warehouse);
51
        $this->assertArrayHasKey('WarehouseStatus', $warehouse);
52
        $this->assertArrayHasKey('CategoryOfWarehouse', $warehouse);
53
        $this->assertArrayHasKey('TypeOfWarehouse', $warehouse);
54
    }
55
}
56