|
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
|
|
|
'Weight' => 34.4, |
|
36
|
|
|
]; |
|
37
|
|
|
$actualResult = $this->model->getDocumentPrice($params); |
|
38
|
|
|
$this->assertEntity($actualResult, [ |
|
39
|
|
|
'CostDoorsDoors', |
|
40
|
|
|
'CostDoorsWarehouse', |
|
41
|
|
|
'CostWarehouseWarehouse', |
|
42
|
|
|
'CostWarehouseDoors', |
|
43
|
|
|
'CostDoorsPostomat', |
|
44
|
|
|
'CostWarehousePostomat', |
|
45
|
|
|
'AssessedCost', |
|
46
|
|
|
]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @throws NovaPoshtaApiException |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testGetWheelsPrice(): void |
|
53
|
|
|
{ |
|
54
|
|
|
$params = [ |
|
55
|
|
|
'CitySender' => self::CITY_REF_KHARKIV, |
|
56
|
|
|
'CityRecipient' => self::CITY_REF_KYIV, |
|
57
|
|
|
'Weight' => 34.4, |
|
58
|
|
|
'ServiceType' => 'WarehouseWarehouse', |
|
59
|
|
|
'Cost' => 100.00, |
|
60
|
|
|
'CargoType' => InternetDocument::CARGO_TYPE_TIRES_WHEELS, |
|
61
|
|
|
'CargoDetails' => [ |
|
62
|
|
|
['CargoDescription' => self::CARGO_TYPE_TIRES_WHEELS_DESCRIPTION, 'Amount' => 2] |
|
63
|
|
|
], |
|
64
|
|
|
'SeatsAmount' => 2, |
|
65
|
|
|
'PackCount' => 2, |
|
66
|
|
|
'CargoDescription' => self::CARGO_TYPE_TIRES_WHEELS_DESCRIPTION, |
|
67
|
|
|
]; |
|
68
|
|
|
$actualResult = $this->model->getDocumentPrice($params); |
|
69
|
|
|
$this->assertEntity($actualResult, [ |
|
70
|
|
|
'Cost', |
|
71
|
|
|
'AssessedCost', |
|
72
|
|
|
]); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @throws NovaPoshtaApiException |
|
77
|
|
|
*/ |
|
78
|
|
|
public function testGetPalletsPrice(): void |
|
79
|
|
|
{ |
|
80
|
|
|
$params = [ |
|
81
|
|
|
'CitySender' => self::CITY_REF_KHARKIV, |
|
82
|
|
|
'CityRecipient' => self::CITY_REF_KYIV, |
|
83
|
|
|
'Weight' => 0.1, |
|
84
|
|
|
'ServiceType' => 'WarehouseWarehouse', |
|
85
|
|
|
'Cost' => 150.00, |
|
86
|
|
|
'CargoType' => InternetDocument::CARGO_TYPE_PALLET, |
|
87
|
|
|
'CargoDetails' => [ |
|
88
|
|
|
['CargoDescription' => self::CARGO_TYPE_PALLETS_DESCRIPTION, 'Amount' => 2] |
|
89
|
|
|
], |
|
90
|
|
|
'OptionsSeat' => [ |
|
91
|
|
|
[ |
|
92
|
|
|
'weight' => 10, |
|
93
|
|
|
'volumetricHeight' => 100, |
|
94
|
|
|
'volumetricWidth' => 120, |
|
95
|
|
|
'volumetricLength' => 120, |
|
96
|
|
|
], |
|
97
|
|
|
], |
|
98
|
|
|
'SeatsAmount' => 2, |
|
99
|
|
|
'PackCount' => 2, |
|
100
|
|
|
'CargoDescription' => self::CARGO_TYPE_PALLETS_DESCRIPTION, |
|
101
|
|
|
]; |
|
102
|
|
|
$actualResult = $this->model->getDocumentPrice($params); |
|
103
|
|
|
$this->assertEntity($actualResult, [ |
|
104
|
|
|
'Cost', |
|
105
|
|
|
'AssessedCost', |
|
106
|
|
|
]); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @throws NovaPoshtaApiException |
|
111
|
|
|
*/ |
|
112
|
|
|
public function testGetCargoPrice(): void |
|
113
|
|
|
{ |
|
114
|
|
|
$params = [ |
|
115
|
|
|
'CitySender' => self::CITY_REF_KHARKIV, |
|
116
|
|
|
'CityRecipient' => self::CITY_REF_KYIV, |
|
117
|
|
|
'Weight' => 0.1, |
|
118
|
|
|
'ServiceType' => 'WarehouseWarehouse', |
|
119
|
|
|
'Cost' => 150.00, |
|
120
|
|
|
'CargoType' => InternetDocument::CARGO_TYPE_CARGO, |
|
121
|
|
|
'CargoDescription' => self::CARGO_TYPE_CARGO_DESCRIPTION, |
|
122
|
|
|
]; |
|
123
|
|
|
$actualResult = $this->model->getDocumentPrice($params); |
|
124
|
|
|
$this->assertEntity($actualResult, [ |
|
125
|
|
|
'Cost', |
|
126
|
|
|
'AssessedCost', |
|
127
|
|
|
]); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @throws NovaPoshtaApiException |
|
132
|
|
|
*/ |
|
133
|
|
|
public function testGetDocumentsPrice(): void |
|
134
|
|
|
{ |
|
135
|
|
|
$params = [ |
|
136
|
|
|
'CitySender' => self::CITY_REF_KHARKIV, |
|
137
|
|
|
'CityRecipient' => self::CITY_REF_KYIV, |
|
138
|
|
|
'Weight' => 0.1, |
|
139
|
|
|
'ServiceType' => 'WarehouseWarehouse', |
|
140
|
|
|
'Cost' => 150.00, |
|
141
|
|
|
'CargoType' => InternetDocument::CARGO_TYPE_DOCUMENTS, |
|
142
|
|
|
'CargoDescription' => self::CARGO_TYPE_PALLETS_DESCRIPTION, |
|
143
|
|
|
]; |
|
144
|
|
|
$actualResult = $this->model->getDocumentPrice($params); |
|
145
|
|
|
$this->assertEntity($actualResult, [ |
|
146
|
|
|
'Cost', |
|
147
|
|
|
'AssessedCost', |
|
148
|
|
|
]); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
|