GetDocumentPriceTest::testGetWheelsPrice()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
c 1
b 0
f 1
dl 0
loc 20
rs 9.7333
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SergeyNezbritskiy\NovaPoshta\Tests\Integration\Models\InternetDocument;
6
7
use PHPUnit\Framework\TestCase;
8
use SergeyNezbritskiy\NovaPoshta\Models\InternetDocument;
9
use SergeyNezbritskiy\NovaPoshta\NovaPoshtaApiException;
10
use SergeyNezbritskiy\NovaPoshta\Tests\AssertEntityByPropertiesTrait;
11
use SergeyNezbritskiy\NovaPoshta\Tests\ConstantsInterface;
12
use SergeyNezbritskiy\NovaPoshta\Tests\UsesConnectionTrait;
13
14
class GetDocumentPriceTest extends TestCase implements ConstantsInterface
15
{
16
    use AssertEntityByPropertiesTrait;
17
    use UsesConnectionTrait;
18
19
    private InternetDocument $model;
20
21
    protected function setUp(): void
22
    {
23
        $connection = $this->getConnection();
24
        $this->model = new InternetDocument($connection);
25
    }
26
27
    /**
28
     * @throws NovaPoshtaApiException
29
     */
30
    public function testGetDocumentPriceWithoutServiceType(): void
31
    {
32
        $params = [
33
            'CitySender' => self::CITY_REF_KHARKIV,
34
            'CityRecipient' => self::CITY_REF_KYIV,
35
            'ServiceType' => InternetDocument::SERVICE_TYPE_WAREHOUSE_WAREHOUSE,
36
            'Weight' => 34.4,
37
        ];
38
        $actualResult = $this->model->getDocumentPrice($params);
39
        $this->assertEntity($actualResult, ['Cost', 'AssessedCost']);
40
    }
41
42
    /**
43
     * @throws NovaPoshtaApiException
44
     */
45
    public function testGetWheelsPrice(): void
46
    {
47
        $params = [
48
            'CitySender' => self::CITY_REF_KHARKIV,
49
            'CityRecipient' => self::CITY_REF_KYIV,
50
            'Weight' => 34.4,
51
            'ServiceType' => 'WarehouseWarehouse',
52
            'Cost' => 100.00,
53
            'CargoType' => InternetDocument::CARGO_TYPE_TIRES_WHEELS,
54
            'CargoDetails' => [
55
                ['CargoDescription' => self::CARGO_TYPE_TIRES_WHEELS_DESCRIPTION, 'Amount' => 2]
56
            ],
57
            'SeatsAmount' => 2,
58
            'PackCount' => 2,
59
            'CargoDescription' => self::CARGO_TYPE_TIRES_WHEELS_DESCRIPTION,
60
        ];
61
        $actualResult = $this->model->getDocumentPrice($params);
62
        $this->assertEntity($actualResult, [
63
            'Cost',
64
            'AssessedCost',
65
        ]);
66
    }
67
68
    /**
69
     * @throws NovaPoshtaApiException
70
     */
71
    public function testGetPalletsPrice(): void
72
    {
73
        $params = [
74
            'CitySender' => self::CITY_REF_KHARKIV,
75
            'CityRecipient' => self::CITY_REF_KYIV,
76
            'Weight' => 0.1,
77
            'ServiceType' => 'WarehouseWarehouse',
78
            'Cost' => 150.00,
79
            'CargoType' => InternetDocument::CARGO_TYPE_PALLET,
80
            'CargoDetails' => [
81
                ['CargoDescription' => self::CARGO_TYPE_PALLETS_DESCRIPTION, 'Amount' => 2]
82
            ],
83
            'OptionsSeat' => [
84
                [
85
                    'weight' => 10,
86
                    'volumetricHeight' => 100,
87
                    'volumetricWidth' => 120,
88
                    'volumetricLength' => 120,
89
                ],
90
            ],
91
            'SeatsAmount' => 2,
92
            'PackCount' => 2,
93
            'CargoDescription' => self::CARGO_TYPE_PALLETS_DESCRIPTION,
94
        ];
95
        $actualResult = $this->model->getDocumentPrice($params);
96
        $this->assertEntity($actualResult, [
97
            'Cost',
98
            'AssessedCost',
99
        ]);
100
    }
101
102
    /**
103
     * @throws NovaPoshtaApiException
104
     */
105
    public function testGetCargoPrice(): void
106
    {
107
        $params = [
108
            'CitySender' => self::CITY_REF_KHARKIV,
109
            'CityRecipient' => self::CITY_REF_KYIV,
110
            'Weight' => 0.1,
111
            'ServiceType' => 'WarehouseWarehouse',
112
            'Cost' => 150.00,
113
            'CargoType' => InternetDocument::CARGO_TYPE_CARGO,
114
            'CargoDescription' => self::CARGO_TYPE_CARGO_DESCRIPTION,
115
        ];
116
        $actualResult = $this->model->getDocumentPrice($params);
117
        $this->assertEntity($actualResult, [
118
            'Cost',
119
            'AssessedCost',
120
        ]);
121
    }
122
123
    /**
124
     * @throws NovaPoshtaApiException
125
     */
126
    public function testGetDocumentsPrice(): void
127
    {
128
        $params = [
129
            'CitySender' => self::CITY_REF_KHARKIV,
130
            'CityRecipient' => self::CITY_REF_KYIV,
131
            'Weight' => 0.1,
132
            'ServiceType' => 'WarehouseWarehouse',
133
            'Cost' => 150.00,
134
            'CargoType' => InternetDocument::CARGO_TYPE_DOCUMENTS,
135
            'CargoDescription' => self::CARGO_TYPE_PALLETS_DESCRIPTION,
136
        ];
137
        $actualResult = $this->model->getDocumentPrice($params);
138
        $this->assertEntity($actualResult, [
139
            'Cost',
140
            'AssessedCost',
141
        ]);
142
    }
143
}
144