Passed
Push — master ( 3eedbe...821bb4 )
by Sergey
57s queued 21s
created

GetBackwardDeliveryCargoTypesTest::gulp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SergeyNezbritskiy\NovaPoshta\Tests\Integration\Models\Common;
6
7
use PHPUnit\Framework\TestCase;
8
use SergeyNezbritskiy\NovaPoshta\Models\Common;
9
use SergeyNezbritskiy\NovaPoshta\NovaPoshtaApiException;
10
use SergeyNezbritskiy\NovaPoshta\Tests\AssertEntityByPropertiesTrait;
11
use SergeyNezbritskiy\NovaPoshta\Tests\UsesConnectionTrait;
12
13
class GetBackwardDeliveryCargoTypesTest extends TestCase
14
{
15
    use AssertEntityByPropertiesTrait;
16
    use UsesConnectionTrait;
17
18
    private Common $model;
19
20
    protected function setUp(): void
21
    {
22
        $connection = $this->getConnection();
23
        $this->model = new Common($connection);
24
    }
25
26
    /**
27
     * @return void
28
     * @throws NovaPoshtaApiException
29
     */
30
    public function testGetBackwardDeliveryCargoTypes(): void
31
    {
32
        $this->gulp();
33
        $actualResult = $this->model->getBackwardDeliveryCargoTypes();
34
        $this->assertNotEmpty($actualResult);
35
        $entity = array_shift($actualResult);
36
        $expectedProperties = ['Description', 'Ref'];
37
        $this->assertEntity($entity, $expectedProperties);
38
    }
39
40
    /**
41
     * @return void
42
     */
43
    private function gulp(): void
44
    {
45
        $gulp = (int)getenv('GULP');
46
47
        if ($gulp) {
48
            sleep($gulp);
49
        }
50
    }
51
}
52