@@ -9,303 +9,303 @@ |
||
9 | 9 | |
10 | 10 | class TerritoryTests extends \PHPUnit\Framework\TestCase |
11 | 11 | { |
12 | - public static $createdTerritories = []; |
|
13 | - |
|
14 | - public static function setUpBeforeClass() |
|
15 | - { |
|
16 | - Route4Me::setApiKey(Constants::API_KEY); |
|
17 | - |
|
18 | - $territory = new Territory(); |
|
19 | - |
|
20 | - $territoryParams['type'] = TerritoryTypes::CIRCLE; |
|
21 | - $territoryParams['data'] = [ |
|
22 | - '37.569752822786455,-77.47833251953125', |
|
23 | - '5000', |
|
24 | - ]; |
|
25 | - |
|
26 | - $TerritoryParameters = Territory::fromArray([ |
|
27 | - 'territory_name' => 'Test Territory '.strval(rand(10000, 99999)), |
|
28 | - 'territory_color' => 'ff7700', |
|
29 | - 'territory' => $territoryParams, |
|
30 | - ]); |
|
31 | - |
|
32 | - $territory = new Territory(); |
|
33 | - |
|
34 | - $response = $territory->addTerritory($TerritoryParameters); |
|
35 | - |
|
36 | - self::assertNotNull($response); |
|
37 | - self::assertTrue(is_array($response)); |
|
38 | - self::assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
39 | - self::assertTrue(isset($response['territory_id'])); |
|
40 | - |
|
41 | - self::$createdTerritories[] = $response['territory_id']; |
|
42 | - } |
|
43 | - |
|
44 | - public function testFromArray() |
|
45 | - { |
|
46 | - $terrName = 'Test Territory '.strval(rand(10000, 99999)); |
|
47 | - |
|
48 | - $territory = Territory::fromArray([ |
|
49 | - 'territory_name' => $terrName, |
|
50 | - 'territory_color' => 'ff7700', |
|
51 | - 'territory' => [ |
|
52 | - 'type' => TerritoryTypes::CIRCLE, |
|
53 | - 'data' => [ |
|
54 | - '37.569752822786455,-77.47833251953125', |
|
55 | - '5000', |
|
56 | - ] |
|
57 | - ], |
|
58 | - ]); |
|
59 | - |
|
60 | - $this->assertEquals($terrName, $territory->territory_name); |
|
61 | - $this->assertEquals('ff7700', $territory->territory_color); |
|
62 | - $this->assertEquals( |
|
63 | - [ |
|
64 | - 'type' => TerritoryTypes::CIRCLE, |
|
65 | - 'data' => [ |
|
66 | - '37.569752822786455,-77.47833251953125', |
|
67 | - '5000', |
|
68 | - ] |
|
69 | - ], |
|
70 | - $territory->territory); |
|
71 | - } |
|
72 | - |
|
73 | - public function testToArray() |
|
74 | - { |
|
75 | - $terrName = 'Test Territory '.strval(rand(10000, 99999)); |
|
76 | - |
|
77 | - $territory = Territory::fromArray([ |
|
78 | - 'territory_name' => $terrName, |
|
79 | - 'territory_color' => 'ff7700', |
|
80 | - 'territory' => [ |
|
81 | - 'type' => TerritoryTypes::CIRCLE, |
|
82 | - 'data' => [ |
|
83 | - '37.569752822786455,-77.47833251953125', |
|
84 | - '5000', |
|
85 | - ] |
|
86 | - ], |
|
87 | - ]); |
|
88 | - |
|
89 | - $this->assertEquals( |
|
90 | - $territory->toArray(), |
|
91 | - [ |
|
92 | - 'territory_name' => $terrName, |
|
93 | - 'territory_color' => 'ff7700', |
|
94 | - 'territory' => [ |
|
95 | - 'type' => TerritoryTypes::CIRCLE, |
|
96 | - 'data' => [ |
|
97 | - '37.569752822786455,-77.47833251953125', |
|
98 | - '5000', |
|
99 | - ] |
|
100 | - ], |
|
101 | - ] |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - public function testGetTerritories() |
|
106 | - { |
|
107 | - $territory = new Territory(); |
|
108 | - |
|
109 | - $queryParameters = [ |
|
110 | - 'offset' => 0, |
|
111 | - 'limit' => 20, |
|
112 | - ]; |
|
113 | - |
|
114 | - $response = $territory->getTerritories($queryParameters); |
|
115 | - |
|
116 | - $this->assertNotNull($response); |
|
117 | - $this->assertTrue(is_array($response)); |
|
118 | - $this->assertTrue(sizeof($response)>0); |
|
119 | - $this->assertInstanceOf(Territory::class, Territory::fromArray($response[0])); |
|
120 | - } |
|
121 | - |
|
122 | - public function testGetTerritory(){ |
|
123 | - $territory = new Territory(); |
|
124 | - |
|
125 | - $params = [ |
|
126 | - 'territory_id' => self::$createdTerritories[0], |
|
127 | - ]; |
|
128 | - |
|
129 | - $response = $territory->getTerritory($params); |
|
130 | - |
|
131 | - $this->assertNotNull($response); |
|
132 | - $this->assertTrue(is_array($response)); |
|
133 | - $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
134 | - $this->assertTrue(isset($response['territory_id'])); |
|
135 | - $this->assertEquals(self::$createdTerritories[0],$response['territory_id']); |
|
136 | - } |
|
137 | - |
|
138 | - public function testCreateCircleTerritory() |
|
139 | - { |
|
140 | - $territoryParams['type'] = TerritoryTypes::CIRCLE; |
|
141 | - $territoryParams['data'] = [ |
|
142 | - '37.569752822786455,-77.47833251953125', |
|
143 | - '5100', |
|
144 | - ]; |
|
145 | - |
|
146 | - $TerritoryParameters = Territory::fromArray([ |
|
147 | - 'territory_name' => 'Test Circle Territory '.strval(rand(10000, 99999)), |
|
148 | - 'territory_color' => 'ff7700', |
|
149 | - 'territory' => $territoryParams, |
|
150 | - ]); |
|
151 | - |
|
152 | - $territory = new Territory(); |
|
153 | - |
|
154 | - $response = $territory->addTerritory($TerritoryParameters); |
|
155 | - |
|
156 | - $this->assertNotNull($response); |
|
157 | - $this->assertTrue(is_array($response)); |
|
158 | - $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
159 | - $this->assertTrue(isset($response['territory'])); |
|
160 | - $this->assertTrue(isset($response['territory']['type'])); |
|
161 | - |
|
162 | - $this->assertEquals( |
|
163 | - TerritoryTypes::CIRCLE, |
|
164 | - $response['territory']['type'] |
|
165 | - ); |
|
166 | - |
|
167 | - self::$createdTerritories[] = $response['territory_id']; |
|
168 | - } |
|
169 | - |
|
170 | - public function testCreateRectangularTerritory() |
|
171 | - { |
|
172 | - $territoryParams['type'] = TerritoryTypes::RECT; |
|
173 | - $territoryParams['data'] = [ |
|
174 | - '43.51668853502909,-109.3798828125', |
|
175 | - '46.98025235521883,-101.865234375', |
|
176 | - ]; |
|
177 | - |
|
178 | - $TerritoryParameters = Territory::fromArray([ |
|
179 | - 'territory_name' => 'Test Rectangular Territory '.strval(rand(10000, 99999)), |
|
180 | - 'territory_color' => 'ff7705', |
|
181 | - 'territory' => $territoryParams, |
|
182 | - ]); |
|
183 | - |
|
184 | - $territory = new Territory(); |
|
185 | - |
|
186 | - $response = $territory->addTerritory($TerritoryParameters); |
|
187 | - |
|
188 | - $this->assertNotNull($response); |
|
189 | - $this->assertTrue(is_array($response)); |
|
190 | - $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
191 | - $this->assertTrue(isset($response['territory'])); |
|
192 | - $this->assertTrue(isset($response['territory']['type'])); |
|
193 | - |
|
194 | - $this->assertEquals( |
|
195 | - TerritoryTypes::RECT, |
|
196 | - $response['territory']['type'] |
|
197 | - ); |
|
198 | - |
|
199 | - self::$createdTerritories[] = $response['territory_id']; |
|
200 | - } |
|
201 | - |
|
202 | - public function testCreatePolygonTerritory() |
|
203 | - { |
|
204 | - $territoryParams['type'] = TerritoryTypes::POLY; |
|
205 | - $territoryParams['data'] = [ |
|
206 | - '37.769752822786455,-77.67833251953125', |
|
207 | - '37.75886716305343,-77.68974800109863', |
|
208 | - '37.74763966054455,-77.6917221069336', |
|
209 | - '37.74655084306813,-77.68863220214844', |
|
210 | - '37.7502255383101,-77.68125076293945', |
|
211 | - '37.74797991274437,-77.67498512268066', |
|
212 | - '37.73327960206065,-77.6411678314209', |
|
213 | - '37.74430510679532,-77.63172645568848', |
|
214 | - '37.76641925847049,-77.66846199035645', |
|
215 | - ]; |
|
216 | - |
|
217 | - $TerritoryParameters = Territory::fromArray([ |
|
218 | - 'territory_name' => 'Test Polygon Territory '.strval(rand(10000, 99999)), |
|
219 | - 'territory_color' => 'ff7707', |
|
220 | - 'territory' => $territoryParams, |
|
221 | - ]); |
|
222 | - |
|
223 | - $territory = new Territory(); |
|
224 | - |
|
225 | - $response = $territory->addTerritory($TerritoryParameters); |
|
226 | - |
|
227 | - $this->assertNotNull($response); |
|
228 | - $this->assertTrue(is_array($response)); |
|
229 | - $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
230 | - $this->assertTrue(isset($response['territory'])); |
|
231 | - $this->assertTrue(isset($response['territory']['type'])); |
|
232 | - |
|
233 | - $this->assertEquals( |
|
234 | - TerritoryTypes::POLY, |
|
235 | - $response['territory']['type'] |
|
236 | - ); |
|
237 | - |
|
238 | - self::$createdTerritories[] = $response['territory_id']; |
|
239 | - } |
|
240 | - |
|
241 | - public function testUpdateTerritory() |
|
242 | - { |
|
243 | - $territory = new Territory(); |
|
244 | - |
|
245 | - // Update territory |
|
246 | - $territoryParameters = [ |
|
247 | - 'type' => TerritoryTypes::RECT, |
|
248 | - 'data' => [ |
|
249 | - '29.6600127358956,-95.6593322753906', |
|
250 | - '29.8966150753098,-95.3146362304688', |
|
251 | - ], |
|
252 | - ]; |
|
253 | - |
|
254 | - $TerritoryParameters = Territory::fromArray([ |
|
255 | - 'territory_id' => self::$createdTerritories[0], |
|
256 | - 'territory_name' => 'Test Territory Updated as rectangle', |
|
257 | - 'territory_color' => 'ff5500', |
|
258 | - 'territory' => $territoryParameters, |
|
259 | - ]); |
|
260 | - |
|
261 | - $response = $territory->updateTerritory($TerritoryParameters); |
|
262 | - |
|
263 | - $this->assertNotNull($response); |
|
264 | - $this->assertTrue(is_array($response)); |
|
265 | - $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
266 | - $this->assertTrue(isset($response['territory'])); |
|
267 | - $this->assertTrue(isset($response['territory']['type'])); |
|
268 | - |
|
269 | - $this->assertEquals( |
|
270 | - TerritoryTypes::RECT, |
|
271 | - $response['territory']['type'] |
|
272 | - ); |
|
273 | - |
|
274 | - $this->assertEquals( |
|
275 | - 'Test Territory Updated as rectangle', |
|
276 | - $response['territory_name'] |
|
277 | - ); |
|
278 | - } |
|
279 | - |
|
280 | - public function testRemoveTerritory() |
|
281 | - { |
|
282 | - $territory = new Territory(); |
|
283 | - |
|
284 | - $territoryId = self::$createdTerritories[sizeof(self::$createdTerritories)-1]; |
|
285 | - |
|
286 | - $response = $territory->deleteTerritory($territoryId); |
|
287 | - |
|
288 | - $this->assertNotNull($response); |
|
289 | - $this->assertTrue(isset($response['status'])); |
|
290 | - $this->assertTrue($response['status']); |
|
291 | - |
|
292 | - self::$createdTerritories[] = array_pop(self::$createdTerritories); |
|
293 | - } |
|
294 | - |
|
295 | - public static function tearDownAfterClass() |
|
296 | - { |
|
297 | - if (sizeof(self::$createdTerritories)<1) return; |
|
298 | - |
|
299 | - $territory = new Territory(); |
|
300 | - |
|
301 | - foreach (self::$createdTerritories as $createdTerritoryId) { |
|
302 | - $result1 = $territory->deleteTerritory($createdTerritoryId); |
|
303 | - |
|
304 | - if (!is_null($result1) && isset($result1['status']) && $result1['status']) { |
|
305 | - echo "Removed the territory ".$createdTerritoryId." <br>"; |
|
306 | - } else { |
|
307 | - echo "Cannot removed the territory ".$createdTerritoryId." <br>"; |
|
308 | - } |
|
309 | - } |
|
310 | - } |
|
12 | + public static $createdTerritories = []; |
|
13 | + |
|
14 | + public static function setUpBeforeClass() |
|
15 | + { |
|
16 | + Route4Me::setApiKey(Constants::API_KEY); |
|
17 | + |
|
18 | + $territory = new Territory(); |
|
19 | + |
|
20 | + $territoryParams['type'] = TerritoryTypes::CIRCLE; |
|
21 | + $territoryParams['data'] = [ |
|
22 | + '37.569752822786455,-77.47833251953125', |
|
23 | + '5000', |
|
24 | + ]; |
|
25 | + |
|
26 | + $TerritoryParameters = Territory::fromArray([ |
|
27 | + 'territory_name' => 'Test Territory '.strval(rand(10000, 99999)), |
|
28 | + 'territory_color' => 'ff7700', |
|
29 | + 'territory' => $territoryParams, |
|
30 | + ]); |
|
31 | + |
|
32 | + $territory = new Territory(); |
|
33 | + |
|
34 | + $response = $territory->addTerritory($TerritoryParameters); |
|
35 | + |
|
36 | + self::assertNotNull($response); |
|
37 | + self::assertTrue(is_array($response)); |
|
38 | + self::assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
39 | + self::assertTrue(isset($response['territory_id'])); |
|
40 | + |
|
41 | + self::$createdTerritories[] = $response['territory_id']; |
|
42 | + } |
|
43 | + |
|
44 | + public function testFromArray() |
|
45 | + { |
|
46 | + $terrName = 'Test Territory '.strval(rand(10000, 99999)); |
|
47 | + |
|
48 | + $territory = Territory::fromArray([ |
|
49 | + 'territory_name' => $terrName, |
|
50 | + 'territory_color' => 'ff7700', |
|
51 | + 'territory' => [ |
|
52 | + 'type' => TerritoryTypes::CIRCLE, |
|
53 | + 'data' => [ |
|
54 | + '37.569752822786455,-77.47833251953125', |
|
55 | + '5000', |
|
56 | + ] |
|
57 | + ], |
|
58 | + ]); |
|
59 | + |
|
60 | + $this->assertEquals($terrName, $territory->territory_name); |
|
61 | + $this->assertEquals('ff7700', $territory->territory_color); |
|
62 | + $this->assertEquals( |
|
63 | + [ |
|
64 | + 'type' => TerritoryTypes::CIRCLE, |
|
65 | + 'data' => [ |
|
66 | + '37.569752822786455,-77.47833251953125', |
|
67 | + '5000', |
|
68 | + ] |
|
69 | + ], |
|
70 | + $territory->territory); |
|
71 | + } |
|
72 | + |
|
73 | + public function testToArray() |
|
74 | + { |
|
75 | + $terrName = 'Test Territory '.strval(rand(10000, 99999)); |
|
76 | + |
|
77 | + $territory = Territory::fromArray([ |
|
78 | + 'territory_name' => $terrName, |
|
79 | + 'territory_color' => 'ff7700', |
|
80 | + 'territory' => [ |
|
81 | + 'type' => TerritoryTypes::CIRCLE, |
|
82 | + 'data' => [ |
|
83 | + '37.569752822786455,-77.47833251953125', |
|
84 | + '5000', |
|
85 | + ] |
|
86 | + ], |
|
87 | + ]); |
|
88 | + |
|
89 | + $this->assertEquals( |
|
90 | + $territory->toArray(), |
|
91 | + [ |
|
92 | + 'territory_name' => $terrName, |
|
93 | + 'territory_color' => 'ff7700', |
|
94 | + 'territory' => [ |
|
95 | + 'type' => TerritoryTypes::CIRCLE, |
|
96 | + 'data' => [ |
|
97 | + '37.569752822786455,-77.47833251953125', |
|
98 | + '5000', |
|
99 | + ] |
|
100 | + ], |
|
101 | + ] |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + public function testGetTerritories() |
|
106 | + { |
|
107 | + $territory = new Territory(); |
|
108 | + |
|
109 | + $queryParameters = [ |
|
110 | + 'offset' => 0, |
|
111 | + 'limit' => 20, |
|
112 | + ]; |
|
113 | + |
|
114 | + $response = $territory->getTerritories($queryParameters); |
|
115 | + |
|
116 | + $this->assertNotNull($response); |
|
117 | + $this->assertTrue(is_array($response)); |
|
118 | + $this->assertTrue(sizeof($response)>0); |
|
119 | + $this->assertInstanceOf(Territory::class, Territory::fromArray($response[0])); |
|
120 | + } |
|
121 | + |
|
122 | + public function testGetTerritory(){ |
|
123 | + $territory = new Territory(); |
|
124 | + |
|
125 | + $params = [ |
|
126 | + 'territory_id' => self::$createdTerritories[0], |
|
127 | + ]; |
|
128 | + |
|
129 | + $response = $territory->getTerritory($params); |
|
130 | + |
|
131 | + $this->assertNotNull($response); |
|
132 | + $this->assertTrue(is_array($response)); |
|
133 | + $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
134 | + $this->assertTrue(isset($response['territory_id'])); |
|
135 | + $this->assertEquals(self::$createdTerritories[0],$response['territory_id']); |
|
136 | + } |
|
137 | + |
|
138 | + public function testCreateCircleTerritory() |
|
139 | + { |
|
140 | + $territoryParams['type'] = TerritoryTypes::CIRCLE; |
|
141 | + $territoryParams['data'] = [ |
|
142 | + '37.569752822786455,-77.47833251953125', |
|
143 | + '5100', |
|
144 | + ]; |
|
145 | + |
|
146 | + $TerritoryParameters = Territory::fromArray([ |
|
147 | + 'territory_name' => 'Test Circle Territory '.strval(rand(10000, 99999)), |
|
148 | + 'territory_color' => 'ff7700', |
|
149 | + 'territory' => $territoryParams, |
|
150 | + ]); |
|
151 | + |
|
152 | + $territory = new Territory(); |
|
153 | + |
|
154 | + $response = $territory->addTerritory($TerritoryParameters); |
|
155 | + |
|
156 | + $this->assertNotNull($response); |
|
157 | + $this->assertTrue(is_array($response)); |
|
158 | + $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
159 | + $this->assertTrue(isset($response['territory'])); |
|
160 | + $this->assertTrue(isset($response['territory']['type'])); |
|
161 | + |
|
162 | + $this->assertEquals( |
|
163 | + TerritoryTypes::CIRCLE, |
|
164 | + $response['territory']['type'] |
|
165 | + ); |
|
166 | + |
|
167 | + self::$createdTerritories[] = $response['territory_id']; |
|
168 | + } |
|
169 | + |
|
170 | + public function testCreateRectangularTerritory() |
|
171 | + { |
|
172 | + $territoryParams['type'] = TerritoryTypes::RECT; |
|
173 | + $territoryParams['data'] = [ |
|
174 | + '43.51668853502909,-109.3798828125', |
|
175 | + '46.98025235521883,-101.865234375', |
|
176 | + ]; |
|
177 | + |
|
178 | + $TerritoryParameters = Territory::fromArray([ |
|
179 | + 'territory_name' => 'Test Rectangular Territory '.strval(rand(10000, 99999)), |
|
180 | + 'territory_color' => 'ff7705', |
|
181 | + 'territory' => $territoryParams, |
|
182 | + ]); |
|
183 | + |
|
184 | + $territory = new Territory(); |
|
185 | + |
|
186 | + $response = $territory->addTerritory($TerritoryParameters); |
|
187 | + |
|
188 | + $this->assertNotNull($response); |
|
189 | + $this->assertTrue(is_array($response)); |
|
190 | + $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
191 | + $this->assertTrue(isset($response['territory'])); |
|
192 | + $this->assertTrue(isset($response['territory']['type'])); |
|
193 | + |
|
194 | + $this->assertEquals( |
|
195 | + TerritoryTypes::RECT, |
|
196 | + $response['territory']['type'] |
|
197 | + ); |
|
198 | + |
|
199 | + self::$createdTerritories[] = $response['territory_id']; |
|
200 | + } |
|
201 | + |
|
202 | + public function testCreatePolygonTerritory() |
|
203 | + { |
|
204 | + $territoryParams['type'] = TerritoryTypes::POLY; |
|
205 | + $territoryParams['data'] = [ |
|
206 | + '37.769752822786455,-77.67833251953125', |
|
207 | + '37.75886716305343,-77.68974800109863', |
|
208 | + '37.74763966054455,-77.6917221069336', |
|
209 | + '37.74655084306813,-77.68863220214844', |
|
210 | + '37.7502255383101,-77.68125076293945', |
|
211 | + '37.74797991274437,-77.67498512268066', |
|
212 | + '37.73327960206065,-77.6411678314209', |
|
213 | + '37.74430510679532,-77.63172645568848', |
|
214 | + '37.76641925847049,-77.66846199035645', |
|
215 | + ]; |
|
216 | + |
|
217 | + $TerritoryParameters = Territory::fromArray([ |
|
218 | + 'territory_name' => 'Test Polygon Territory '.strval(rand(10000, 99999)), |
|
219 | + 'territory_color' => 'ff7707', |
|
220 | + 'territory' => $territoryParams, |
|
221 | + ]); |
|
222 | + |
|
223 | + $territory = new Territory(); |
|
224 | + |
|
225 | + $response = $territory->addTerritory($TerritoryParameters); |
|
226 | + |
|
227 | + $this->assertNotNull($response); |
|
228 | + $this->assertTrue(is_array($response)); |
|
229 | + $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
230 | + $this->assertTrue(isset($response['territory'])); |
|
231 | + $this->assertTrue(isset($response['territory']['type'])); |
|
232 | + |
|
233 | + $this->assertEquals( |
|
234 | + TerritoryTypes::POLY, |
|
235 | + $response['territory']['type'] |
|
236 | + ); |
|
237 | + |
|
238 | + self::$createdTerritories[] = $response['territory_id']; |
|
239 | + } |
|
240 | + |
|
241 | + public function testUpdateTerritory() |
|
242 | + { |
|
243 | + $territory = new Territory(); |
|
244 | + |
|
245 | + // Update territory |
|
246 | + $territoryParameters = [ |
|
247 | + 'type' => TerritoryTypes::RECT, |
|
248 | + 'data' => [ |
|
249 | + '29.6600127358956,-95.6593322753906', |
|
250 | + '29.8966150753098,-95.3146362304688', |
|
251 | + ], |
|
252 | + ]; |
|
253 | + |
|
254 | + $TerritoryParameters = Territory::fromArray([ |
|
255 | + 'territory_id' => self::$createdTerritories[0], |
|
256 | + 'territory_name' => 'Test Territory Updated as rectangle', |
|
257 | + 'territory_color' => 'ff5500', |
|
258 | + 'territory' => $territoryParameters, |
|
259 | + ]); |
|
260 | + |
|
261 | + $response = $territory->updateTerritory($TerritoryParameters); |
|
262 | + |
|
263 | + $this->assertNotNull($response); |
|
264 | + $this->assertTrue(is_array($response)); |
|
265 | + $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
|
266 | + $this->assertTrue(isset($response['territory'])); |
|
267 | + $this->assertTrue(isset($response['territory']['type'])); |
|
268 | + |
|
269 | + $this->assertEquals( |
|
270 | + TerritoryTypes::RECT, |
|
271 | + $response['territory']['type'] |
|
272 | + ); |
|
273 | + |
|
274 | + $this->assertEquals( |
|
275 | + 'Test Territory Updated as rectangle', |
|
276 | + $response['territory_name'] |
|
277 | + ); |
|
278 | + } |
|
279 | + |
|
280 | + public function testRemoveTerritory() |
|
281 | + { |
|
282 | + $territory = new Territory(); |
|
283 | + |
|
284 | + $territoryId = self::$createdTerritories[sizeof(self::$createdTerritories)-1]; |
|
285 | + |
|
286 | + $response = $territory->deleteTerritory($territoryId); |
|
287 | + |
|
288 | + $this->assertNotNull($response); |
|
289 | + $this->assertTrue(isset($response['status'])); |
|
290 | + $this->assertTrue($response['status']); |
|
291 | + |
|
292 | + self::$createdTerritories[] = array_pop(self::$createdTerritories); |
|
293 | + } |
|
294 | + |
|
295 | + public static function tearDownAfterClass() |
|
296 | + { |
|
297 | + if (sizeof(self::$createdTerritories)<1) return; |
|
298 | + |
|
299 | + $territory = new Territory(); |
|
300 | + |
|
301 | + foreach (self::$createdTerritories as $createdTerritoryId) { |
|
302 | + $result1 = $territory->deleteTerritory($createdTerritoryId); |
|
303 | + |
|
304 | + if (!is_null($result1) && isset($result1['status']) && $result1['status']) { |
|
305 | + echo "Removed the territory ".$createdTerritoryId." <br>"; |
|
306 | + } else { |
|
307 | + echo "Cannot removed the territory ".$createdTerritoryId." <br>"; |
|
308 | + } |
|
309 | + } |
|
310 | + } |
|
311 | 311 | } |
312 | 312 | \ No newline at end of file |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $this->assertInstanceOf(Territory::class, Territory::fromArray($response[0])); |
120 | 120 | } |
121 | 121 | |
122 | - public function testGetTerritory(){ |
|
122 | + public function testGetTerritory() { |
|
123 | 123 | $territory = new Territory(); |
124 | 124 | |
125 | 125 | $params = [ |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $this->assertTrue(is_array($response)); |
133 | 133 | $this->assertInstanceOf(Territory::class, Territory::fromArray($response)); |
134 | 134 | $this->assertTrue(isset($response['territory_id'])); |
135 | - $this->assertEquals(self::$createdTerritories[0],$response['territory_id']); |
|
135 | + $this->assertEquals(self::$createdTerritories[0], $response['territory_id']); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | public function testCreateCircleTerritory() |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | { |
282 | 282 | $territory = new Territory(); |
283 | 283 | |
284 | - $territoryId = self::$createdTerritories[sizeof(self::$createdTerritories)-1]; |
|
284 | + $territoryId = self::$createdTerritories[sizeof(self::$createdTerritories) - 1]; |
|
285 | 285 | |
286 | 286 | $response = $territory->deleteTerritory($territoryId); |
287 | 287 |
@@ -294,7 +294,9 @@ |
||
294 | 294 | |
295 | 295 | public static function tearDownAfterClass() |
296 | 296 | { |
297 | - if (sizeof(self::$createdTerritories)<1) return; |
|
297 | + if (sizeof(self::$createdTerritories)<1) { |
|
298 | + return; |
|
299 | + } |
|
298 | 300 | |
299 | 301 | $territory = new Territory(); |
300 | 302 |
@@ -16,418 +16,418 @@ |
||
16 | 16 | |
17 | 17 | class AddressNoteUnitTests extends \PHPUnit\Framework\TestCase |
18 | 18 | { |
19 | - protected $addressNote; |
|
20 | - |
|
21 | - public static $problem; |
|
22 | - |
|
23 | - public static $route_id = null; |
|
24 | - public static $address_id = null; |
|
25 | - public static $address_lat = null; |
|
26 | - public static $address_lng = null; |
|
27 | - public static $address_is_depot = null; |
|
28 | - public static $noteAddressId = null; |
|
29 | - public static $noteFileAddressId = null; |
|
30 | - |
|
31 | - public static $addresIdMarkedAsVisited; |
|
32 | - |
|
33 | - public static $afterAddressId; |
|
34 | - public static $route_id_dest; |
|
35 | - |
|
36 | - public static $createdCustomNotes; |
|
37 | - |
|
38 | - public static function setUpBeforeClass() |
|
39 | - { |
|
40 | - if (Constants::API_KEY == Constants::DEMO_API_KEY) { |
|
41 | - $className = str_replace('UnitTestFiles\\Test\\','',get_class()); |
|
42 | - self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" ); |
|
43 | - } |
|
44 | - |
|
45 | - Route4Me::setApiKey(Constants::API_KEY); |
|
46 | - |
|
47 | - //<editor-fold desc="Prepare Addresses"> |
|
48 | - $addresses = []; |
|
49 | - $addresses[] = Address::fromArray([ |
|
50 | - 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
51 | - 'is_depot' => true, |
|
52 | - 'lat' => 30.159341812134, |
|
53 | - 'lng' => -81.538619995117, |
|
54 | - 'time' => 300, |
|
55 | - 'time_window_start' => 28800, |
|
56 | - 'time_window_end' => 32400, |
|
57 | - ]); |
|
58 | - |
|
59 | - $addresses[] = Address::fromArray([ |
|
60 | - 'address' => '214 Edgewater Branch Drive 32259', |
|
61 | - 'lat' => 30.103567123413, |
|
62 | - 'lng' => -81.595352172852, |
|
63 | - 'time' => 300, |
|
64 | - 'time_window_start' => 36000, |
|
65 | - 'time_window_end' => 37200, |
|
66 | - ]); |
|
67 | - |
|
68 | - $addresses[] = Address::fromArray([ |
|
69 | - 'address' => '756 eagle point dr 32092', |
|
70 | - 'lat' => 30.046422958374, |
|
71 | - 'lng' => -81.508758544922, |
|
72 | - 'time' => 300, |
|
73 | - 'time_window_start' => 39600, |
|
74 | - 'time_window_end' => 41400, |
|
75 | - ]); |
|
76 | - |
|
77 | - $addresses[] = Address::fromArray([ |
|
78 | - 'address' => '63 Stone Creek Cir St Johns, FL 32259, USA', |
|
79 | - 'lat' => 30.048496, |
|
80 | - 'lng' => -81.558716, |
|
81 | - 'time' => 300, |
|
82 | - 'time_window_start' => 43200, |
|
83 | - 'time_window_end' => 45000, |
|
84 | - ]); |
|
85 | - |
|
86 | - $addresses[] = Address::fromArray([ |
|
87 | - 'address' => 'St Johns Florida 32259, USA', |
|
88 | - 'lat' => 30.099642, |
|
89 | - 'lng' => -81.547201, |
|
90 | - 'time' => 300, |
|
91 | - 'time_window_start' => 46800, |
|
92 | - 'time_window_end' => 48600, |
|
93 | - ]); |
|
94 | - |
|
95 | - $parameters = RouteParameters::fromArray([ |
|
96 | - 'device_type' => DeviceType::IPAD, |
|
97 | - 'disable_optimization' => false, |
|
98 | - 'route_name' => 'phpunit test '.date('Y-m-d H:i'), |
|
99 | - ]); |
|
100 | - //</editor-fold> |
|
101 | - |
|
102 | - $optimizationParameters = new OptimizationProblemParams(); |
|
103 | - $optimizationParameters->setAddresses($addresses); |
|
104 | - $optimizationParameters->setParameters($parameters); |
|
105 | - |
|
106 | - self::$problem = OptimizationProblem::optimize($optimizationParameters); |
|
107 | - $routes = self::$problem->getRoutes(); |
|
108 | - self::$route_id = $routes[0]->route_id; |
|
109 | - self::$noteAddressId = $routes[0]->addresses[2]->route_destination_id; |
|
110 | - self::$noteFileAddressId = $routes[0]->addresses[3]->route_destination_id; |
|
111 | - |
|
112 | - $addresses = self::$problem->addresses; |
|
113 | - self::$address_id = $addresses[1]->getAddressId(); |
|
114 | - //self::$address_address = $addresses[1]->address; |
|
115 | - self::$address_lat = $addresses[1]->lat; |
|
116 | - self::$address_lng = $addresses[1]->lng; |
|
117 | - self::$address_is_depot = $addresses[1]->is_depot; |
|
118 | - |
|
119 | - $noteParameters = [ |
|
120 | - 'route_id' => self::$route_id, |
|
121 | - 'address_id' => self::$address_id, |
|
122 | - 'dev_lat' => self::$address_lat, |
|
123 | - 'dev_lng' => self::$address_lng, |
|
124 | - 'device_type' => 'web', |
|
125 | - 'strUpdateType' => 'dropoff', |
|
126 | - 'strNoteContents' => 'Test Address Note', |
|
127 | - ]; |
|
128 | - |
|
129 | - $addressNote = new AddressNote(); |
|
130 | - |
|
131 | - $addresses[1] = $addressNote->AddAddressNote($noteParameters); |
|
132 | - |
|
133 | - self::$createdCustomNotes = []; |
|
134 | - |
|
135 | - $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
|
136 | - |
|
137 | - foreach ($customNoteTypes as $custNote) { |
|
138 | - if ($custNote['note_custom_type'] == 'Unit Test To Do') { |
|
139 | - self::$createdCustomNotes[]='Unit Test To Do'; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - if (sizeof(self::$createdCustomNotes)<1) { |
|
144 | - $customNoteTypeParameters = [ |
|
145 | - 'type' => 'Unit Test To Do', |
|
146 | - 'values' => [ |
|
147 | - 'Pass a package', |
|
148 | - 'Pickup package', |
|
149 | - 'Do a service', |
|
150 | - ], |
|
151 | - ]; |
|
152 | - |
|
153 | - $customNoteTypeResult = $addressNote->createCustomNoteType($customNoteTypeParameters); |
|
154 | - |
|
155 | - if ($customNoteTypeResult!=null |
|
156 | - && $customNoteTypeResult['result']!=null |
|
157 | - && $customNoteTypeResult['result']=='OK' |
|
158 | - && $customNoteTypeResult['affected']!=null |
|
159 | - && $customNoteTypeResult['affected']==1 |
|
160 | - ) { |
|
161 | - self::$createdCustomNotes[]='Unit Test To Do'; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - public function testFromArray() |
|
167 | - { |
|
168 | - $addressNote = AddressNote::fromArray([ |
|
169 | - 'note_id' => 539264, |
|
170 | - 'route_id' => '5555E83A4BE0055551537955558D5555', |
|
171 | - 'route_destination_id' => 162916895, |
|
172 | - 'ts_added' => 1466515325, |
|
173 | - 'activity_type' => 'dropoff', |
|
174 | - 'upload_id' => '1a499993c63d68d1a5d26045a1763d16', |
|
175 | - 'upload_extension' => 'csv', |
|
176 | - 'upload_url' => 'http:\/\/adb6def9928467589ebb-f540d5a8d53c2e76ad581b6e5c346ad6.\/1a499113c63d68d1a5d26045a1763d16.csv', |
|
177 | - 'upload_type' => 'ANY_FILE', |
|
178 | - 'contents' => 'Some text', |
|
179 | - 'lat' => 33.132675, |
|
180 | - 'lng' => -83.244743, |
|
181 | - 'device_type' => 'web' |
|
182 | - ]); |
|
183 | - |
|
184 | - $this->assertEquals(539264, $addressNote->note_id); |
|
185 | - $this->assertEquals('5555E83A4BE0055551537955558D5555', $addressNote->route_id); |
|
186 | - $this->assertEquals(162916895, $addressNote->route_destination_id); |
|
187 | - $this->assertEquals(1466515325, $addressNote->ts_added); |
|
188 | - $this->assertEquals('dropoff', $addressNote->activity_type); |
|
189 | - $this->assertEquals('1a499993c63d68d1a5d26045a1763d16', $addressNote->upload_id); |
|
190 | - $this->assertEquals('csv', $addressNote->upload_extension); |
|
191 | - $this->assertEquals('http:\/\/adb6def9928467589ebb-f540d5a8d53c2e76ad581b6e5c346ad6.\/1a499113c63d68d1a5d26045a1763d16.csv', $addressNote->upload_url); |
|
192 | - $this->assertEquals('ANY_FILE', $addressNote->upload_type); |
|
193 | - $this->assertEquals('Some text', $addressNote->contents); |
|
194 | - $this->assertEquals(33.132675, $addressNote->lat); |
|
195 | - $this->assertEquals(-83.244743, $addressNote->lng); |
|
196 | - $this->assertEquals('web', $addressNote->device_type); |
|
197 | - } |
|
198 | - |
|
199 | - public function testGetAddressesNotes() |
|
200 | - { |
|
201 | - $noteParameters = [ |
|
202 | - 'route_id' => self::$route_id, |
|
203 | - 'route_destination_id' => self::$address_id, |
|
204 | - ]; |
|
205 | - |
|
206 | - $addressNote = new AddressNote(); |
|
207 | - |
|
208 | - $addressWithNotes = Address::fromArray( |
|
209 | - $addressNote->GetAddressesNotes($noteParameters) |
|
210 | - ); |
|
211 | - |
|
212 | - $firstNote = AddressNote::fromArray( |
|
213 | - $addressWithNotes->notes[0] |
|
214 | - ); |
|
215 | - |
|
216 | - $this->assertNotNull($addressWithNotes); |
|
217 | - $this->assertTrue(sizeof( $addressWithNotes->notes)>0); |
|
218 | - $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
|
219 | - $this->assertEquals('Test Address Note', $firstNote->contents); |
|
220 | - $this->assertEquals('dropoff',$firstNote->activity_type); |
|
221 | - } |
|
222 | - |
|
223 | - public function testAddAddressNote() |
|
224 | - { |
|
225 | - $noteParameters = [ |
|
226 | - 'strFilename' => 'notes.csv', |
|
227 | - 'route_id' => self::$route_id, |
|
228 | - 'address_id' => self::$noteAddressId, |
|
229 | - 'dev_lat' => 33.132675170898, |
|
230 | - 'dev_lng' => -83.244743347168, |
|
231 | - 'device_type' => 'web', |
|
232 | - 'strUpdateType' => 'dropoff', |
|
233 | - 'strNoteContents' => 'Test Add Note To Route Address', |
|
234 | - ]; |
|
235 | - |
|
236 | - $addressNote = new AddressNote(); |
|
237 | - |
|
238 | - $response = AddressNoteResponse::fromArray( |
|
239 | - $addressNote->AddAddressNote($noteParameters) |
|
240 | - ); |
|
241 | - |
|
242 | - $this->assertNotNull($response); |
|
243 | - $this->assertContainsOnlyInstancesOf(AddressNoteResponse::class, [$response]); |
|
244 | - |
|
245 | - $firstNote = AddressNote::fromArray( |
|
246 | - $response->note |
|
247 | - ); |
|
248 | - |
|
249 | - $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
|
250 | - $this->assertEquals('Test Add Note To Route Address', $firstNote->contents); |
|
251 | - $this->assertNotNull($firstNote->upload_id); |
|
252 | - } |
|
253 | - |
|
254 | - public function testAddNoteFile() |
|
255 | - { |
|
256 | - //$this->markTestSkipped('must be revisited.'); |
|
257 | - |
|
258 | - $noteParameters = [ |
|
259 | - 'strFilename' => dirname(__FILE__).'\data\notes.csv', |
|
260 | - 'route_id' => self::$route_id, |
|
261 | - 'address_id' => self::$noteFileAddressId, |
|
262 | - 'dev_lat' => 33.132675170898, |
|
263 | - 'dev_lng' => -83.244743347168, |
|
264 | - 'device_type' => 'web', |
|
265 | - 'strUpdateType' => 'dropoff', |
|
266 | - ]; |
|
267 | - |
|
268 | - $addressNote = new AddressNote(); |
|
269 | - |
|
270 | - $result = $addressNote->AddNoteFile($noteParameters); |
|
271 | - |
|
272 | - $response = AddressNoteResponse::fromArray( |
|
273 | - $result |
|
274 | - ); |
|
275 | - |
|
276 | - sleep(5); |
|
277 | - |
|
278 | - $this->assertNotNull($response); |
|
279 | - $this->assertNotNull($response->status); |
|
280 | - $this->assertTrue($response->status); |
|
281 | - $this->assertContainsOnlyInstancesOf(AddressNoteResponse::class, [$response]); |
|
282 | - |
|
283 | - $firstNote = AddressNote::fromArray( |
|
284 | - $response->note |
|
285 | - ); |
|
286 | - |
|
287 | - $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
|
288 | - $this->assertNotNull($firstNote->upload_id); |
|
289 | - $this->assertNotNull($firstNote->upload_url); |
|
290 | - $this->assertEquals('csv', $firstNote->upload_extension); |
|
291 | - } |
|
292 | - |
|
293 | - public function testGetCustomNoteTypeByKey() |
|
294 | - { |
|
295 | - $addressNote = new AddressNote(); |
|
296 | - |
|
297 | - $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
|
298 | - |
|
299 | - $this->assertEquals(self::$createdCustomNotes[0],$customNoteType['note_custom_type']); |
|
300 | - } |
|
301 | - |
|
302 | - public function testGetAllCustomNoteTypes() |
|
303 | - { |
|
304 | - $addressNote = new AddressNote(); |
|
305 | - |
|
306 | - $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
|
307 | - |
|
308 | - $firstCustomNoteType = CustomNoteTypeResponse::fromArray($customNoteTypes[0]); |
|
309 | - |
|
310 | - $this->assertNotNull($customNoteTypes); |
|
311 | - $this->assertTrue(sizeof($customNoteTypes)>0); |
|
312 | - $this->assertContainsOnlyInstancesOf(CustomNoteTypeResponse::class, [$firstCustomNoteType]); |
|
313 | - } |
|
314 | - |
|
315 | - public function testCreateCustomNoteType() |
|
316 | - { |
|
317 | - $customNoteTypeKey = 'cnt'.date('yMdHi'); |
|
318 | - |
|
319 | - $noteParameters = [ |
|
320 | - 'type' => $customNoteTypeKey, |
|
321 | - 'values' => [ |
|
322 | - 'First value', |
|
323 | - 'Second value', |
|
324 | - 'Third value', |
|
325 | - ], |
|
326 | - ]; |
|
19 | + protected $addressNote; |
|
20 | + |
|
21 | + public static $problem; |
|
22 | + |
|
23 | + public static $route_id = null; |
|
24 | + public static $address_id = null; |
|
25 | + public static $address_lat = null; |
|
26 | + public static $address_lng = null; |
|
27 | + public static $address_is_depot = null; |
|
28 | + public static $noteAddressId = null; |
|
29 | + public static $noteFileAddressId = null; |
|
30 | + |
|
31 | + public static $addresIdMarkedAsVisited; |
|
32 | + |
|
33 | + public static $afterAddressId; |
|
34 | + public static $route_id_dest; |
|
35 | + |
|
36 | + public static $createdCustomNotes; |
|
37 | + |
|
38 | + public static function setUpBeforeClass() |
|
39 | + { |
|
40 | + if (Constants::API_KEY == Constants::DEMO_API_KEY) { |
|
41 | + $className = str_replace('UnitTestFiles\\Test\\','',get_class()); |
|
42 | + self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" ); |
|
43 | + } |
|
44 | + |
|
45 | + Route4Me::setApiKey(Constants::API_KEY); |
|
46 | + |
|
47 | + //<editor-fold desc="Prepare Addresses"> |
|
48 | + $addresses = []; |
|
49 | + $addresses[] = Address::fromArray([ |
|
50 | + 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
51 | + 'is_depot' => true, |
|
52 | + 'lat' => 30.159341812134, |
|
53 | + 'lng' => -81.538619995117, |
|
54 | + 'time' => 300, |
|
55 | + 'time_window_start' => 28800, |
|
56 | + 'time_window_end' => 32400, |
|
57 | + ]); |
|
58 | + |
|
59 | + $addresses[] = Address::fromArray([ |
|
60 | + 'address' => '214 Edgewater Branch Drive 32259', |
|
61 | + 'lat' => 30.103567123413, |
|
62 | + 'lng' => -81.595352172852, |
|
63 | + 'time' => 300, |
|
64 | + 'time_window_start' => 36000, |
|
65 | + 'time_window_end' => 37200, |
|
66 | + ]); |
|
67 | + |
|
68 | + $addresses[] = Address::fromArray([ |
|
69 | + 'address' => '756 eagle point dr 32092', |
|
70 | + 'lat' => 30.046422958374, |
|
71 | + 'lng' => -81.508758544922, |
|
72 | + 'time' => 300, |
|
73 | + 'time_window_start' => 39600, |
|
74 | + 'time_window_end' => 41400, |
|
75 | + ]); |
|
76 | + |
|
77 | + $addresses[] = Address::fromArray([ |
|
78 | + 'address' => '63 Stone Creek Cir St Johns, FL 32259, USA', |
|
79 | + 'lat' => 30.048496, |
|
80 | + 'lng' => -81.558716, |
|
81 | + 'time' => 300, |
|
82 | + 'time_window_start' => 43200, |
|
83 | + 'time_window_end' => 45000, |
|
84 | + ]); |
|
85 | + |
|
86 | + $addresses[] = Address::fromArray([ |
|
87 | + 'address' => 'St Johns Florida 32259, USA', |
|
88 | + 'lat' => 30.099642, |
|
89 | + 'lng' => -81.547201, |
|
90 | + 'time' => 300, |
|
91 | + 'time_window_start' => 46800, |
|
92 | + 'time_window_end' => 48600, |
|
93 | + ]); |
|
94 | + |
|
95 | + $parameters = RouteParameters::fromArray([ |
|
96 | + 'device_type' => DeviceType::IPAD, |
|
97 | + 'disable_optimization' => false, |
|
98 | + 'route_name' => 'phpunit test '.date('Y-m-d H:i'), |
|
99 | + ]); |
|
100 | + //</editor-fold> |
|
101 | + |
|
102 | + $optimizationParameters = new OptimizationProblemParams(); |
|
103 | + $optimizationParameters->setAddresses($addresses); |
|
104 | + $optimizationParameters->setParameters($parameters); |
|
105 | + |
|
106 | + self::$problem = OptimizationProblem::optimize($optimizationParameters); |
|
107 | + $routes = self::$problem->getRoutes(); |
|
108 | + self::$route_id = $routes[0]->route_id; |
|
109 | + self::$noteAddressId = $routes[0]->addresses[2]->route_destination_id; |
|
110 | + self::$noteFileAddressId = $routes[0]->addresses[3]->route_destination_id; |
|
111 | + |
|
112 | + $addresses = self::$problem->addresses; |
|
113 | + self::$address_id = $addresses[1]->getAddressId(); |
|
114 | + //self::$address_address = $addresses[1]->address; |
|
115 | + self::$address_lat = $addresses[1]->lat; |
|
116 | + self::$address_lng = $addresses[1]->lng; |
|
117 | + self::$address_is_depot = $addresses[1]->is_depot; |
|
118 | + |
|
119 | + $noteParameters = [ |
|
120 | + 'route_id' => self::$route_id, |
|
121 | + 'address_id' => self::$address_id, |
|
122 | + 'dev_lat' => self::$address_lat, |
|
123 | + 'dev_lng' => self::$address_lng, |
|
124 | + 'device_type' => 'web', |
|
125 | + 'strUpdateType' => 'dropoff', |
|
126 | + 'strNoteContents' => 'Test Address Note', |
|
127 | + ]; |
|
128 | + |
|
129 | + $addressNote = new AddressNote(); |
|
130 | + |
|
131 | + $addresses[1] = $addressNote->AddAddressNote($noteParameters); |
|
132 | + |
|
133 | + self::$createdCustomNotes = []; |
|
134 | + |
|
135 | + $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
|
136 | + |
|
137 | + foreach ($customNoteTypes as $custNote) { |
|
138 | + if ($custNote['note_custom_type'] == 'Unit Test To Do') { |
|
139 | + self::$createdCustomNotes[]='Unit Test To Do'; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + if (sizeof(self::$createdCustomNotes)<1) { |
|
144 | + $customNoteTypeParameters = [ |
|
145 | + 'type' => 'Unit Test To Do', |
|
146 | + 'values' => [ |
|
147 | + 'Pass a package', |
|
148 | + 'Pickup package', |
|
149 | + 'Do a service', |
|
150 | + ], |
|
151 | + ]; |
|
152 | + |
|
153 | + $customNoteTypeResult = $addressNote->createCustomNoteType($customNoteTypeParameters); |
|
154 | + |
|
155 | + if ($customNoteTypeResult!=null |
|
156 | + && $customNoteTypeResult['result']!=null |
|
157 | + && $customNoteTypeResult['result']=='OK' |
|
158 | + && $customNoteTypeResult['affected']!=null |
|
159 | + && $customNoteTypeResult['affected']==1 |
|
160 | + ) { |
|
161 | + self::$createdCustomNotes[]='Unit Test To Do'; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + public function testFromArray() |
|
167 | + { |
|
168 | + $addressNote = AddressNote::fromArray([ |
|
169 | + 'note_id' => 539264, |
|
170 | + 'route_id' => '5555E83A4BE0055551537955558D5555', |
|
171 | + 'route_destination_id' => 162916895, |
|
172 | + 'ts_added' => 1466515325, |
|
173 | + 'activity_type' => 'dropoff', |
|
174 | + 'upload_id' => '1a499993c63d68d1a5d26045a1763d16', |
|
175 | + 'upload_extension' => 'csv', |
|
176 | + 'upload_url' => 'http:\/\/adb6def9928467589ebb-f540d5a8d53c2e76ad581b6e5c346ad6.\/1a499113c63d68d1a5d26045a1763d16.csv', |
|
177 | + 'upload_type' => 'ANY_FILE', |
|
178 | + 'contents' => 'Some text', |
|
179 | + 'lat' => 33.132675, |
|
180 | + 'lng' => -83.244743, |
|
181 | + 'device_type' => 'web' |
|
182 | + ]); |
|
183 | + |
|
184 | + $this->assertEquals(539264, $addressNote->note_id); |
|
185 | + $this->assertEquals('5555E83A4BE0055551537955558D5555', $addressNote->route_id); |
|
186 | + $this->assertEquals(162916895, $addressNote->route_destination_id); |
|
187 | + $this->assertEquals(1466515325, $addressNote->ts_added); |
|
188 | + $this->assertEquals('dropoff', $addressNote->activity_type); |
|
189 | + $this->assertEquals('1a499993c63d68d1a5d26045a1763d16', $addressNote->upload_id); |
|
190 | + $this->assertEquals('csv', $addressNote->upload_extension); |
|
191 | + $this->assertEquals('http:\/\/adb6def9928467589ebb-f540d5a8d53c2e76ad581b6e5c346ad6.\/1a499113c63d68d1a5d26045a1763d16.csv', $addressNote->upload_url); |
|
192 | + $this->assertEquals('ANY_FILE', $addressNote->upload_type); |
|
193 | + $this->assertEquals('Some text', $addressNote->contents); |
|
194 | + $this->assertEquals(33.132675, $addressNote->lat); |
|
195 | + $this->assertEquals(-83.244743, $addressNote->lng); |
|
196 | + $this->assertEquals('web', $addressNote->device_type); |
|
197 | + } |
|
198 | + |
|
199 | + public function testGetAddressesNotes() |
|
200 | + { |
|
201 | + $noteParameters = [ |
|
202 | + 'route_id' => self::$route_id, |
|
203 | + 'route_destination_id' => self::$address_id, |
|
204 | + ]; |
|
205 | + |
|
206 | + $addressNote = new AddressNote(); |
|
207 | + |
|
208 | + $addressWithNotes = Address::fromArray( |
|
209 | + $addressNote->GetAddressesNotes($noteParameters) |
|
210 | + ); |
|
211 | + |
|
212 | + $firstNote = AddressNote::fromArray( |
|
213 | + $addressWithNotes->notes[0] |
|
214 | + ); |
|
215 | + |
|
216 | + $this->assertNotNull($addressWithNotes); |
|
217 | + $this->assertTrue(sizeof( $addressWithNotes->notes)>0); |
|
218 | + $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
|
219 | + $this->assertEquals('Test Address Note', $firstNote->contents); |
|
220 | + $this->assertEquals('dropoff',$firstNote->activity_type); |
|
221 | + } |
|
222 | + |
|
223 | + public function testAddAddressNote() |
|
224 | + { |
|
225 | + $noteParameters = [ |
|
226 | + 'strFilename' => 'notes.csv', |
|
227 | + 'route_id' => self::$route_id, |
|
228 | + 'address_id' => self::$noteAddressId, |
|
229 | + 'dev_lat' => 33.132675170898, |
|
230 | + 'dev_lng' => -83.244743347168, |
|
231 | + 'device_type' => 'web', |
|
232 | + 'strUpdateType' => 'dropoff', |
|
233 | + 'strNoteContents' => 'Test Add Note To Route Address', |
|
234 | + ]; |
|
235 | + |
|
236 | + $addressNote = new AddressNote(); |
|
237 | + |
|
238 | + $response = AddressNoteResponse::fromArray( |
|
239 | + $addressNote->AddAddressNote($noteParameters) |
|
240 | + ); |
|
241 | + |
|
242 | + $this->assertNotNull($response); |
|
243 | + $this->assertContainsOnlyInstancesOf(AddressNoteResponse::class, [$response]); |
|
244 | + |
|
245 | + $firstNote = AddressNote::fromArray( |
|
246 | + $response->note |
|
247 | + ); |
|
248 | + |
|
249 | + $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
|
250 | + $this->assertEquals('Test Add Note To Route Address', $firstNote->contents); |
|
251 | + $this->assertNotNull($firstNote->upload_id); |
|
252 | + } |
|
253 | + |
|
254 | + public function testAddNoteFile() |
|
255 | + { |
|
256 | + //$this->markTestSkipped('must be revisited.'); |
|
257 | + |
|
258 | + $noteParameters = [ |
|
259 | + 'strFilename' => dirname(__FILE__).'\data\notes.csv', |
|
260 | + 'route_id' => self::$route_id, |
|
261 | + 'address_id' => self::$noteFileAddressId, |
|
262 | + 'dev_lat' => 33.132675170898, |
|
263 | + 'dev_lng' => -83.244743347168, |
|
264 | + 'device_type' => 'web', |
|
265 | + 'strUpdateType' => 'dropoff', |
|
266 | + ]; |
|
267 | + |
|
268 | + $addressNote = new AddressNote(); |
|
269 | + |
|
270 | + $result = $addressNote->AddNoteFile($noteParameters); |
|
271 | + |
|
272 | + $response = AddressNoteResponse::fromArray( |
|
273 | + $result |
|
274 | + ); |
|
275 | + |
|
276 | + sleep(5); |
|
277 | + |
|
278 | + $this->assertNotNull($response); |
|
279 | + $this->assertNotNull($response->status); |
|
280 | + $this->assertTrue($response->status); |
|
281 | + $this->assertContainsOnlyInstancesOf(AddressNoteResponse::class, [$response]); |
|
282 | + |
|
283 | + $firstNote = AddressNote::fromArray( |
|
284 | + $response->note |
|
285 | + ); |
|
286 | + |
|
287 | + $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
|
288 | + $this->assertNotNull($firstNote->upload_id); |
|
289 | + $this->assertNotNull($firstNote->upload_url); |
|
290 | + $this->assertEquals('csv', $firstNote->upload_extension); |
|
291 | + } |
|
292 | + |
|
293 | + public function testGetCustomNoteTypeByKey() |
|
294 | + { |
|
295 | + $addressNote = new AddressNote(); |
|
296 | + |
|
297 | + $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
|
298 | + |
|
299 | + $this->assertEquals(self::$createdCustomNotes[0],$customNoteType['note_custom_type']); |
|
300 | + } |
|
301 | + |
|
302 | + public function testGetAllCustomNoteTypes() |
|
303 | + { |
|
304 | + $addressNote = new AddressNote(); |
|
305 | + |
|
306 | + $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
|
307 | + |
|
308 | + $firstCustomNoteType = CustomNoteTypeResponse::fromArray($customNoteTypes[0]); |
|
309 | + |
|
310 | + $this->assertNotNull($customNoteTypes); |
|
311 | + $this->assertTrue(sizeof($customNoteTypes)>0); |
|
312 | + $this->assertContainsOnlyInstancesOf(CustomNoteTypeResponse::class, [$firstCustomNoteType]); |
|
313 | + } |
|
314 | + |
|
315 | + public function testCreateCustomNoteType() |
|
316 | + { |
|
317 | + $customNoteTypeKey = 'cnt'.date('yMdHi'); |
|
318 | + |
|
319 | + $noteParameters = [ |
|
320 | + 'type' => $customNoteTypeKey, |
|
321 | + 'values' => [ |
|
322 | + 'First value', |
|
323 | + 'Second value', |
|
324 | + 'Third value', |
|
325 | + ], |
|
326 | + ]; |
|
327 | 327 | |
328 | - $addressNote = new AddressNote(); |
|
328 | + $addressNote = new AddressNote(); |
|
329 | 329 | |
330 | - $response = $addressNote->createCustomNoteType($noteParameters); |
|
330 | + $response = $addressNote->createCustomNoteType($noteParameters); |
|
331 | 331 | |
332 | - $this->assertNotNull($response); |
|
333 | - $this->assertNotNull($response['result']); |
|
334 | - $this->assertEquals('OK', $response['result']); |
|
335 | - $this->assertNotNull($response['affected']); |
|
336 | - $this->assertEquals(1, $response['affected']); |
|
332 | + $this->assertNotNull($response); |
|
333 | + $this->assertNotNull($response['result']); |
|
334 | + $this->assertEquals('OK', $response['result']); |
|
335 | + $this->assertNotNull($response['affected']); |
|
336 | + $this->assertEquals(1, $response['affected']); |
|
337 | 337 | |
338 | - self::$createdCustomNotes[] = $customNoteTypeKey; |
|
339 | - } |
|
338 | + self::$createdCustomNotes[] = $customNoteTypeKey; |
|
339 | + } |
|
340 | 340 | |
341 | - public function testAddCustomNoteToRoute() |
|
342 | - { |
|
343 | - $addressNote = new AddressNote(); |
|
341 | + public function testAddCustomNoteToRoute() |
|
342 | + { |
|
343 | + $addressNote = new AddressNote(); |
|
344 | 344 | |
345 | - $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
|
345 | + $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
|
346 | 346 | |
347 | - $noteParameters = [ |
|
348 | - 'route_id' => self::$route_id, |
|
349 | - 'address_id' => self::$address_id, |
|
350 | - 'format' => 'json', |
|
351 | - 'dev_lat' => 33.132675170898, |
|
352 | - 'dev_lng' => -83.244743347168, |
|
353 | - 'custom_note_type['.$customNoteType["note_custom_type_id"].']' => 'Pickup package', |
|
354 | - 'strUpdateType' => 'dropoff', |
|
355 | - 'strNoteContents' => 'php test 1111', |
|
356 | - ]; |
|
347 | + $noteParameters = [ |
|
348 | + 'route_id' => self::$route_id, |
|
349 | + 'address_id' => self::$address_id, |
|
350 | + 'format' => 'json', |
|
351 | + 'dev_lat' => 33.132675170898, |
|
352 | + 'dev_lng' => -83.244743347168, |
|
353 | + 'custom_note_type['.$customNoteType["note_custom_type_id"].']' => 'Pickup package', |
|
354 | + 'strUpdateType' => 'dropoff', |
|
355 | + 'strNoteContents' => 'php test 1111', |
|
356 | + ]; |
|
357 | 357 | |
358 | - $response = AddressNoteResponse::fromArray( |
|
359 | - $addressNote->addCustomNoteToRoute($noteParameters) |
|
360 | - ); |
|
358 | + $response = AddressNoteResponse::fromArray( |
|
359 | + $addressNote->addCustomNoteToRoute($noteParameters) |
|
360 | + ); |
|
361 | 361 | |
362 | - $this->assertNotNull($response); |
|
363 | - $this->assertContainsOnlyInstancesOf(AddressNoteResponse::class, [$response]); |
|
362 | + $this->assertNotNull($response); |
|
363 | + $this->assertContainsOnlyInstancesOf(AddressNoteResponse::class, [$response]); |
|
364 | 364 | |
365 | - $note = AddressNote::fromArray($response->note); |
|
366 | - $this->assertNotNull($note); |
|
367 | - $this->assertNotNull($note->custom_types); |
|
368 | - $this->assertTrue(sizeof($note->custom_types)>0); |
|
365 | + $note = AddressNote::fromArray($response->note); |
|
366 | + $this->assertNotNull($note); |
|
367 | + $this->assertNotNull($note->custom_types); |
|
368 | + $this->assertTrue(sizeof($note->custom_types)>0); |
|
369 | 369 | |
370 | - $customNote = CustomNoteType::fromArray($note->custom_types[0]); |
|
370 | + $customNote = CustomNoteType::fromArray($note->custom_types[0]); |
|
371 | 371 | |
372 | - $this->assertContainsOnlyInstancesOf(CustomNoteType::class, [$customNote]); |
|
373 | - $this->assertEquals('Pickup package',$customNote->note_custom_value); |
|
374 | - } |
|
372 | + $this->assertContainsOnlyInstancesOf(CustomNoteType::class, [$customNote]); |
|
373 | + $this->assertEquals('Pickup package',$customNote->note_custom_value); |
|
374 | + } |
|
375 | 375 | |
376 | - public function testRemoveCustomNoteType() |
|
377 | - { |
|
378 | - $addressNote = new AddressNote(); |
|
376 | + public function testRemoveCustomNoteType() |
|
377 | + { |
|
378 | + $addressNote = new AddressNote(); |
|
379 | 379 | |
380 | - $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
|
380 | + $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
|
381 | 381 | |
382 | - $customNoteTypeParameters = [ |
|
383 | - 'id' => $customNoteType["note_custom_type_id"], |
|
384 | - ]; |
|
382 | + $customNoteTypeParameters = [ |
|
383 | + 'id' => $customNoteType["note_custom_type_id"], |
|
384 | + ]; |
|
385 | 385 | |
386 | - $response = $addressNote->removeCustomNoteType($customNoteTypeParameters); |
|
386 | + $response = $addressNote->removeCustomNoteType($customNoteTypeParameters); |
|
387 | 387 | |
388 | - $this->assertNotNull($response); |
|
389 | - $this->assertNotNull($response['result']); |
|
390 | - $this->assertEquals('OK', $response['result']); |
|
391 | - $this->assertNotNull($response['affected']); |
|
392 | - $this->assertEquals(1, $response['affected']); |
|
388 | + $this->assertNotNull($response); |
|
389 | + $this->assertNotNull($response['result']); |
|
390 | + $this->assertEquals('OK', $response['result']); |
|
391 | + $this->assertNotNull($response['affected']); |
|
392 | + $this->assertEquals(1, $response['affected']); |
|
393 | 393 | |
394 | - array_shift(self::$createdCustomNotes); |
|
395 | - } |
|
394 | + array_shift(self::$createdCustomNotes); |
|
395 | + } |
|
396 | 396 | |
397 | - public static function tearDownAfterClass() |
|
398 | - { |
|
399 | - $optimizationProblemId = self:: $problem->optimization_problem_id; |
|
397 | + public static function tearDownAfterClass() |
|
398 | + { |
|
399 | + $optimizationProblemId = self:: $problem->optimization_problem_id; |
|
400 | 400 | |
401 | - $params = [ |
|
402 | - 'optimization_problem_ids' => [ |
|
403 | - '0' => $optimizationProblemId |
|
404 | - ], |
|
405 | - 'redirect' => 0, |
|
406 | - ]; |
|
401 | + $params = [ |
|
402 | + 'optimization_problem_ids' => [ |
|
403 | + '0' => $optimizationProblemId |
|
404 | + ], |
|
405 | + 'redirect' => 0, |
|
406 | + ]; |
|
407 | 407 | |
408 | - $result = self:: $problem->removeOptimization($params); |
|
408 | + $result = self:: $problem->removeOptimization($params); |
|
409 | 409 | |
410 | - if ($result!=null && $result['status']==true) { |
|
411 | - echo "The test optimization was removed <br>"; |
|
412 | - } else { |
|
413 | - echo "Cannot remove the test optimization <br>"; |
|
414 | - } |
|
410 | + if ($result!=null && $result['status']==true) { |
|
411 | + echo "The test optimization was removed <br>"; |
|
412 | + } else { |
|
413 | + echo "Cannot remove the test optimization <br>"; |
|
414 | + } |
|
415 | 415 | |
416 | - $addressNote = new AddressNote(); |
|
416 | + $addressNote = new AddressNote(); |
|
417 | 417 | |
418 | - foreach (self::$createdCustomNotes as $createdCustomNote) { |
|
419 | - $customNoteId = $addressNote->getCustomNoteTypeByKey($createdCustomNote)["note_custom_type_id"]; |
|
418 | + foreach (self::$createdCustomNotes as $createdCustomNote) { |
|
419 | + $customNoteId = $addressNote->getCustomNoteTypeByKey($createdCustomNote)["note_custom_type_id"]; |
|
420 | 420 | |
421 | - $customNoteTypeParameters = [ |
|
422 | - 'id' => $customNoteId, |
|
423 | - ]; |
|
421 | + $customNoteTypeParameters = [ |
|
422 | + 'id' => $customNoteId, |
|
423 | + ]; |
|
424 | 424 | |
425 | - $response = $addressNote->removeCustomNoteType($customNoteTypeParameters); |
|
425 | + $response = $addressNote->removeCustomNoteType($customNoteTypeParameters); |
|
426 | 426 | |
427 | - if ($response!=null && $response['result']!=null && $response['result']=='OK') { |
|
428 | - echo "Removed the custom note type ".$createdCustomNote.'<br>'; |
|
429 | - } |
|
430 | - } |
|
427 | + if ($response!=null && $response['result']!=null && $response['result']=='OK') { |
|
428 | + echo "Removed the custom note type ".$createdCustomNote.'<br>'; |
|
429 | + } |
|
430 | + } |
|
431 | 431 | |
432 | - } |
|
432 | + } |
|
433 | 433 | } |
434 | 434 | \ No newline at end of file |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | public static function setUpBeforeClass() |
39 | 39 | { |
40 | - if (Constants::API_KEY == Constants::DEMO_API_KEY) { |
|
41 | - $className = str_replace('UnitTestFiles\\Test\\','',get_class()); |
|
42 | - self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" ); |
|
40 | + if (Constants::API_KEY==Constants::DEMO_API_KEY) { |
|
41 | + $className = str_replace('UnitTestFiles\\Test\\', '', get_class()); |
|
42 | + self::markTestSkipped('PHPUnit will skip '.$className." class - it impossible run with demo API key"); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | Route4Me::setApiKey(Constants::API_KEY); |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
136 | 136 | |
137 | 137 | foreach ($customNoteTypes as $custNote) { |
138 | - if ($custNote['note_custom_type'] == 'Unit Test To Do') { |
|
139 | - self::$createdCustomNotes[]='Unit Test To Do'; |
|
138 | + if ($custNote['note_custom_type']=='Unit Test To Do') { |
|
139 | + self::$createdCustomNotes[] = 'Unit Test To Do'; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | && $customNoteTypeResult['affected']!=null |
159 | 159 | && $customNoteTypeResult['affected']==1 |
160 | 160 | ) { |
161 | - self::$createdCustomNotes[]='Unit Test To Do'; |
|
161 | + self::$createdCustomNotes[] = 'Unit Test To Do'; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | ); |
215 | 215 | |
216 | 216 | $this->assertNotNull($addressWithNotes); |
217 | - $this->assertTrue(sizeof( $addressWithNotes->notes)>0); |
|
217 | + $this->assertTrue(sizeof($addressWithNotes->notes)>0); |
|
218 | 218 | $this->assertContainsOnlyInstancesOf(AddressNote::class, [$firstNote]); |
219 | 219 | $this->assertEquals('Test Address Note', $firstNote->contents); |
220 | - $this->assertEquals('dropoff',$firstNote->activity_type); |
|
220 | + $this->assertEquals('dropoff', $firstNote->activity_type); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | public function testAddAddressNote() |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | |
297 | 297 | $customNoteType = $addressNote->getCustomNoteTypeByKey(self::$createdCustomNotes[0]); |
298 | 298 | |
299 | - $this->assertEquals(self::$createdCustomNotes[0],$customNoteType['note_custom_type']); |
|
299 | + $this->assertEquals(self::$createdCustomNotes[0], $customNoteType['note_custom_type']); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | public function testGetAllCustomNoteTypes() |
303 | 303 | { |
304 | 304 | $addressNote = new AddressNote(); |
305 | 305 | |
306 | - $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
|
306 | + $customNoteTypes = $addressNote->getAllCustomNoteTypes(); |
|
307 | 307 | |
308 | 308 | $firstCustomNoteType = CustomNoteTypeResponse::fromArray($customNoteTypes[0]); |
309 | 309 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $customNote = CustomNoteType::fromArray($note->custom_types[0]); |
371 | 371 | |
372 | 372 | $this->assertContainsOnlyInstancesOf(CustomNoteType::class, [$customNote]); |
373 | - $this->assertEquals('Pickup package',$customNote->note_custom_value); |
|
373 | + $this->assertEquals('Pickup package', $customNote->note_custom_value); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | public function testRemoveCustomNoteType() |
@@ -14,205 +14,205 @@ |
||
14 | 14 | |
15 | 15 | class ActivityParametersUntTests extends \PHPUnit\Framework\TestCase |
16 | 16 | { |
17 | - public static $route_id = null; |
|
18 | - public static $problem = null; |
|
19 | - |
|
20 | - public static function setUpBeforeClass() |
|
21 | - { |
|
22 | - if (Constants::API_KEY == Constants::DEMO_API_KEY) { |
|
23 | - $className = str_replace('UnitTestFiles\\Test\\','',get_class()); |
|
24 | - self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" ); |
|
25 | - } |
|
26 | - |
|
27 | - Route4Me::setApiKey(Constants::API_KEY); |
|
28 | - |
|
29 | - $addresses = []; |
|
30 | - $addresses[] = Address::fromArray([ |
|
31 | - 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
32 | - 'is_depot' => true, |
|
33 | - 'lat' => 30.159341812134, |
|
34 | - 'lng' => -81.538619995117, |
|
35 | - 'time' => 300, |
|
36 | - 'time_window_start' => 28800, |
|
37 | - 'time_window_end' => 32400, |
|
38 | - ]); |
|
39 | - |
|
40 | - $addresses[] = Address::fromArray([ |
|
41 | - 'address' => '214 Edgewater Branch Drive 32259', |
|
42 | - 'lat' => 30.103567123413, |
|
43 | - 'lng' => -81.595352172852, |
|
44 | - 'time' => 300, |
|
45 | - 'time_window_start' => 36000, |
|
46 | - 'time_window_end' => 37200, |
|
47 | - ]); |
|
48 | - |
|
49 | - $addresses[] = Address::fromArray([ |
|
50 | - 'address' => '756 eagle point dr 32092', |
|
51 | - 'lat' => 30.046422958374, |
|
52 | - 'lng' => -81.508758544922, |
|
53 | - 'time' => 300, |
|
54 | - 'time_window_start' => 39600, |
|
55 | - 'time_window_end' => 41400, |
|
56 | - ]); |
|
57 | - |
|
58 | - $addresses[] = Address::fromArray([ |
|
59 | - 'address' => '63 Stone Creek Cir St Johns, FL 32259, USA', |
|
60 | - 'lat' => 30.048496, |
|
61 | - 'lng' => -81.558716, |
|
62 | - 'time' => 300, |
|
63 | - 'time_window_start' => 43200, |
|
64 | - 'time_window_end' => 45000, |
|
65 | - ]); |
|
66 | - |
|
67 | - $parameters = RouteParameters::fromArray([ |
|
68 | - 'device_type' => DeviceType::IPAD, |
|
69 | - 'disable_optimization' => false, |
|
70 | - 'route_name' => 'phpunit test '.date('Y-m-d H:i'), |
|
71 | - ]); |
|
72 | - |
|
73 | - $optimizationParameters = new OptimizationProblemParams(); |
|
74 | - $optimizationParameters->setAddresses($addresses); |
|
75 | - $optimizationParameters->setParameters($parameters); |
|
76 | - |
|
77 | - self::$problem = OptimizationProblem::optimize($optimizationParameters); |
|
78 | - $routes = self::$problem->getRoutes(); |
|
79 | - self::$route_id = $routes[0]->route_id; |
|
80 | - } |
|
81 | - |
|
82 | - public function testFromArray() |
|
83 | - { |
|
84 | - $activityParameters = ActivityParameters::fromArray([ |
|
85 | - "activity_id" => "77BBB5F38723CCCCCCCCCCCCCCCCDD88", |
|
86 | - "member_id" => 444333, |
|
87 | - "activity_timestamp" => 1595418362, |
|
88 | - "activity_type" => "note-insert", |
|
89 | - "activity_message" => "A note was added to address '63 Stone Creek Cir St Johns, FL 32259, USA' from Web Interface", |
|
90 | - "route_id" => "38777FFFE274A1F970A3CA8D96F32222", |
|
91 | - "route_destination_id" => 535455583, |
|
92 | - "note_id" => 9933366, |
|
93 | - "note_type" => "Drop Off Occurred", |
|
94 | - "note_contents" => "Test Add Note To Route Address", |
|
95 | - "route_name" => "phpunit test 2020-07-22 13:45", |
|
96 | - "note_file" => "file.ext", |
|
97 | - "destination_name" => "63 Stone Creek Cir St Johns, FL 32259, USA", |
|
98 | - "destination_alias" => "Dest Alias", |
|
99 | - "member" => [ |
|
100 | - "member_id" => "444333", |
|
101 | - "member_first_name" => "Olbay", |
|
102 | - "member_last_name" => "Gustavson", |
|
103 | - "member_email" => "[email protected]" |
|
104 | - ] |
|
105 | - ]); |
|
106 | - |
|
107 | - $this->assertEquals('77BBB5F38723CCCCCCCCCCCCCCCCDD88', $activityParameters->activity_id); |
|
108 | - |
|
109 | - $this->assertEquals(444333, $activityParameters->member_id); |
|
110 | - $this->assertEquals(1595418362, $activityParameters->activity_timestamp); |
|
111 | - $this->assertEquals('note-insert', $activityParameters->activity_type); |
|
112 | - $this->assertEquals('A note was added to address \'63 Stone Creek Cir St Johns, FL 32259, USA\' from Web Interface', $activityParameters->activity_message); |
|
113 | - $this->assertEquals('38777FFFE274A1F970A3CA8D96F32222', $activityParameters->route_id); |
|
114 | - $this->assertEquals(535455583, $activityParameters->route_destination_id); |
|
115 | - $this->assertEquals(9933366, $activityParameters->note_id); |
|
116 | - $this->assertEquals('Drop Off Occurred', $activityParameters->note_type); |
|
117 | - $this->assertEquals('Test Add Note To Route Address', $activityParameters->note_contents); |
|
118 | - $this->assertEquals('phpunit test 2020-07-22 13:45', $activityParameters->route_name); |
|
119 | - $this->assertEquals('file.ext', $activityParameters->note_file); |
|
120 | - $this->assertEquals('63 Stone Creek Cir St Johns, FL 32259, USA', $activityParameters->destination_name); |
|
121 | - $this->assertEquals('Dest Alias', $activityParameters->destination_alias); |
|
122 | - $this->assertEquals([ |
|
123 | - "member_id" => "444333", |
|
124 | - "member_first_name" => "Olbay", |
|
125 | - "member_last_name" => "Gustavson", |
|
126 | - "member_email" => "[email protected]" |
|
127 | - ], $activityParameters->member); |
|
128 | - } |
|
129 | - |
|
130 | - public function testGetActivities() |
|
131 | - { |
|
132 | - $activities = new ActivityParameters(); |
|
133 | - |
|
134 | - $activityParameters = ActivityParameters::fromArray([ |
|
135 | - 'limit' => 10, |
|
136 | - 'offset' => 0, |
|
137 | - ]); |
|
138 | - |
|
139 | - $result = $activities->getActivities($activityParameters); |
|
140 | - |
|
141 | - $this->assertNotNull($result); |
|
142 | - $this->assertNotNull(isset($result['results'])); |
|
143 | - |
|
144 | - $firstActivity = ActivityParameters::fromArray( |
|
145 | - $result['results'][0] |
|
146 | - ); |
|
147 | - |
|
148 | - $this->assertContainsOnlyInstancesOf(ActivityParameters::class, [$firstActivity]); |
|
149 | - } |
|
150 | - |
|
151 | - public function testSearchActivities() |
|
152 | - { |
|
153 | - $activities = new ActivityParameters(); |
|
154 | - |
|
155 | - $activityTypes = new ActivityTypes(); |
|
156 | - |
|
157 | - foreach ($activityTypes->getConstants() as $prop => $value) { |
|
158 | - $activityParameters = ActivityParameters::fromArray([ |
|
159 | - 'activity_type' => $value, |
|
160 | - 'limit' => 2, |
|
161 | - 'offset' => 0, |
|
162 | - ]); |
|
163 | - |
|
164 | - $activities = new ActivityParameters(); |
|
165 | - $result = $activities->searchActivities($activityParameters); |
|
166 | - |
|
167 | - $this->assertNotNull($result); |
|
168 | - $this->assertNotNull(isset($result['results'])); |
|
169 | - |
|
170 | - if (sizeof($result['results'])>0) { |
|
171 | - $firstActivity = ActivityParameters::fromArray( |
|
172 | - $result['results'][0] |
|
173 | - ); |
|
174 | - |
|
175 | - $this->assertContainsOnlyInstancesOf(ActivityParameters::class, [$firstActivity]); |
|
176 | - } |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - public function testSendUserMessage() |
|
181 | - { |
|
182 | - $activities = new ActivityParameters(); |
|
183 | - |
|
184 | - $postParameters = ActivityParameters::fromArray([ |
|
185 | - 'activity_type' => 'user_message', |
|
186 | - 'activity_message' => 'Hello - php!', |
|
187 | - 'route_id' => self::$route_id, |
|
188 | - ]); |
|
189 | - |
|
190 | - $result = $activities->sendUserMessage($postParameters); |
|
191 | - |
|
192 | - $this->assertNotNull($result); |
|
193 | - $this->assertNotNull(isset($result['status'])); |
|
194 | - $this->assertTrue(isset($result['status'])); |
|
195 | - } |
|
196 | - |
|
197 | - public static function tearDownAfterClass() |
|
198 | - { |
|
199 | - $optimizationProblemId = self:: $problem->optimization_problem_id; |
|
200 | - |
|
201 | - $params = [ |
|
202 | - 'optimization_problem_ids' => [ |
|
203 | - '0' => $optimizationProblemId |
|
204 | - ], |
|
205 | - 'redirect' => 0, |
|
206 | - ]; |
|
207 | - |
|
208 | - $optimizationProblem = new OptimizationProblem(); |
|
209 | - |
|
210 | - $result = $optimizationProblem->removeOptimization($params); |
|
211 | - |
|
212 | - if ($result!=null && $result['status']==true) { |
|
213 | - echo "The test optimization was removed <br>"; |
|
214 | - } else { |
|
215 | - echo "Cannot remove the test optimization <br>"; |
|
216 | - } |
|
217 | - } |
|
17 | + public static $route_id = null; |
|
18 | + public static $problem = null; |
|
19 | + |
|
20 | + public static function setUpBeforeClass() |
|
21 | + { |
|
22 | + if (Constants::API_KEY == Constants::DEMO_API_KEY) { |
|
23 | + $className = str_replace('UnitTestFiles\\Test\\','',get_class()); |
|
24 | + self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" ); |
|
25 | + } |
|
26 | + |
|
27 | + Route4Me::setApiKey(Constants::API_KEY); |
|
28 | + |
|
29 | + $addresses = []; |
|
30 | + $addresses[] = Address::fromArray([ |
|
31 | + 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
32 | + 'is_depot' => true, |
|
33 | + 'lat' => 30.159341812134, |
|
34 | + 'lng' => -81.538619995117, |
|
35 | + 'time' => 300, |
|
36 | + 'time_window_start' => 28800, |
|
37 | + 'time_window_end' => 32400, |
|
38 | + ]); |
|
39 | + |
|
40 | + $addresses[] = Address::fromArray([ |
|
41 | + 'address' => '214 Edgewater Branch Drive 32259', |
|
42 | + 'lat' => 30.103567123413, |
|
43 | + 'lng' => -81.595352172852, |
|
44 | + 'time' => 300, |
|
45 | + 'time_window_start' => 36000, |
|
46 | + 'time_window_end' => 37200, |
|
47 | + ]); |
|
48 | + |
|
49 | + $addresses[] = Address::fromArray([ |
|
50 | + 'address' => '756 eagle point dr 32092', |
|
51 | + 'lat' => 30.046422958374, |
|
52 | + 'lng' => -81.508758544922, |
|
53 | + 'time' => 300, |
|
54 | + 'time_window_start' => 39600, |
|
55 | + 'time_window_end' => 41400, |
|
56 | + ]); |
|
57 | + |
|
58 | + $addresses[] = Address::fromArray([ |
|
59 | + 'address' => '63 Stone Creek Cir St Johns, FL 32259, USA', |
|
60 | + 'lat' => 30.048496, |
|
61 | + 'lng' => -81.558716, |
|
62 | + 'time' => 300, |
|
63 | + 'time_window_start' => 43200, |
|
64 | + 'time_window_end' => 45000, |
|
65 | + ]); |
|
66 | + |
|
67 | + $parameters = RouteParameters::fromArray([ |
|
68 | + 'device_type' => DeviceType::IPAD, |
|
69 | + 'disable_optimization' => false, |
|
70 | + 'route_name' => 'phpunit test '.date('Y-m-d H:i'), |
|
71 | + ]); |
|
72 | + |
|
73 | + $optimizationParameters = new OptimizationProblemParams(); |
|
74 | + $optimizationParameters->setAddresses($addresses); |
|
75 | + $optimizationParameters->setParameters($parameters); |
|
76 | + |
|
77 | + self::$problem = OptimizationProblem::optimize($optimizationParameters); |
|
78 | + $routes = self::$problem->getRoutes(); |
|
79 | + self::$route_id = $routes[0]->route_id; |
|
80 | + } |
|
81 | + |
|
82 | + public function testFromArray() |
|
83 | + { |
|
84 | + $activityParameters = ActivityParameters::fromArray([ |
|
85 | + "activity_id" => "77BBB5F38723CCCCCCCCCCCCCCCCDD88", |
|
86 | + "member_id" => 444333, |
|
87 | + "activity_timestamp" => 1595418362, |
|
88 | + "activity_type" => "note-insert", |
|
89 | + "activity_message" => "A note was added to address '63 Stone Creek Cir St Johns, FL 32259, USA' from Web Interface", |
|
90 | + "route_id" => "38777FFFE274A1F970A3CA8D96F32222", |
|
91 | + "route_destination_id" => 535455583, |
|
92 | + "note_id" => 9933366, |
|
93 | + "note_type" => "Drop Off Occurred", |
|
94 | + "note_contents" => "Test Add Note To Route Address", |
|
95 | + "route_name" => "phpunit test 2020-07-22 13:45", |
|
96 | + "note_file" => "file.ext", |
|
97 | + "destination_name" => "63 Stone Creek Cir St Johns, FL 32259, USA", |
|
98 | + "destination_alias" => "Dest Alias", |
|
99 | + "member" => [ |
|
100 | + "member_id" => "444333", |
|
101 | + "member_first_name" => "Olbay", |
|
102 | + "member_last_name" => "Gustavson", |
|
103 | + "member_email" => "[email protected]" |
|
104 | + ] |
|
105 | + ]); |
|
106 | + |
|
107 | + $this->assertEquals('77BBB5F38723CCCCCCCCCCCCCCCCDD88', $activityParameters->activity_id); |
|
108 | + |
|
109 | + $this->assertEquals(444333, $activityParameters->member_id); |
|
110 | + $this->assertEquals(1595418362, $activityParameters->activity_timestamp); |
|
111 | + $this->assertEquals('note-insert', $activityParameters->activity_type); |
|
112 | + $this->assertEquals('A note was added to address \'63 Stone Creek Cir St Johns, FL 32259, USA\' from Web Interface', $activityParameters->activity_message); |
|
113 | + $this->assertEquals('38777FFFE274A1F970A3CA8D96F32222', $activityParameters->route_id); |
|
114 | + $this->assertEquals(535455583, $activityParameters->route_destination_id); |
|
115 | + $this->assertEquals(9933366, $activityParameters->note_id); |
|
116 | + $this->assertEquals('Drop Off Occurred', $activityParameters->note_type); |
|
117 | + $this->assertEquals('Test Add Note To Route Address', $activityParameters->note_contents); |
|
118 | + $this->assertEquals('phpunit test 2020-07-22 13:45', $activityParameters->route_name); |
|
119 | + $this->assertEquals('file.ext', $activityParameters->note_file); |
|
120 | + $this->assertEquals('63 Stone Creek Cir St Johns, FL 32259, USA', $activityParameters->destination_name); |
|
121 | + $this->assertEquals('Dest Alias', $activityParameters->destination_alias); |
|
122 | + $this->assertEquals([ |
|
123 | + "member_id" => "444333", |
|
124 | + "member_first_name" => "Olbay", |
|
125 | + "member_last_name" => "Gustavson", |
|
126 | + "member_email" => "[email protected]" |
|
127 | + ], $activityParameters->member); |
|
128 | + } |
|
129 | + |
|
130 | + public function testGetActivities() |
|
131 | + { |
|
132 | + $activities = new ActivityParameters(); |
|
133 | + |
|
134 | + $activityParameters = ActivityParameters::fromArray([ |
|
135 | + 'limit' => 10, |
|
136 | + 'offset' => 0, |
|
137 | + ]); |
|
138 | + |
|
139 | + $result = $activities->getActivities($activityParameters); |
|
140 | + |
|
141 | + $this->assertNotNull($result); |
|
142 | + $this->assertNotNull(isset($result['results'])); |
|
143 | + |
|
144 | + $firstActivity = ActivityParameters::fromArray( |
|
145 | + $result['results'][0] |
|
146 | + ); |
|
147 | + |
|
148 | + $this->assertContainsOnlyInstancesOf(ActivityParameters::class, [$firstActivity]); |
|
149 | + } |
|
150 | + |
|
151 | + public function testSearchActivities() |
|
152 | + { |
|
153 | + $activities = new ActivityParameters(); |
|
154 | + |
|
155 | + $activityTypes = new ActivityTypes(); |
|
156 | + |
|
157 | + foreach ($activityTypes->getConstants() as $prop => $value) { |
|
158 | + $activityParameters = ActivityParameters::fromArray([ |
|
159 | + 'activity_type' => $value, |
|
160 | + 'limit' => 2, |
|
161 | + 'offset' => 0, |
|
162 | + ]); |
|
163 | + |
|
164 | + $activities = new ActivityParameters(); |
|
165 | + $result = $activities->searchActivities($activityParameters); |
|
166 | + |
|
167 | + $this->assertNotNull($result); |
|
168 | + $this->assertNotNull(isset($result['results'])); |
|
169 | + |
|
170 | + if (sizeof($result['results'])>0) { |
|
171 | + $firstActivity = ActivityParameters::fromArray( |
|
172 | + $result['results'][0] |
|
173 | + ); |
|
174 | + |
|
175 | + $this->assertContainsOnlyInstancesOf(ActivityParameters::class, [$firstActivity]); |
|
176 | + } |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + public function testSendUserMessage() |
|
181 | + { |
|
182 | + $activities = new ActivityParameters(); |
|
183 | + |
|
184 | + $postParameters = ActivityParameters::fromArray([ |
|
185 | + 'activity_type' => 'user_message', |
|
186 | + 'activity_message' => 'Hello - php!', |
|
187 | + 'route_id' => self::$route_id, |
|
188 | + ]); |
|
189 | + |
|
190 | + $result = $activities->sendUserMessage($postParameters); |
|
191 | + |
|
192 | + $this->assertNotNull($result); |
|
193 | + $this->assertNotNull(isset($result['status'])); |
|
194 | + $this->assertTrue(isset($result['status'])); |
|
195 | + } |
|
196 | + |
|
197 | + public static function tearDownAfterClass() |
|
198 | + { |
|
199 | + $optimizationProblemId = self:: $problem->optimization_problem_id; |
|
200 | + |
|
201 | + $params = [ |
|
202 | + 'optimization_problem_ids' => [ |
|
203 | + '0' => $optimizationProblemId |
|
204 | + ], |
|
205 | + 'redirect' => 0, |
|
206 | + ]; |
|
207 | + |
|
208 | + $optimizationProblem = new OptimizationProblem(); |
|
209 | + |
|
210 | + $result = $optimizationProblem->removeOptimization($params); |
|
211 | + |
|
212 | + if ($result!=null && $result['status']==true) { |
|
213 | + echo "The test optimization was removed <br>"; |
|
214 | + } else { |
|
215 | + echo "Cannot remove the test optimization <br>"; |
|
216 | + } |
|
217 | + } |
|
218 | 218 | } |
219 | 219 | \ No newline at end of file |
@@ -19,9 +19,9 @@ |
||
19 | 19 | |
20 | 20 | public static function setUpBeforeClass() |
21 | 21 | { |
22 | - if (Constants::API_KEY == Constants::DEMO_API_KEY) { |
|
23 | - $className = str_replace('UnitTestFiles\\Test\\','',get_class()); |
|
24 | - self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" ); |
|
22 | + if (Constants::API_KEY==Constants::DEMO_API_KEY) { |
|
23 | + $className = str_replace('UnitTestFiles\\Test\\', '', get_class()); |
|
24 | + self::markTestSkipped('PHPUnit will skip '.$className." class - it impossible run with demo API key"); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | Route4Me::setApiKey(Constants::API_KEY); |
@@ -7,53 +7,53 @@ |
||
7 | 7 | |
8 | 8 | class AddressNoteResponseUnitTests extends \PHPUnit\Framework\TestCase |
9 | 9 | { |
10 | - public function testFromArray() |
|
11 | - { |
|
12 | - $addressNoteResponse = AddressNoteResponse::fromArray([ |
|
13 | - 'status' => true, |
|
14 | - 'note_id' => '1015289', |
|
15 | - 'upload_id' => '', |
|
16 | - 'note' => [ |
|
17 | - 'note_id' => 1015289, |
|
18 | - 'route_id' => 'DD376C7148E777736CFABE2BD9998BDD', |
|
19 | - 'route_destination_id' => 183045812, |
|
20 | - 'ts_added' => 1480511401, |
|
21 | - 'activity_type' => '', |
|
22 | - 'upload_id' => '', |
|
23 | - 'upload_extension' => null, |
|
24 | - 'upload_url' => null, |
|
25 | - 'upload_type' => null, |
|
26 | - 'contents' => 'Note example for Destination Audit Use Case', |
|
27 | - 'lat' => 41.145241, |
|
28 | - 'lng' => -81.410248, |
|
29 | - 'device_type' => 'web' |
|
30 | - ] |
|
31 | - ]); |
|
10 | + public function testFromArray() |
|
11 | + { |
|
12 | + $addressNoteResponse = AddressNoteResponse::fromArray([ |
|
13 | + 'status' => true, |
|
14 | + 'note_id' => '1015289', |
|
15 | + 'upload_id' => '', |
|
16 | + 'note' => [ |
|
17 | + 'note_id' => 1015289, |
|
18 | + 'route_id' => 'DD376C7148E777736CFABE2BD9998BDD', |
|
19 | + 'route_destination_id' => 183045812, |
|
20 | + 'ts_added' => 1480511401, |
|
21 | + 'activity_type' => '', |
|
22 | + 'upload_id' => '', |
|
23 | + 'upload_extension' => null, |
|
24 | + 'upload_url' => null, |
|
25 | + 'upload_type' => null, |
|
26 | + 'contents' => 'Note example for Destination Audit Use Case', |
|
27 | + 'lat' => 41.145241, |
|
28 | + 'lng' => -81.410248, |
|
29 | + 'device_type' => 'web' |
|
30 | + ] |
|
31 | + ]); |
|
32 | 32 | |
33 | - $this->assertEquals(true, $addressNoteResponse->status); |
|
34 | - $this->assertEquals('1015289', $addressNoteResponse->note_id); |
|
35 | - $this->assertEquals('', $addressNoteResponse->upload_id); |
|
36 | - $this->assertEquals([ |
|
37 | - 'note_id' => 1015289, |
|
38 | - 'route_id' => 'DD376C7148E777736CFABE2BD9998BDD', |
|
39 | - 'route_destination_id' => 183045812, |
|
40 | - 'ts_added' => 1480511401, |
|
41 | - 'activity_type' => '', |
|
42 | - 'upload_id' => '', |
|
43 | - 'upload_extension' => null, |
|
44 | - 'upload_url' => null, |
|
45 | - 'upload_type' => null, |
|
46 | - 'contents' => 'Note example for Destination Audit Use Case', |
|
47 | - 'lat' => 41.145241, |
|
48 | - 'lng' => -81.410248, |
|
49 | - 'device_type' => 'web' |
|
50 | - ], |
|
51 | - $addressNoteResponse->note); |
|
33 | + $this->assertEquals(true, $addressNoteResponse->status); |
|
34 | + $this->assertEquals('1015289', $addressNoteResponse->note_id); |
|
35 | + $this->assertEquals('', $addressNoteResponse->upload_id); |
|
36 | + $this->assertEquals([ |
|
37 | + 'note_id' => 1015289, |
|
38 | + 'route_id' => 'DD376C7148E777736CFABE2BD9998BDD', |
|
39 | + 'route_destination_id' => 183045812, |
|
40 | + 'ts_added' => 1480511401, |
|
41 | + 'activity_type' => '', |
|
42 | + 'upload_id' => '', |
|
43 | + 'upload_extension' => null, |
|
44 | + 'upload_url' => null, |
|
45 | + 'upload_type' => null, |
|
46 | + 'contents' => 'Note example for Destination Audit Use Case', |
|
47 | + 'lat' => 41.145241, |
|
48 | + 'lng' => -81.410248, |
|
49 | + 'device_type' => 'web' |
|
50 | + ], |
|
51 | + $addressNoteResponse->note); |
|
52 | 52 | |
53 | - $note = AddressNote::fromArray( |
|
54 | - $addressNoteResponse->note |
|
55 | - ); |
|
53 | + $note = AddressNote::fromArray( |
|
54 | + $addressNoteResponse->note |
|
55 | + ); |
|
56 | 56 | |
57 | - $this->assertContainsOnlyInstancesOf(AddressNote::class, [$note]); |
|
58 | - } |
|
57 | + $this->assertContainsOnlyInstancesOf(AddressNote::class, [$note]); |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -7,16 +7,16 @@ |
||
7 | 7 | |
8 | 8 | class RapidAddressSearchResponseUnitTests extends \PHPUnit\Framework\TestCase |
9 | 9 | { |
10 | - public function testFromArray() |
|
11 | - { |
|
12 | - $rapidAddressSearch = RapidAddressSearchResponse::fromArray([ |
|
13 | - 'zipcode' => '00601', |
|
14 | - 'street_name' => 'GENERAL DELIVERY', |
|
15 | - 'county_no' => '103' |
|
16 | - ]); |
|
10 | + public function testFromArray() |
|
11 | + { |
|
12 | + $rapidAddressSearch = RapidAddressSearchResponse::fromArray([ |
|
13 | + 'zipcode' => '00601', |
|
14 | + 'street_name' => 'GENERAL DELIVERY', |
|
15 | + 'county_no' => '103' |
|
16 | + ]); |
|
17 | 17 | |
18 | - $this->assertEquals('00601', $rapidAddressSearch->zipcode); |
|
19 | - $this->assertEquals('GENERAL DELIVERY', $rapidAddressSearch->street_name); |
|
20 | - $this->assertEquals('103', $rapidAddressSearch->county_no); |
|
21 | - } |
|
18 | + $this->assertEquals('00601', $rapidAddressSearch->zipcode); |
|
19 | + $this->assertEquals('GENERAL DELIVERY', $rapidAddressSearch->street_name); |
|
20 | + $this->assertEquals('103', $rapidAddressSearch->county_no); |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -27,391 +27,391 @@ |
||
27 | 27 | |
28 | 28 | class RouteTests extends \PHPUnit\Framework\TestCase |
29 | 29 | { |
30 | - public static $createdProblems = []; |
|
31 | - public static $testRoutes = []; |
|
32 | - public static $addresses = []; |
|
33 | - |
|
34 | - public static $removedOptimizationIDs = []; |
|
35 | - public static $removedRouteIDs = []; |
|
36 | - |
|
37 | - public static function setUpBeforeClass() |
|
38 | - { |
|
39 | - Route4Me::setApiKey(Constants::API_KEY); |
|
40 | - |
|
41 | - //region -- Prepae Addresses -- |
|
42 | - $json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses_md_tw.json'), true); |
|
43 | - |
|
44 | - $addresses = []; |
|
45 | - foreach ($json as $address) { |
|
46 | - $addresses[] = Address::fromArray($address); |
|
47 | - } |
|
48 | - |
|
49 | - $parameters = RouteParameters::fromArray([ |
|
50 | - 'algorithm_type' => AlgorithmType::CVRP_TW_MD, |
|
51 | - 'distance_unit' => DistanceUnit::MILES, |
|
52 | - 'device_type' => DeviceType::WEB, |
|
53 | - 'optimize' => OptimizationType::DISTANCE, |
|
54 | - 'metric' => Metric::GEODESIC, |
|
55 | - 'route_max_duration' => 86400 * 2, |
|
56 | - 'travel_mode' => TravelMode::DRIVING, |
|
57 | - 'vehicle_capacity' => 50, |
|
58 | - 'vehicle_max_distance_mi' => 10000, |
|
59 | - 'parts' => 50, |
|
60 | - ]); |
|
61 | - //endregion |
|
62 | - |
|
63 | - $optimizationParameters = new OptimizationProblemParams(); |
|
64 | - $optimizationParameters->setAddresses($addresses); |
|
65 | - $optimizationParameters->setParameters($parameters); |
|
66 | - |
|
67 | - self::$createdProblems[] = OptimizationProblem::optimize($optimizationParameters); |
|
68 | - |
|
69 | - self::$testRoutes = self::$createdProblems[0]->routes; |
|
70 | - |
|
71 | - //region -- Extra Testing Addresses -- |
|
72 | - $addresses = []; |
|
73 | - $addresses[] = Address::fromArray([ |
|
74 | - 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
75 | - 'is_depot' => true, |
|
76 | - 'lat' => 30.159341812134, |
|
77 | - 'lng' => -81.538619995117, |
|
78 | - 'time' => 300, |
|
79 | - 'time_window_start' => 28800, |
|
80 | - 'time_window_end' => 32400, |
|
81 | - ]); |
|
82 | - |
|
83 | - $addresses[] = Address::fromArray([ |
|
84 | - 'address' => '214 Edgewater Branch Drive 32259', |
|
85 | - 'lat' => 30.103567123413, |
|
86 | - 'lng' => -81.595352172852, |
|
87 | - 'time' => 300, |
|
88 | - 'time_window_start' => 36000, |
|
89 | - 'time_window_end' => 37200, |
|
90 | - ]); |
|
91 | - |
|
92 | - $addresses[] = Address::fromArray([ |
|
93 | - 'address' => '756 eagle point dr 32092', |
|
94 | - 'lat' => 30.046422958374, |
|
95 | - 'lng' => -81.508758544922, |
|
96 | - 'time' => 300, |
|
97 | - 'time_window_start' => 39600, |
|
98 | - 'time_window_end' => 41400, |
|
99 | - ]); |
|
100 | - //endregion |
|
101 | - |
|
102 | - self::$addresses = $addresses; |
|
103 | - } |
|
104 | - |
|
105 | - public function testFromArray() |
|
106 | - { |
|
107 | - //region -- Prepare Addresses -- |
|
108 | - |
|
109 | - $addresses = []; |
|
110 | - $addresses[] = [ |
|
111 | - 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
112 | - 'is_depot' => true, |
|
113 | - 'lat' => 30.159341812134, |
|
114 | - 'lng' => -81.538619995117, |
|
115 | - 'time' => 300, |
|
116 | - 'time_window_start' => 28800, |
|
117 | - 'time_window_end' => 32400, |
|
118 | - ]; |
|
119 | - |
|
120 | - $addresses[] = [ |
|
121 | - 'address' => '214 Edgewater Branch Drive 32259', |
|
122 | - 'lat' => 30.103567123413, |
|
123 | - 'lng' => -81.595352172852, |
|
124 | - 'time' => 300, |
|
125 | - 'time_window_start' => 36000, |
|
126 | - 'time_window_end' => 37200, |
|
127 | - ]; |
|
128 | - |
|
129 | - $addresses[] = [ |
|
130 | - 'address' => '756 eagle point dr 32092', |
|
131 | - 'lat' => 30.046422958374, |
|
132 | - 'lng' => -81.508758544922, |
|
133 | - 'time' => 300, |
|
134 | - 'time_window_start' => 39600, |
|
135 | - 'time_window_end' => 41400, |
|
136 | - ]; |
|
137 | - |
|
138 | - $addresses[] = [ |
|
139 | - 'address' => '63 Stone Creek Cir St Johns, FL 32259, USA', |
|
140 | - 'lat' => 30.048496, |
|
141 | - 'lng' => -81.558716, |
|
142 | - 'time' => 300, |
|
143 | - 'time_window_start' => 43200, |
|
144 | - 'time_window_end' => 45000, |
|
145 | - ]; |
|
146 | - |
|
147 | - $addresses[] = [ |
|
148 | - 'address' => 'St Johns Florida 32259, USA', |
|
149 | - 'lat' => 30.099642, |
|
150 | - 'lng' => -81.547201, |
|
151 | - 'time' => 300, |
|
152 | - 'time_window_start' => 46800, |
|
153 | - 'time_window_end' => 48600, |
|
154 | - ]; |
|
155 | - |
|
156 | - //endregion |
|
157 | - |
|
158 | - $parameters = [ |
|
159 | - 'device_type' => DeviceType::IPAD, |
|
160 | - 'disable_optimization' => false, |
|
161 | - 'route_name' => 'phpunit test '.date('Y-m-d H:i'), |
|
162 | - ]; |
|
163 | - |
|
164 | - $routeParameters = Route::fromArray([ |
|
165 | - 'parameters' => $parameters, |
|
166 | - 'addresses' => $addresses |
|
167 | - ]); |
|
168 | - |
|
169 | - $this->assertEquals(RouteParameters::fromArray($parameters), $routeParameters->parameters); |
|
170 | - } |
|
171 | - |
|
172 | - public function testGetRoutes() |
|
173 | - { |
|
174 | - $params = new RouteParametersQuery(); |
|
175 | - |
|
176 | - $params->limit = 10; |
|
177 | - $params->offset = 0; |
|
178 | - |
|
179 | - $route = new Route(); |
|
180 | - |
|
181 | - $routeResults = $route->getRoutes($params->toArray()); |
|
182 | - |
|
183 | - $this->assertNotNull($routeResults); |
|
184 | - $this->assertTrue(is_array($routeResults)); |
|
185 | - $this->assertTrue(sizeof($routeResults)>0); |
|
186 | - $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
187 | - } |
|
188 | - |
|
189 | - public function testGetAllRoutesWithPagination() |
|
190 | - { |
|
191 | - $params = new RouteParametersQuery(); |
|
192 | - |
|
193 | - $params->page = 1; |
|
194 | - $params->per_page = 10; |
|
195 | - |
|
196 | - $route = new Route(); |
|
197 | - |
|
198 | - $routeResults = $route->getAllRoutesWithPagination($params->toArray()); |
|
199 | - |
|
200 | - $this->assertNotNull($routeResults); |
|
201 | - $this->assertTrue(is_array($routeResults)); |
|
202 | - $this->assertTrue(sizeof($routeResults)>0); |
|
203 | - $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
204 | - } |
|
205 | - |
|
206 | - public function testGetPaginatedRouteListWithoutElasticSearch() |
|
207 | - { |
|
208 | - $params = new RouteParametersQuery(); |
|
209 | - |
|
210 | - $params->page = 1; |
|
211 | - $params->per_page = 10; |
|
212 | - |
|
213 | - $route = new Route(); |
|
214 | - |
|
215 | - $routeResults = $route->getPaginatedRouteListWithoutElasticSearch($params->toArray()); |
|
216 | - |
|
217 | - $this->assertNotNull($routeResults); |
|
218 | - $this->assertTrue(is_array($routeResults)); |
|
219 | - $this->assertTrue(sizeof($routeResults)>0); |
|
220 | - $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
221 | - } |
|
222 | - |
|
223 | - public function testGetRouteDataTableWithoutElasticSearch() |
|
224 | - { |
|
225 | - $scheduleFilter = new RouteFilterParametersFilters(); |
|
226 | - |
|
227 | - $scheduleFilter->schedule_date = [ |
|
228 | - date('Y-m-d', strtotime('-2 days')), |
|
229 | - date('Y-m-d', strtotime('-3 days')), |
|
230 | - date('Y-m-d', strtotime('-4 days')) |
|
231 | - ]; |
|
232 | - |
|
233 | - $filterParams = new RouteFilterParameters(); |
|
234 | - $filterParams->page = 1; |
|
235 | - $filterParams->per_page = 20; |
|
236 | - $filterParams->filters = $scheduleFilter; |
|
237 | - $filterParams->order_by = [["route_created_unix", "desc"]]; |
|
238 | - $filterParams->timezone = "UTC"; |
|
239 | - |
|
240 | - $route = new Route(); |
|
30 | + public static $createdProblems = []; |
|
31 | + public static $testRoutes = []; |
|
32 | + public static $addresses = []; |
|
33 | + |
|
34 | + public static $removedOptimizationIDs = []; |
|
35 | + public static $removedRouteIDs = []; |
|
36 | + |
|
37 | + public static function setUpBeforeClass() |
|
38 | + { |
|
39 | + Route4Me::setApiKey(Constants::API_KEY); |
|
40 | + |
|
41 | + //region -- Prepae Addresses -- |
|
42 | + $json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses_md_tw.json'), true); |
|
43 | + |
|
44 | + $addresses = []; |
|
45 | + foreach ($json as $address) { |
|
46 | + $addresses[] = Address::fromArray($address); |
|
47 | + } |
|
48 | + |
|
49 | + $parameters = RouteParameters::fromArray([ |
|
50 | + 'algorithm_type' => AlgorithmType::CVRP_TW_MD, |
|
51 | + 'distance_unit' => DistanceUnit::MILES, |
|
52 | + 'device_type' => DeviceType::WEB, |
|
53 | + 'optimize' => OptimizationType::DISTANCE, |
|
54 | + 'metric' => Metric::GEODESIC, |
|
55 | + 'route_max_duration' => 86400 * 2, |
|
56 | + 'travel_mode' => TravelMode::DRIVING, |
|
57 | + 'vehicle_capacity' => 50, |
|
58 | + 'vehicle_max_distance_mi' => 10000, |
|
59 | + 'parts' => 50, |
|
60 | + ]); |
|
61 | + //endregion |
|
62 | + |
|
63 | + $optimizationParameters = new OptimizationProblemParams(); |
|
64 | + $optimizationParameters->setAddresses($addresses); |
|
65 | + $optimizationParameters->setParameters($parameters); |
|
66 | + |
|
67 | + self::$createdProblems[] = OptimizationProblem::optimize($optimizationParameters); |
|
68 | + |
|
69 | + self::$testRoutes = self::$createdProblems[0]->routes; |
|
70 | + |
|
71 | + //region -- Extra Testing Addresses -- |
|
72 | + $addresses = []; |
|
73 | + $addresses[] = Address::fromArray([ |
|
74 | + 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
75 | + 'is_depot' => true, |
|
76 | + 'lat' => 30.159341812134, |
|
77 | + 'lng' => -81.538619995117, |
|
78 | + 'time' => 300, |
|
79 | + 'time_window_start' => 28800, |
|
80 | + 'time_window_end' => 32400, |
|
81 | + ]); |
|
82 | + |
|
83 | + $addresses[] = Address::fromArray([ |
|
84 | + 'address' => '214 Edgewater Branch Drive 32259', |
|
85 | + 'lat' => 30.103567123413, |
|
86 | + 'lng' => -81.595352172852, |
|
87 | + 'time' => 300, |
|
88 | + 'time_window_start' => 36000, |
|
89 | + 'time_window_end' => 37200, |
|
90 | + ]); |
|
91 | + |
|
92 | + $addresses[] = Address::fromArray([ |
|
93 | + 'address' => '756 eagle point dr 32092', |
|
94 | + 'lat' => 30.046422958374, |
|
95 | + 'lng' => -81.508758544922, |
|
96 | + 'time' => 300, |
|
97 | + 'time_window_start' => 39600, |
|
98 | + 'time_window_end' => 41400, |
|
99 | + ]); |
|
100 | + //endregion |
|
101 | + |
|
102 | + self::$addresses = $addresses; |
|
103 | + } |
|
104 | + |
|
105 | + public function testFromArray() |
|
106 | + { |
|
107 | + //region -- Prepare Addresses -- |
|
108 | + |
|
109 | + $addresses = []; |
|
110 | + $addresses[] = [ |
|
111 | + 'address' => '11497 Columbia Park Dr W, Jacksonville, FL 32258', |
|
112 | + 'is_depot' => true, |
|
113 | + 'lat' => 30.159341812134, |
|
114 | + 'lng' => -81.538619995117, |
|
115 | + 'time' => 300, |
|
116 | + 'time_window_start' => 28800, |
|
117 | + 'time_window_end' => 32400, |
|
118 | + ]; |
|
119 | + |
|
120 | + $addresses[] = [ |
|
121 | + 'address' => '214 Edgewater Branch Drive 32259', |
|
122 | + 'lat' => 30.103567123413, |
|
123 | + 'lng' => -81.595352172852, |
|
124 | + 'time' => 300, |
|
125 | + 'time_window_start' => 36000, |
|
126 | + 'time_window_end' => 37200, |
|
127 | + ]; |
|
128 | + |
|
129 | + $addresses[] = [ |
|
130 | + 'address' => '756 eagle point dr 32092', |
|
131 | + 'lat' => 30.046422958374, |
|
132 | + 'lng' => -81.508758544922, |
|
133 | + 'time' => 300, |
|
134 | + 'time_window_start' => 39600, |
|
135 | + 'time_window_end' => 41400, |
|
136 | + ]; |
|
137 | + |
|
138 | + $addresses[] = [ |
|
139 | + 'address' => '63 Stone Creek Cir St Johns, FL 32259, USA', |
|
140 | + 'lat' => 30.048496, |
|
141 | + 'lng' => -81.558716, |
|
142 | + 'time' => 300, |
|
143 | + 'time_window_start' => 43200, |
|
144 | + 'time_window_end' => 45000, |
|
145 | + ]; |
|
146 | + |
|
147 | + $addresses[] = [ |
|
148 | + 'address' => 'St Johns Florida 32259, USA', |
|
149 | + 'lat' => 30.099642, |
|
150 | + 'lng' => -81.547201, |
|
151 | + 'time' => 300, |
|
152 | + 'time_window_start' => 46800, |
|
153 | + 'time_window_end' => 48600, |
|
154 | + ]; |
|
155 | + |
|
156 | + //endregion |
|
157 | + |
|
158 | + $parameters = [ |
|
159 | + 'device_type' => DeviceType::IPAD, |
|
160 | + 'disable_optimization' => false, |
|
161 | + 'route_name' => 'phpunit test '.date('Y-m-d H:i'), |
|
162 | + ]; |
|
163 | + |
|
164 | + $routeParameters = Route::fromArray([ |
|
165 | + 'parameters' => $parameters, |
|
166 | + 'addresses' => $addresses |
|
167 | + ]); |
|
168 | + |
|
169 | + $this->assertEquals(RouteParameters::fromArray($parameters), $routeParameters->parameters); |
|
170 | + } |
|
171 | + |
|
172 | + public function testGetRoutes() |
|
173 | + { |
|
174 | + $params = new RouteParametersQuery(); |
|
175 | + |
|
176 | + $params->limit = 10; |
|
177 | + $params->offset = 0; |
|
178 | + |
|
179 | + $route = new Route(); |
|
180 | + |
|
181 | + $routeResults = $route->getRoutes($params->toArray()); |
|
182 | + |
|
183 | + $this->assertNotNull($routeResults); |
|
184 | + $this->assertTrue(is_array($routeResults)); |
|
185 | + $this->assertTrue(sizeof($routeResults)>0); |
|
186 | + $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
187 | + } |
|
188 | + |
|
189 | + public function testGetAllRoutesWithPagination() |
|
190 | + { |
|
191 | + $params = new RouteParametersQuery(); |
|
192 | + |
|
193 | + $params->page = 1; |
|
194 | + $params->per_page = 10; |
|
195 | + |
|
196 | + $route = new Route(); |
|
197 | + |
|
198 | + $routeResults = $route->getAllRoutesWithPagination($params->toArray()); |
|
199 | + |
|
200 | + $this->assertNotNull($routeResults); |
|
201 | + $this->assertTrue(is_array($routeResults)); |
|
202 | + $this->assertTrue(sizeof($routeResults)>0); |
|
203 | + $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
204 | + } |
|
205 | + |
|
206 | + public function testGetPaginatedRouteListWithoutElasticSearch() |
|
207 | + { |
|
208 | + $params = new RouteParametersQuery(); |
|
209 | + |
|
210 | + $params->page = 1; |
|
211 | + $params->per_page = 10; |
|
212 | + |
|
213 | + $route = new Route(); |
|
214 | + |
|
215 | + $routeResults = $route->getPaginatedRouteListWithoutElasticSearch($params->toArray()); |
|
216 | + |
|
217 | + $this->assertNotNull($routeResults); |
|
218 | + $this->assertTrue(is_array($routeResults)); |
|
219 | + $this->assertTrue(sizeof($routeResults)>0); |
|
220 | + $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
221 | + } |
|
222 | + |
|
223 | + public function testGetRouteDataTableWithoutElasticSearch() |
|
224 | + { |
|
225 | + $scheduleFilter = new RouteFilterParametersFilters(); |
|
226 | + |
|
227 | + $scheduleFilter->schedule_date = [ |
|
228 | + date('Y-m-d', strtotime('-2 days')), |
|
229 | + date('Y-m-d', strtotime('-3 days')), |
|
230 | + date('Y-m-d', strtotime('-4 days')) |
|
231 | + ]; |
|
232 | + |
|
233 | + $filterParams = new RouteFilterParameters(); |
|
234 | + $filterParams->page = 1; |
|
235 | + $filterParams->per_page = 20; |
|
236 | + $filterParams->filters = $scheduleFilter; |
|
237 | + $filterParams->order_by = [["route_created_unix", "desc"]]; |
|
238 | + $filterParams->timezone = "UTC"; |
|
239 | + |
|
240 | + $route = new Route(); |
|
241 | 241 | |
242 | - $routeResults = $route->getRouteDataTableWithoutElasticSearch($filterParams->toArray()); |
|
242 | + $routeResults = $route->getRouteDataTableWithoutElasticSearch($filterParams->toArray()); |
|
243 | 243 | |
244 | - $this->assertNotNull($routeResults); |
|
245 | - $this->assertTrue(is_array($routeResults)); |
|
246 | - $this->assertTrue(sizeof($routeResults)>0); |
|
247 | - $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
248 | - } |
|
244 | + $this->assertNotNull($routeResults); |
|
245 | + $this->assertTrue(is_array($routeResults)); |
|
246 | + $this->assertTrue(sizeof($routeResults)>0); |
|
247 | + $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
248 | + } |
|
249 | 249 | |
250 | - public function testGetRouteDatatableWithElasticSearch() |
|
251 | - { |
|
252 | - $scheduleFilter = new RouteFilterParametersFilters(); |
|
250 | + public function testGetRouteDatatableWithElasticSearch() |
|
251 | + { |
|
252 | + $scheduleFilter = new RouteFilterParametersFilters(); |
|
253 | 253 | |
254 | - $scheduleFilter->schedule_date = [ |
|
255 | - date('Y-m-d', strtotime('-1 days')), |
|
256 | - date('Y-m-d', strtotime('-2 days')), |
|
257 | - date('Y-m-d', strtotime('-3 days')) |
|
258 | - ]; |
|
254 | + $scheduleFilter->schedule_date = [ |
|
255 | + date('Y-m-d', strtotime('-1 days')), |
|
256 | + date('Y-m-d', strtotime('-2 days')), |
|
257 | + date('Y-m-d', strtotime('-3 days')) |
|
258 | + ]; |
|
259 | 259 | |
260 | - $filterParams = new RouteFilterParameters(); |
|
261 | - $filterParams->page = 1; |
|
262 | - $filterParams->per_page = 20; |
|
263 | - $filterParams->filters = $scheduleFilter; |
|
264 | - $filterParams->order_by = [["route_created_unix", "desc"]]; |
|
265 | - $filterParams->timezone = "UTC"; |
|
260 | + $filterParams = new RouteFilterParameters(); |
|
261 | + $filterParams->page = 1; |
|
262 | + $filterParams->per_page = 20; |
|
263 | + $filterParams->filters = $scheduleFilter; |
|
264 | + $filterParams->order_by = [["route_created_unix", "desc"]]; |
|
265 | + $filterParams->timezone = "UTC"; |
|
266 | 266 | |
267 | - $route = new Route(); |
|
267 | + $route = new Route(); |
|
268 | 268 | |
269 | - $routeResults = $route->getRouteDataTableWithElasticSearch($filterParams->toArray()); |
|
269 | + $routeResults = $route->getRouteDataTableWithElasticSearch($filterParams->toArray()); |
|
270 | 270 | |
271 | - $this->assertNotNull($routeResults); |
|
272 | - $this->assertTrue(is_array($routeResults)); |
|
273 | - $this->assertTrue(sizeof($routeResults)>0); |
|
274 | - $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
275 | - } |
|
271 | + $this->assertNotNull($routeResults); |
|
272 | + $this->assertTrue(is_array($routeResults)); |
|
273 | + $this->assertTrue(sizeof($routeResults)>0); |
|
274 | + $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
275 | + } |
|
276 | 276 | |
277 | - public function testGetRouteListWithoutElasticSearch() |
|
278 | - { |
|
279 | - $params = new RouteParametersQuery(); |
|
277 | + public function testGetRouteListWithoutElasticSearch() |
|
278 | + { |
|
279 | + $params = new RouteParametersQuery(); |
|
280 | 280 | |
281 | - $params->limit = 10; |
|
282 | - $params->offset = 0; |
|
281 | + $params->limit = 10; |
|
282 | + $params->offset = 0; |
|
283 | 283 | |
284 | - $route = new Route(); |
|
284 | + $route = new Route(); |
|
285 | 285 | |
286 | - $routeResults = $route->getRouteListWithoutElasticSearch($params->toArray()); |
|
286 | + $routeResults = $route->getRouteListWithoutElasticSearch($params->toArray()); |
|
287 | 287 | |
288 | - $this->assertNotNull($routeResults); |
|
289 | - $this->assertTrue(is_array($routeResults)); |
|
290 | - $this->assertTrue(sizeof($routeResults)>0); |
|
291 | - $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
292 | - } |
|
288 | + $this->assertNotNull($routeResults); |
|
289 | + $this->assertTrue(is_array($routeResults)); |
|
290 | + $this->assertTrue(sizeof($routeResults)>0); |
|
291 | + $this->assertInstanceOf(Route::class, Route::fromArray($routeResults)); |
|
292 | + } |
|
293 | 293 | |
294 | - public function testDuplicateRoutes() |
|
295 | - { |
|
296 | - $routeIDs = [ |
|
297 | - self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id |
|
298 | - ]; |
|
294 | + public function testDuplicateRoutes() |
|
295 | + { |
|
296 | + $routeIDs = [ |
|
297 | + self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id |
|
298 | + ]; |
|
299 | 299 | |
300 | - $route = new Route(); |
|
300 | + $route = new Route(); |
|
301 | 301 | |
302 | - $result = $route->duplicateRoute($routeIDs); |
|
302 | + $result = $route->duplicateRoute($routeIDs); |
|
303 | 303 | |
304 | - $this->assertNotNull($result); |
|
305 | - $this->assertInstanceOf(RouteDuplicateResponse::class, RouteDuplicateResponse::fromArray( $result)); |
|
306 | - $this->assertTrue($result['status']); |
|
307 | - } |
|
304 | + $this->assertNotNull($result); |
|
305 | + $this->assertInstanceOf(RouteDuplicateResponse::class, RouteDuplicateResponse::fromArray( $result)); |
|
306 | + $this->assertTrue($result['status']); |
|
307 | + } |
|
308 | 308 | |
309 | - public function testGetRouteDataTableConfig() |
|
310 | - { |
|
311 | - $route = new Route(); |
|
309 | + public function testGetRouteDataTableConfig() |
|
310 | + { |
|
311 | + $route = new Route(); |
|
312 | 312 | |
313 | - $result = $route->getRouteDataTableConfig(); |
|
313 | + $result = $route->getRouteDataTableConfig(); |
|
314 | 314 | |
315 | - $this->assertNotNull($result); |
|
316 | - $this->assertInstanceOf( RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray( $result)); |
|
317 | - $this->assertInstanceOf( ApiCapabilities::class, ApiCapabilities::fromArray( $result['api_capabilities'])); |
|
318 | - $this->assertInstanceOf( ApiPreferences::class, ApiPreferences::fromArray( $result['api_preferences'])); |
|
319 | - } |
|
315 | + $this->assertNotNull($result); |
|
316 | + $this->assertInstanceOf( RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray( $result)); |
|
317 | + $this->assertInstanceOf( ApiCapabilities::class, ApiCapabilities::fromArray( $result['api_capabilities'])); |
|
318 | + $this->assertInstanceOf( ApiPreferences::class, ApiPreferences::fromArray( $result['api_preferences'])); |
|
319 | + } |
|
320 | 320 | |
321 | - public function testRouteDataTableFallbackConfig() |
|
322 | - { |
|
323 | - $route = new Route(); |
|
321 | + public function testRouteDataTableFallbackConfig() |
|
322 | + { |
|
323 | + $route = new Route(); |
|
324 | 324 | |
325 | - $result = $route->getRouteDataTableFallbackConfig(); |
|
325 | + $result = $route->getRouteDataTableFallbackConfig(); |
|
326 | 326 | |
327 | - $this->assertNotNull($result); |
|
328 | - $this->assertInstanceOf( RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray( $result)); |
|
329 | - $this->assertInstanceOf( ApiCapabilities::class, ApiCapabilities::fromArray( $result['api_capabilities'])); |
|
330 | - $this->assertInstanceOf( ApiPreferences::class, ApiPreferences::fromArray( $result['api_preferences'])); |
|
331 | - } |
|
327 | + $this->assertNotNull($result); |
|
328 | + $this->assertInstanceOf( RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray( $result)); |
|
329 | + $this->assertInstanceOf( ApiCapabilities::class, ApiCapabilities::fromArray( $result['api_capabilities'])); |
|
330 | + $this->assertInstanceOf( ApiPreferences::class, ApiPreferences::fromArray( $result['api_preferences'])); |
|
331 | + } |
|
332 | 332 | |
333 | - public function testUpdateRouteParameters() |
|
334 | - { |
|
335 | - $routeQueryParams= new RouteParametersQuery(); |
|
336 | - $routeQueryParams->route_id = self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id; |
|
337 | - $routeQueryParams->original = 0; |
|
333 | + public function testUpdateRouteParameters() |
|
334 | + { |
|
335 | + $routeQueryParams= new RouteParametersQuery(); |
|
336 | + $routeQueryParams->route_id = self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id; |
|
337 | + $routeQueryParams->original = 0; |
|
338 | 338 | |
339 | - $routeParams = new RouteParameters(); |
|
339 | + $routeParams = new RouteParameters(); |
|
340 | 340 | |
341 | - $routeParams->disable_optimization = false; |
|
342 | - $routeParams->vehicle_capacity = 9800; |
|
343 | - $routeParams->target_duration = 0; |
|
344 | - $routeParams->target_distance = 100; |
|
345 | - $routeParams->target_wait_by_tail_size = 0; |
|
341 | + $routeParams->disable_optimization = false; |
|
342 | + $routeParams->vehicle_capacity = 9800; |
|
343 | + $routeParams->target_duration = 0; |
|
344 | + $routeParams->target_distance = 100; |
|
345 | + $routeParams->target_wait_by_tail_size = 0; |
|
346 | 346 | |
347 | - $route = new Route(); |
|
347 | + $route = new Route(); |
|
348 | 348 | |
349 | - $result = $route->updateRouteParameters($routeQueryParams->toArray(), $routeParams->toArray()); |
|
349 | + $result = $route->updateRouteParameters($routeQueryParams->toArray(), $routeParams->toArray()); |
|
350 | 350 | |
351 | - $this->assertNotNull($result); |
|
352 | - $this->assertInstanceOf( Route::class, Route::fromArray( $result)); |
|
353 | - } |
|
351 | + $this->assertNotNull($result); |
|
352 | + $this->assertInstanceOf( Route::class, Route::fromArray( $result)); |
|
353 | + } |
|
354 | 354 | |
355 | - public function testDeleteRoutes() |
|
356 | - { |
|
357 | - $routeToDeleteID = self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id; |
|
355 | + public function testDeleteRoutes() |
|
356 | + { |
|
357 | + $routeToDeleteID = self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id; |
|
358 | 358 | |
359 | - $routeIDs = [ $routeToDeleteID ]; |
|
359 | + $routeIDs = [ $routeToDeleteID ]; |
|
360 | 360 | |
361 | - $route = new Route(); |
|
361 | + $route = new Route(); |
|
362 | 362 | |
363 | - $result = $route->deleteRoutes($routeIDs); |
|
363 | + $result = $route->deleteRoutes($routeIDs); |
|
364 | 364 | |
365 | - $this->assertNotNull($result); |
|
366 | - $this->assertInstanceOf(RoutesDeleteResponse::class, RoutesDeleteResponse::fromArray( $result)); |
|
367 | - $this->assertTrue($result['deleted']); |
|
365 | + $this->assertNotNull($result); |
|
366 | + $this->assertInstanceOf(RoutesDeleteResponse::class, RoutesDeleteResponse::fromArray( $result)); |
|
367 | + $this->assertTrue($result['deleted']); |
|
368 | 368 | |
369 | - self::$testRoutes = array_pop(self::$testRoutes); |
|
370 | - } |
|
369 | + self::$testRoutes = array_pop(self::$testRoutes); |
|
370 | + } |
|
371 | 371 | |
372 | - public static function tearDownAfterClass() |
|
373 | - { |
|
374 | - if (sizeof(self::$createdProblems)>0) { |
|
375 | - $optimizationProblemIDs = []; |
|
372 | + public static function tearDownAfterClass() |
|
373 | + { |
|
374 | + if (sizeof(self::$createdProblems)>0) { |
|
375 | + $optimizationProblemIDs = []; |
|
376 | 376 | |
377 | - foreach (self::$createdProblems as $problem) { |
|
378 | - $optimizationProblemId = $problem->optimization_problem_id; |
|
377 | + foreach (self::$createdProblems as $problem) { |
|
378 | + $optimizationProblemId = $problem->optimization_problem_id; |
|
379 | 379 | |
380 | - $optimizationProblemIDs[] = $optimizationProblemId; |
|
381 | - } |
|
380 | + $optimizationProblemIDs[] = $optimizationProblemId; |
|
381 | + } |
|
382 | 382 | |
383 | - if (sizeof(self::$removedOptimizationIDs)>0) { |
|
384 | - $optimizationProblemIDs = array_merge($optimizationProblemIDs,self::$removedOptimizationIDs); |
|
385 | - } |
|
383 | + if (sizeof(self::$removedOptimizationIDs)>0) { |
|
384 | + $optimizationProblemIDs = array_merge($optimizationProblemIDs,self::$removedOptimizationIDs); |
|
385 | + } |
|
386 | 386 | |
387 | - $params = [ |
|
388 | - 'optimization_problem_ids' => $optimizationProblemIDs, |
|
389 | - 'redirect' => 0, |
|
390 | - ]; |
|
387 | + $params = [ |
|
388 | + 'optimization_problem_ids' => $optimizationProblemIDs, |
|
389 | + 'redirect' => 0, |
|
390 | + ]; |
|
391 | 391 | |
392 | - $problem = new OptimizationProblem(); |
|
393 | - $result = $problem->removeOptimization($params); |
|
392 | + $problem = new OptimizationProblem(); |
|
393 | + $result = $problem->removeOptimization($params); |
|
394 | 394 | |
395 | - if ($result!=null && $result['status']==true) { |
|
396 | - echo "The test optimizations were removed <br>"; |
|
397 | - } else { |
|
398 | - echo "Cannot remove the test optimizations <br>"; |
|
399 | - } |
|
400 | - } |
|
395 | + if ($result!=null && $result['status']==true) { |
|
396 | + echo "The test optimizations were removed <br>"; |
|
397 | + } else { |
|
398 | + echo "Cannot remove the test optimizations <br>"; |
|
399 | + } |
|
400 | + } |
|
401 | 401 | |
402 | - if (sizeof(self::$removedRouteIDs)>0) { |
|
403 | - $route = new Route(); |
|
402 | + if (sizeof(self::$removedRouteIDs)>0) { |
|
403 | + $route = new Route(); |
|
404 | 404 | |
405 | - $route_ids = join(',', self::$removedRouteIDs); |
|
405 | + $route_ids = join(',', self::$removedRouteIDs); |
|
406 | 406 | |
407 | - $result = $route->deleteRoutes($route_ids); |
|
407 | + $result = $route->deleteRoutes($route_ids); |
|
408 | 408 | |
409 | - if ($result!=null && $result['deleted']==true) { |
|
410 | - echo "The test routes were removed <br>"; |
|
411 | - } else { |
|
412 | - echo "Cannot remove the test routes <br>"; |
|
413 | - } |
|
414 | - } |
|
415 | - } |
|
409 | + if ($result!=null && $result['deleted']==true) { |
|
410 | + echo "The test routes were removed <br>"; |
|
411 | + } else { |
|
412 | + echo "Cannot remove the test routes <br>"; |
|
413 | + } |
|
414 | + } |
|
415 | + } |
|
416 | 416 | |
417 | 417 | } |
418 | 418 | \ No newline at end of file |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $result = $route->duplicateRoute($routeIDs); |
303 | 303 | |
304 | 304 | $this->assertNotNull($result); |
305 | - $this->assertInstanceOf(RouteDuplicateResponse::class, RouteDuplicateResponse::fromArray( $result)); |
|
305 | + $this->assertInstanceOf(RouteDuplicateResponse::class, RouteDuplicateResponse::fromArray($result)); |
|
306 | 306 | $this->assertTrue($result['status']); |
307 | 307 | } |
308 | 308 | |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | $result = $route->getRouteDataTableConfig(); |
314 | 314 | |
315 | 315 | $this->assertNotNull($result); |
316 | - $this->assertInstanceOf( RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray( $result)); |
|
317 | - $this->assertInstanceOf( ApiCapabilities::class, ApiCapabilities::fromArray( $result['api_capabilities'])); |
|
318 | - $this->assertInstanceOf( ApiPreferences::class, ApiPreferences::fromArray( $result['api_preferences'])); |
|
316 | + $this->assertInstanceOf(RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray($result)); |
|
317 | + $this->assertInstanceOf(ApiCapabilities::class, ApiCapabilities::fromArray($result['api_capabilities'])); |
|
318 | + $this->assertInstanceOf(ApiPreferences::class, ApiPreferences::fromArray($result['api_preferences'])); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | public function testRouteDataTableFallbackConfig() |
@@ -325,14 +325,14 @@ discard block |
||
325 | 325 | $result = $route->getRouteDataTableFallbackConfig(); |
326 | 326 | |
327 | 327 | $this->assertNotNull($result); |
328 | - $this->assertInstanceOf( RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray( $result)); |
|
329 | - $this->assertInstanceOf( ApiCapabilities::class, ApiCapabilities::fromArray( $result['api_capabilities'])); |
|
330 | - $this->assertInstanceOf( ApiPreferences::class, ApiPreferences::fromArray( $result['api_preferences'])); |
|
328 | + $this->assertInstanceOf(RouteDataTableConfigResponse::class, RouteDataTableConfigResponse::fromArray($result)); |
|
329 | + $this->assertInstanceOf(ApiCapabilities::class, ApiCapabilities::fromArray($result['api_capabilities'])); |
|
330 | + $this->assertInstanceOf(ApiPreferences::class, ApiPreferences::fromArray($result['api_preferences'])); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | public function testUpdateRouteParameters() |
334 | 334 | { |
335 | - $routeQueryParams= new RouteParametersQuery(); |
|
335 | + $routeQueryParams = new RouteParametersQuery(); |
|
336 | 336 | $routeQueryParams->route_id = self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id; |
337 | 337 | $routeQueryParams->original = 0; |
338 | 338 | |
@@ -349,21 +349,21 @@ discard block |
||
349 | 349 | $result = $route->updateRouteParameters($routeQueryParams->toArray(), $routeParams->toArray()); |
350 | 350 | |
351 | 351 | $this->assertNotNull($result); |
352 | - $this->assertInstanceOf( Route::class, Route::fromArray( $result)); |
|
352 | + $this->assertInstanceOf(Route::class, Route::fromArray($result)); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | public function testDeleteRoutes() |
356 | 356 | { |
357 | 357 | $routeToDeleteID = self::$testRoutes[sizeof(self::$testRoutes) - 1]->route_id; |
358 | 358 | |
359 | - $routeIDs = [ $routeToDeleteID ]; |
|
359 | + $routeIDs = [$routeToDeleteID]; |
|
360 | 360 | |
361 | 361 | $route = new Route(); |
362 | 362 | |
363 | 363 | $result = $route->deleteRoutes($routeIDs); |
364 | 364 | |
365 | 365 | $this->assertNotNull($result); |
366 | - $this->assertInstanceOf(RoutesDeleteResponse::class, RoutesDeleteResponse::fromArray( $result)); |
|
366 | + $this->assertInstanceOf(RoutesDeleteResponse::class, RoutesDeleteResponse::fromArray($result)); |
|
367 | 367 | $this->assertTrue($result['deleted']); |
368 | 368 | |
369 | 369 | self::$testRoutes = array_pop(self::$testRoutes); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | if (sizeof(self::$removedOptimizationIDs)>0) { |
384 | - $optimizationProblemIDs = array_merge($optimizationProblemIDs,self::$removedOptimizationIDs); |
|
384 | + $optimizationProblemIDs = array_merge($optimizationProblemIDs, self::$removedOptimizationIDs); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | $params = [ |
@@ -26,541 +26,541 @@ |
||
26 | 26 | |
27 | 27 | class VehicleTests extends TestCase |
28 | 28 | { |
29 | - public static $createdVehicles = []; |
|
30 | - public static $createdVehicleProfiles = []; |
|
31 | - |
|
32 | - public static function setUpBeforeClass() |
|
33 | - { |
|
34 | - Route4Me::setApiKey(Constants::API_KEY); |
|
35 | - |
|
36 | - $vehicle = new Vehicle(); |
|
37 | - |
|
38 | - //region Create Test Vehicles |
|
39 | - |
|
40 | - $class6TruckParams = Vehicle::fromArray([ |
|
41 | - 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
42 | - 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
43 | - 'vehicle_license_plate' => 'CVH4561', |
|
44 | - 'vehicle_model' => 'TopKick C5500', |
|
45 | - 'vehicle_model_year' => 1995, |
|
46 | - 'vehicle_year_acquired' => 2008, |
|
47 | - 'vehicle_reg_country_id' => 223, |
|
48 | - 'vehicle_reg_state_id' => 12, |
|
49 | - 'vehicle_make' => 'GMC', |
|
50 | - 'vehicle_type_id' => 'pickup_truck', |
|
51 | - 'vehicle_cost_new' => 60000, |
|
52 | - 'purchased_new' => true, |
|
53 | - 'mpg_city' => 8, |
|
54 | - 'mpg_highway' => 14, |
|
55 | - 'fuel_type' => 'diesel', |
|
56 | - 'license_start_date' => '2021-01-01', |
|
57 | - 'license_end_date' => '2031-01-01', |
|
58 | - ]); |
|
59 | - |
|
60 | - $result = $vehicle->createVehicle($class6TruckParams); |
|
61 | - |
|
62 | - self::assertNotNull($result); |
|
63 | - self::assertInstanceOf( |
|
64 | - Vehicle::class, |
|
65 | - Vehicle::fromArray($result) |
|
66 | - ); |
|
67 | - |
|
68 | - self::$createdVehicles[] = $result; |
|
69 | - |
|
70 | - |
|
71 | - $class7TruckParams = Vehicle::fromArray([ |
|
72 | - 'vehicle_alias' => 'FORD F750 TST 7', |
|
73 | - 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
74 | - 'vehicle_license_plate' => 'FFV9547', |
|
75 | - 'vehicle_model' => 'F-750', |
|
76 | - 'vehicle_model_year' => 2010, |
|
77 | - 'vehicle_year_acquired' => 2018, |
|
78 | - 'vehicle_reg_country_id' => 223, |
|
79 | - 'vehicle_make' => 'Ford', |
|
80 | - 'vehicle_type_id' => 'livestock_carrier', |
|
81 | - 'vehicle_cost_new' => 60000, |
|
82 | - 'purchased_new' => true, |
|
83 | - 'mpg_city' => 7, |
|
84 | - 'mpg_highway' => 14, |
|
85 | - 'fuel_consumption_city' => 7, |
|
86 | - 'fuel_consumption_highway' => 14, |
|
87 | - 'fuel_type' => 'diesel', |
|
88 | - 'license_start_date' => '2021-01-01', |
|
89 | - 'license_end_date' => '2031-01-01', |
|
90 | - ]); |
|
91 | - |
|
92 | - $result = $vehicle->createVehicle($class7TruckParams); |
|
93 | - |
|
94 | - self::assertNotNull($result); |
|
95 | - self::assertInstanceOf( |
|
96 | - Vehicle::class, |
|
97 | - Vehicle::fromArray($result) |
|
98 | - ); |
|
99 | - |
|
100 | - self::$createdVehicles[] = $result; |
|
101 | - |
|
102 | - //endregion |
|
103 | - |
|
104 | - #region Create Test Vehicle Profiles |
|
105 | - |
|
106 | - $profile1 = new VehicleProfile(); |
|
107 | - |
|
108 | - $profile1->name = "Heavy Duty - 28 Double Trailer ".date('Y-m-d H:i'); |
|
109 | - $profile1->height_units = VehicleSizeUnits::METER; |
|
110 | - $profile1->width_units = VehicleSizeUnits::METER; |
|
111 | - $profile1->length_units = VehicleSizeUnits::METER; |
|
112 | - $profile1->height = 4; |
|
113 | - $profile1->width = 2.44; |
|
114 | - $profile1->length = 12.2; |
|
115 | - $profile1->is_predefined = false; |
|
116 | - $profile1->is_default = false; |
|
117 | - $profile1->weight_units = VehicleWeightUnits::KILOGRAM; |
|
118 | - $profile1->weight = 20400; |
|
119 | - $profile1->max_weight_per_axle = 15400; |
|
120 | - $profile1->fuel_type = FuelTypes::UNLEADED_91; |
|
121 | - $profile1->fuel_consumption_city = 6; |
|
122 | - $profile1->fuel_consumption_highway = 12; |
|
123 | - $profile1->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
124 | - $profile1->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
125 | - |
|
126 | - $result1 = $profile1->createVehicleProfile($profile1->toArray()); |
|
127 | - |
|
128 | - self::assertNotNull($result1); |
|
129 | - self::assertInstanceOf( |
|
130 | - VehicleProfile::class, |
|
131 | - VehicleProfile::fromArray($result1) |
|
132 | - ); |
|
133 | - |
|
134 | - self::$createdVehicleProfiles[] = $result1; |
|
135 | - |
|
136 | - $profile2 = new VehicleProfile(); |
|
137 | - |
|
138 | - $profile2->name = "Heavy Duty - 40 Straight Truck ".date('Y-m-d H:i'); |
|
139 | - $profile2->height_units = VehicleSizeUnits::METER; |
|
140 | - $profile2->width_units = VehicleSizeUnits::METER; |
|
141 | - $profile2->length_units = VehicleSizeUnits::METER; |
|
142 | - $profile2->height = 4; |
|
143 | - $profile2->width = 2.44; |
|
144 | - $profile2->length = 14.6; |
|
145 | - $profile2->is_predefined = false; |
|
146 | - $profile2->is_default = false; |
|
147 | - $profile2->weight_units = VehicleWeightUnits::KILOGRAM; |
|
148 | - $profile2->weight = 36300; |
|
149 | - $profile2->max_weight_per_axle = 15400; |
|
150 | - $profile2->fuel_type = FuelTypes::UNLEADED_87; |
|
151 | - $profile2->fuel_consumption_city = 5; |
|
152 | - $profile2->fuel_consumption_highway = 10; |
|
153 | - $profile2->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
154 | - $profile2->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
155 | - |
|
156 | - $result2 = $profile2->createVehicleProfile($profile2->toArray()); |
|
157 | - |
|
158 | - self::assertNotNull($result2); |
|
159 | - self::assertInstanceOf( |
|
160 | - VehicleProfile::class, |
|
161 | - VehicleProfile::fromArray($result2) |
|
162 | - ); |
|
163 | - |
|
164 | - self::$createdVehicleProfiles[] = $result2; |
|
165 | - |
|
166 | - #endregion |
|
167 | - } |
|
168 | - |
|
169 | - public function testFromArray() |
|
170 | - { |
|
171 | - $class6TruckParams = Vehicle::fromArray([ |
|
172 | - 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
173 | - 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
174 | - 'vehicle_license_plate' => 'CVH4561', |
|
175 | - 'vehicle_model' => 'TopKick C5500', |
|
176 | - 'vehicle_model_year' => 1995, |
|
177 | - 'vehicle_year_acquired' => 2008, |
|
178 | - 'vehicle_reg_country_id' => 223, |
|
179 | - 'vehicle_reg_state_id' => 12, |
|
180 | - 'vehicle_make' => 'GMC', |
|
181 | - 'vehicle_type_id' => 'pickup_truck', |
|
182 | - 'vehicle_cost_new' => 60000, |
|
183 | - 'purchased_new' => true, |
|
184 | - 'mpg_city' => 8, |
|
185 | - 'mpg_highway' => 14, |
|
186 | - 'fuel_type' => 'diesel', |
|
187 | - 'license_start_date' => '2021-01-01', |
|
188 | - 'license_end_date' => '2031-01-01', |
|
189 | - ]); |
|
190 | - |
|
191 | - $this->assertEquals($class6TruckParams->vehicle_alias , 'GMC TopKick C5500 TST 6'); |
|
192 | - $this->assertEquals($class6TruckParams->vehicle_vin , 'SAJXA01A06FN08012'); |
|
193 | - $this->assertEquals($class6TruckParams->vehicle_license_plate , 'CVH4561'); |
|
194 | - $this->assertEquals($class6TruckParams->vehicle_model , 'TopKick C5500'); |
|
195 | - $this->assertEquals($class6TruckParams->vehicle_model_year , 1995); |
|
196 | - $this->assertEquals($class6TruckParams->vehicle_year_acquired , 2008); |
|
197 | - $this->assertEquals($class6TruckParams->vehicle_reg_country_id , 223); |
|
198 | - $this->assertEquals($class6TruckParams->vehicle_reg_state_id , 12); |
|
199 | - $this->assertEquals($class6TruckParams->vehicle_make , 'GMC'); |
|
200 | - $this->assertEquals($class6TruckParams->vehicle_type_id , 'pickup_truck'); |
|
201 | - $this->assertEquals($class6TruckParams->vehicle_cost_new , 60000); |
|
202 | - $this->assertEquals($class6TruckParams->purchased_new ,true); |
|
203 | - $this->assertEquals($class6TruckParams->mpg_city , 8); |
|
204 | - $this->assertEquals($class6TruckParams->mpg_highway , 14); |
|
205 | - $this->assertEquals($class6TruckParams->fuel_type , 'diesel'); |
|
206 | - $this->assertEquals($class6TruckParams->license_start_date , '2021-01-01'); |
|
207 | - $this->assertEquals($class6TruckParams->license_end_date , '2031-01-01'); |
|
208 | - |
|
209 | - |
|
210 | - } |
|
211 | - |
|
212 | - public function testGetVehiclesPaginatedList() |
|
213 | - { |
|
214 | - $vehParams = new VehicleParameters(); |
|
215 | - |
|
216 | - $vehParams->with_pagination = true; |
|
217 | - $vehParams->page = 1; |
|
218 | - $vehParams->perPage = 10; |
|
219 | - |
|
220 | - $vehicle = new Vehicle(); |
|
221 | - |
|
222 | - $result = $vehicle->getVehiclesPaginatedList($vehParams->toArray()); |
|
223 | - |
|
224 | - $this->assertNotNull($result); |
|
225 | - $this->assertTrue(is_array($result)); |
|
226 | - $this->assertTrue(sizeof($result)>0); |
|
227 | - $this->assertInstanceOf(Vehicle::class, Vehicle::fromArray($result)); |
|
228 | - } |
|
229 | - |
|
230 | - public function testCreateVehicle() |
|
231 | - { |
|
232 | - $vehicle = new Vehicle(); |
|
233 | - |
|
234 | - $class7TruckParams = Vehicle::fromArray([ |
|
235 | - 'vehicle_alias' => 'FORD F750 TST 7', |
|
236 | - 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
237 | - 'vehicle_license_plate' => 'FFV9547', |
|
238 | - 'vehicle_model' => 'F-750', |
|
239 | - 'vehicle_model_year' => 2010, |
|
240 | - 'vehicle_year_acquired' => 2018, |
|
241 | - 'vehicle_reg_country_id' => 223, |
|
242 | - 'vehicle_reg_state_id' => 12, |
|
243 | - 'vehicle_make' => 'Ford', |
|
244 | - 'vehicle_type_id' => 'livestock_carrier', |
|
245 | - 'vehicle_cost_new' => 70000, |
|
246 | - 'purchased_new' => false, |
|
247 | - 'mpg_city' => 6, |
|
248 | - 'mpg_highway' => 12, |
|
249 | - 'fuel_consumption_city' => 6, |
|
250 | - 'fuel_consumption_highway' => 12, |
|
251 | - 'fuel_type' => 'diesel', |
|
252 | - 'license_start_date' => '2020-03-01', |
|
253 | - 'license_end_date' => '2028-12-01', |
|
254 | - ]); |
|
255 | - |
|
256 | - $result = $vehicle->createVehicle($class7TruckParams); |
|
257 | - |
|
258 | - self::assertNotNull($result); |
|
259 | - self::assertInstanceOf( |
|
260 | - Vehicle::class, |
|
261 | - Vehicle::fromArray($result) |
|
262 | - ); |
|
263 | - |
|
264 | - self::$createdVehicles[] = $result; |
|
265 | - } |
|
266 | - |
|
267 | - public function testCreateTemporaryVehicle() |
|
268 | - { |
|
269 | - $this->markTestSkipped('The endpoint vehicles/assign is enabled for the accounts with the specified features.'); |
|
270 | - |
|
271 | - $vehicle = new Vehicle(); |
|
272 | - |
|
273 | - $tempVehParams = new VehicleTemporary(); |
|
274 | - |
|
275 | - $tempVehParams->assigned_member_id = 1; |
|
276 | - $tempVehParams->expires_at = '2028-12-20'; |
|
277 | - $tempVehParams->force_assignment = true; |
|
278 | - $tempVehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
279 | - $tempVehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
280 | - |
|
281 | - $result = $vehicle->createTemporaryVehicle($tempVehParams->toArray()); |
|
282 | - |
|
283 | - self::assertNotNull($result); |
|
284 | - self::assertInstanceOf( |
|
285 | - VehicleTemporary::class, |
|
286 | - VehicleTemporary::fromArray($result) |
|
287 | - ); |
|
288 | - } |
|
289 | - |
|
290 | - public function testExecuteVehicleOrder() |
|
291 | - { |
|
292 | - $this->markTestSkipped('The endpoint vehicles/execute is enabled for the account with the specified features.'); |
|
293 | - |
|
294 | - $vehicle = new Vehicle(); |
|
295 | - |
|
296 | - $orderParams = new VehicleOrderParameters(); |
|
297 | - $orderParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
298 | - $orderParams->lat = 38.247605; |
|
299 | - $orderParams->lng = -85.746697; |
|
300 | - |
|
301 | - $result = $vehicle->executeVehicleOrder($orderParams->toArray()); |
|
302 | - |
|
303 | - self::assertNotNull($result); |
|
304 | - self::assertInstanceOf( |
|
305 | - VehicleOrderResponse::class, |
|
306 | - VehicleOrderResponse::fromArray($result) |
|
307 | - ); |
|
308 | - } |
|
309 | - |
|
310 | - public function testGetLatestVehicleLocations() |
|
311 | - { |
|
312 | - $vehicle = new Vehicle(); |
|
313 | - |
|
314 | - $vehicleIDs = array_column(self::$createdVehicles, 'vehicle_id'); |
|
315 | - |
|
316 | - $vehParams = new VehicleParameters(); |
|
317 | - $vehParams->ids = $vehicleIDs; |
|
318 | - |
|
319 | - $result = $vehicle->getVehicleLocations($vehParams); |
|
320 | - |
|
321 | - self::assertNotNull($result); |
|
322 | - self::assertInstanceOf( |
|
323 | - VehicleLocationResponse::class, |
|
324 | - VehicleLocationResponse::fromArray($result) |
|
325 | - ); |
|
326 | - self::assertTrue(isset($result['data'])); |
|
327 | - self::assertTrue(is_array($result['data'])); |
|
328 | - } |
|
329 | - |
|
330 | - public function testGetVehicleById() |
|
331 | - { |
|
332 | - $vehicle = new Vehicle(); |
|
333 | - |
|
334 | - $vehParams = new VehicleParameters(); |
|
335 | - $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
336 | - |
|
337 | - $result = $vehicle->getVehicleById($vehParams->toArray()); |
|
338 | - |
|
339 | - self::assertNotNull($result); |
|
340 | - self::assertInstanceOf( |
|
341 | - Vehicle::class, |
|
342 | - Vehicle::fromArray($result) |
|
343 | - ); |
|
344 | - self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - public function testGetVehicleTrack() |
|
349 | - { |
|
350 | - $vehicle = new Vehicle(); |
|
29 | + public static $createdVehicles = []; |
|
30 | + public static $createdVehicleProfiles = []; |
|
31 | + |
|
32 | + public static function setUpBeforeClass() |
|
33 | + { |
|
34 | + Route4Me::setApiKey(Constants::API_KEY); |
|
35 | + |
|
36 | + $vehicle = new Vehicle(); |
|
37 | + |
|
38 | + //region Create Test Vehicles |
|
39 | + |
|
40 | + $class6TruckParams = Vehicle::fromArray([ |
|
41 | + 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
42 | + 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
43 | + 'vehicle_license_plate' => 'CVH4561', |
|
44 | + 'vehicle_model' => 'TopKick C5500', |
|
45 | + 'vehicle_model_year' => 1995, |
|
46 | + 'vehicle_year_acquired' => 2008, |
|
47 | + 'vehicle_reg_country_id' => 223, |
|
48 | + 'vehicle_reg_state_id' => 12, |
|
49 | + 'vehicle_make' => 'GMC', |
|
50 | + 'vehicle_type_id' => 'pickup_truck', |
|
51 | + 'vehicle_cost_new' => 60000, |
|
52 | + 'purchased_new' => true, |
|
53 | + 'mpg_city' => 8, |
|
54 | + 'mpg_highway' => 14, |
|
55 | + 'fuel_type' => 'diesel', |
|
56 | + 'license_start_date' => '2021-01-01', |
|
57 | + 'license_end_date' => '2031-01-01', |
|
58 | + ]); |
|
59 | + |
|
60 | + $result = $vehicle->createVehicle($class6TruckParams); |
|
61 | + |
|
62 | + self::assertNotNull($result); |
|
63 | + self::assertInstanceOf( |
|
64 | + Vehicle::class, |
|
65 | + Vehicle::fromArray($result) |
|
66 | + ); |
|
67 | + |
|
68 | + self::$createdVehicles[] = $result; |
|
69 | + |
|
70 | + |
|
71 | + $class7TruckParams = Vehicle::fromArray([ |
|
72 | + 'vehicle_alias' => 'FORD F750 TST 7', |
|
73 | + 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
74 | + 'vehicle_license_plate' => 'FFV9547', |
|
75 | + 'vehicle_model' => 'F-750', |
|
76 | + 'vehicle_model_year' => 2010, |
|
77 | + 'vehicle_year_acquired' => 2018, |
|
78 | + 'vehicle_reg_country_id' => 223, |
|
79 | + 'vehicle_make' => 'Ford', |
|
80 | + 'vehicle_type_id' => 'livestock_carrier', |
|
81 | + 'vehicle_cost_new' => 60000, |
|
82 | + 'purchased_new' => true, |
|
83 | + 'mpg_city' => 7, |
|
84 | + 'mpg_highway' => 14, |
|
85 | + 'fuel_consumption_city' => 7, |
|
86 | + 'fuel_consumption_highway' => 14, |
|
87 | + 'fuel_type' => 'diesel', |
|
88 | + 'license_start_date' => '2021-01-01', |
|
89 | + 'license_end_date' => '2031-01-01', |
|
90 | + ]); |
|
91 | + |
|
92 | + $result = $vehicle->createVehicle($class7TruckParams); |
|
93 | + |
|
94 | + self::assertNotNull($result); |
|
95 | + self::assertInstanceOf( |
|
96 | + Vehicle::class, |
|
97 | + Vehicle::fromArray($result) |
|
98 | + ); |
|
99 | + |
|
100 | + self::$createdVehicles[] = $result; |
|
101 | + |
|
102 | + //endregion |
|
103 | + |
|
104 | + #region Create Test Vehicle Profiles |
|
105 | + |
|
106 | + $profile1 = new VehicleProfile(); |
|
107 | + |
|
108 | + $profile1->name = "Heavy Duty - 28 Double Trailer ".date('Y-m-d H:i'); |
|
109 | + $profile1->height_units = VehicleSizeUnits::METER; |
|
110 | + $profile1->width_units = VehicleSizeUnits::METER; |
|
111 | + $profile1->length_units = VehicleSizeUnits::METER; |
|
112 | + $profile1->height = 4; |
|
113 | + $profile1->width = 2.44; |
|
114 | + $profile1->length = 12.2; |
|
115 | + $profile1->is_predefined = false; |
|
116 | + $profile1->is_default = false; |
|
117 | + $profile1->weight_units = VehicleWeightUnits::KILOGRAM; |
|
118 | + $profile1->weight = 20400; |
|
119 | + $profile1->max_weight_per_axle = 15400; |
|
120 | + $profile1->fuel_type = FuelTypes::UNLEADED_91; |
|
121 | + $profile1->fuel_consumption_city = 6; |
|
122 | + $profile1->fuel_consumption_highway = 12; |
|
123 | + $profile1->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
124 | + $profile1->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
125 | + |
|
126 | + $result1 = $profile1->createVehicleProfile($profile1->toArray()); |
|
127 | + |
|
128 | + self::assertNotNull($result1); |
|
129 | + self::assertInstanceOf( |
|
130 | + VehicleProfile::class, |
|
131 | + VehicleProfile::fromArray($result1) |
|
132 | + ); |
|
133 | + |
|
134 | + self::$createdVehicleProfiles[] = $result1; |
|
135 | + |
|
136 | + $profile2 = new VehicleProfile(); |
|
137 | + |
|
138 | + $profile2->name = "Heavy Duty - 40 Straight Truck ".date('Y-m-d H:i'); |
|
139 | + $profile2->height_units = VehicleSizeUnits::METER; |
|
140 | + $profile2->width_units = VehicleSizeUnits::METER; |
|
141 | + $profile2->length_units = VehicleSizeUnits::METER; |
|
142 | + $profile2->height = 4; |
|
143 | + $profile2->width = 2.44; |
|
144 | + $profile2->length = 14.6; |
|
145 | + $profile2->is_predefined = false; |
|
146 | + $profile2->is_default = false; |
|
147 | + $profile2->weight_units = VehicleWeightUnits::KILOGRAM; |
|
148 | + $profile2->weight = 36300; |
|
149 | + $profile2->max_weight_per_axle = 15400; |
|
150 | + $profile2->fuel_type = FuelTypes::UNLEADED_87; |
|
151 | + $profile2->fuel_consumption_city = 5; |
|
152 | + $profile2->fuel_consumption_highway = 10; |
|
153 | + $profile2->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
154 | + $profile2->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
155 | + |
|
156 | + $result2 = $profile2->createVehicleProfile($profile2->toArray()); |
|
157 | + |
|
158 | + self::assertNotNull($result2); |
|
159 | + self::assertInstanceOf( |
|
160 | + VehicleProfile::class, |
|
161 | + VehicleProfile::fromArray($result2) |
|
162 | + ); |
|
163 | + |
|
164 | + self::$createdVehicleProfiles[] = $result2; |
|
165 | + |
|
166 | + #endregion |
|
167 | + } |
|
168 | + |
|
169 | + public function testFromArray() |
|
170 | + { |
|
171 | + $class6TruckParams = Vehicle::fromArray([ |
|
172 | + 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
173 | + 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
174 | + 'vehicle_license_plate' => 'CVH4561', |
|
175 | + 'vehicle_model' => 'TopKick C5500', |
|
176 | + 'vehicle_model_year' => 1995, |
|
177 | + 'vehicle_year_acquired' => 2008, |
|
178 | + 'vehicle_reg_country_id' => 223, |
|
179 | + 'vehicle_reg_state_id' => 12, |
|
180 | + 'vehicle_make' => 'GMC', |
|
181 | + 'vehicle_type_id' => 'pickup_truck', |
|
182 | + 'vehicle_cost_new' => 60000, |
|
183 | + 'purchased_new' => true, |
|
184 | + 'mpg_city' => 8, |
|
185 | + 'mpg_highway' => 14, |
|
186 | + 'fuel_type' => 'diesel', |
|
187 | + 'license_start_date' => '2021-01-01', |
|
188 | + 'license_end_date' => '2031-01-01', |
|
189 | + ]); |
|
190 | + |
|
191 | + $this->assertEquals($class6TruckParams->vehicle_alias , 'GMC TopKick C5500 TST 6'); |
|
192 | + $this->assertEquals($class6TruckParams->vehicle_vin , 'SAJXA01A06FN08012'); |
|
193 | + $this->assertEquals($class6TruckParams->vehicle_license_plate , 'CVH4561'); |
|
194 | + $this->assertEquals($class6TruckParams->vehicle_model , 'TopKick C5500'); |
|
195 | + $this->assertEquals($class6TruckParams->vehicle_model_year , 1995); |
|
196 | + $this->assertEquals($class6TruckParams->vehicle_year_acquired , 2008); |
|
197 | + $this->assertEquals($class6TruckParams->vehicle_reg_country_id , 223); |
|
198 | + $this->assertEquals($class6TruckParams->vehicle_reg_state_id , 12); |
|
199 | + $this->assertEquals($class6TruckParams->vehicle_make , 'GMC'); |
|
200 | + $this->assertEquals($class6TruckParams->vehicle_type_id , 'pickup_truck'); |
|
201 | + $this->assertEquals($class6TruckParams->vehicle_cost_new , 60000); |
|
202 | + $this->assertEquals($class6TruckParams->purchased_new ,true); |
|
203 | + $this->assertEquals($class6TruckParams->mpg_city , 8); |
|
204 | + $this->assertEquals($class6TruckParams->mpg_highway , 14); |
|
205 | + $this->assertEquals($class6TruckParams->fuel_type , 'diesel'); |
|
206 | + $this->assertEquals($class6TruckParams->license_start_date , '2021-01-01'); |
|
207 | + $this->assertEquals($class6TruckParams->license_end_date , '2031-01-01'); |
|
208 | + |
|
209 | + |
|
210 | + } |
|
211 | + |
|
212 | + public function testGetVehiclesPaginatedList() |
|
213 | + { |
|
214 | + $vehParams = new VehicleParameters(); |
|
215 | + |
|
216 | + $vehParams->with_pagination = true; |
|
217 | + $vehParams->page = 1; |
|
218 | + $vehParams->perPage = 10; |
|
219 | + |
|
220 | + $vehicle = new Vehicle(); |
|
221 | + |
|
222 | + $result = $vehicle->getVehiclesPaginatedList($vehParams->toArray()); |
|
223 | + |
|
224 | + $this->assertNotNull($result); |
|
225 | + $this->assertTrue(is_array($result)); |
|
226 | + $this->assertTrue(sizeof($result)>0); |
|
227 | + $this->assertInstanceOf(Vehicle::class, Vehicle::fromArray($result)); |
|
228 | + } |
|
229 | + |
|
230 | + public function testCreateVehicle() |
|
231 | + { |
|
232 | + $vehicle = new Vehicle(); |
|
233 | + |
|
234 | + $class7TruckParams = Vehicle::fromArray([ |
|
235 | + 'vehicle_alias' => 'FORD F750 TST 7', |
|
236 | + 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
237 | + 'vehicle_license_plate' => 'FFV9547', |
|
238 | + 'vehicle_model' => 'F-750', |
|
239 | + 'vehicle_model_year' => 2010, |
|
240 | + 'vehicle_year_acquired' => 2018, |
|
241 | + 'vehicle_reg_country_id' => 223, |
|
242 | + 'vehicle_reg_state_id' => 12, |
|
243 | + 'vehicle_make' => 'Ford', |
|
244 | + 'vehicle_type_id' => 'livestock_carrier', |
|
245 | + 'vehicle_cost_new' => 70000, |
|
246 | + 'purchased_new' => false, |
|
247 | + 'mpg_city' => 6, |
|
248 | + 'mpg_highway' => 12, |
|
249 | + 'fuel_consumption_city' => 6, |
|
250 | + 'fuel_consumption_highway' => 12, |
|
251 | + 'fuel_type' => 'diesel', |
|
252 | + 'license_start_date' => '2020-03-01', |
|
253 | + 'license_end_date' => '2028-12-01', |
|
254 | + ]); |
|
255 | + |
|
256 | + $result = $vehicle->createVehicle($class7TruckParams); |
|
257 | + |
|
258 | + self::assertNotNull($result); |
|
259 | + self::assertInstanceOf( |
|
260 | + Vehicle::class, |
|
261 | + Vehicle::fromArray($result) |
|
262 | + ); |
|
263 | + |
|
264 | + self::$createdVehicles[] = $result; |
|
265 | + } |
|
266 | + |
|
267 | + public function testCreateTemporaryVehicle() |
|
268 | + { |
|
269 | + $this->markTestSkipped('The endpoint vehicles/assign is enabled for the accounts with the specified features.'); |
|
270 | + |
|
271 | + $vehicle = new Vehicle(); |
|
272 | + |
|
273 | + $tempVehParams = new VehicleTemporary(); |
|
274 | + |
|
275 | + $tempVehParams->assigned_member_id = 1; |
|
276 | + $tempVehParams->expires_at = '2028-12-20'; |
|
277 | + $tempVehParams->force_assignment = true; |
|
278 | + $tempVehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
279 | + $tempVehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
280 | + |
|
281 | + $result = $vehicle->createTemporaryVehicle($tempVehParams->toArray()); |
|
282 | + |
|
283 | + self::assertNotNull($result); |
|
284 | + self::assertInstanceOf( |
|
285 | + VehicleTemporary::class, |
|
286 | + VehicleTemporary::fromArray($result) |
|
287 | + ); |
|
288 | + } |
|
289 | + |
|
290 | + public function testExecuteVehicleOrder() |
|
291 | + { |
|
292 | + $this->markTestSkipped('The endpoint vehicles/execute is enabled for the account with the specified features.'); |
|
293 | + |
|
294 | + $vehicle = new Vehicle(); |
|
295 | + |
|
296 | + $orderParams = new VehicleOrderParameters(); |
|
297 | + $orderParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
298 | + $orderParams->lat = 38.247605; |
|
299 | + $orderParams->lng = -85.746697; |
|
300 | + |
|
301 | + $result = $vehicle->executeVehicleOrder($orderParams->toArray()); |
|
302 | + |
|
303 | + self::assertNotNull($result); |
|
304 | + self::assertInstanceOf( |
|
305 | + VehicleOrderResponse::class, |
|
306 | + VehicleOrderResponse::fromArray($result) |
|
307 | + ); |
|
308 | + } |
|
309 | + |
|
310 | + public function testGetLatestVehicleLocations() |
|
311 | + { |
|
312 | + $vehicle = new Vehicle(); |
|
313 | + |
|
314 | + $vehicleIDs = array_column(self::$createdVehicles, 'vehicle_id'); |
|
315 | + |
|
316 | + $vehParams = new VehicleParameters(); |
|
317 | + $vehParams->ids = $vehicleIDs; |
|
318 | + |
|
319 | + $result = $vehicle->getVehicleLocations($vehParams); |
|
320 | + |
|
321 | + self::assertNotNull($result); |
|
322 | + self::assertInstanceOf( |
|
323 | + VehicleLocationResponse::class, |
|
324 | + VehicleLocationResponse::fromArray($result) |
|
325 | + ); |
|
326 | + self::assertTrue(isset($result['data'])); |
|
327 | + self::assertTrue(is_array($result['data'])); |
|
328 | + } |
|
329 | + |
|
330 | + public function testGetVehicleById() |
|
331 | + { |
|
332 | + $vehicle = new Vehicle(); |
|
333 | + |
|
334 | + $vehParams = new VehicleParameters(); |
|
335 | + $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
336 | + |
|
337 | + $result = $vehicle->getVehicleById($vehParams->toArray()); |
|
338 | + |
|
339 | + self::assertNotNull($result); |
|
340 | + self::assertInstanceOf( |
|
341 | + Vehicle::class, |
|
342 | + Vehicle::fromArray($result) |
|
343 | + ); |
|
344 | + self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + public function testGetVehicleTrack() |
|
349 | + { |
|
350 | + $vehicle = new Vehicle(); |
|
351 | 351 | |
352 | - $vehParams = new VehicleParameters(); |
|
353 | - $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
352 | + $vehParams = new VehicleParameters(); |
|
353 | + $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
354 | 354 | |
355 | - $result = $vehicle->getVehicleTrack($vehParams->toArray()); |
|
355 | + $result = $vehicle->getVehicleTrack($vehParams->toArray()); |
|
356 | 356 | |
357 | - self::assertNotNull($result); |
|
358 | - self::assertInstanceOf( |
|
359 | - VehicleTrackResponse::class, |
|
360 | - VehicleTrackResponse::fromArray($result) |
|
361 | - ); |
|
362 | - } |
|
357 | + self::assertNotNull($result); |
|
358 | + self::assertInstanceOf( |
|
359 | + VehicleTrackResponse::class, |
|
360 | + VehicleTrackResponse::fromArray($result) |
|
361 | + ); |
|
362 | + } |
|
363 | 363 | |
364 | - public function testDeleteVehicle() |
|
365 | - { |
|
366 | - $vehicle = new Vehicle(); |
|
364 | + public function testDeleteVehicle() |
|
365 | + { |
|
366 | + $vehicle = new Vehicle(); |
|
367 | 367 | |
368 | - $vehParams = new VehicleParameters(); |
|
369 | - $vehParams->vehicle_id = self::$createdVehicles[sizeof(self::$createdVehicles) - 1]['vehicle_id']; |
|
368 | + $vehParams = new VehicleParameters(); |
|
369 | + $vehParams->vehicle_id = self::$createdVehicles[sizeof(self::$createdVehicles) - 1]['vehicle_id']; |
|
370 | 370 | |
371 | - $result = $vehicle->removeVehicle($vehParams->toArray()); |
|
371 | + $result = $vehicle->removeVehicle($vehParams->toArray()); |
|
372 | 372 | |
373 | - self::assertNotNull($result); |
|
374 | - self::assertInstanceOf( |
|
375 | - Vehicle::class, |
|
376 | - Vehicle::fromArray($result) |
|
377 | - ); |
|
378 | - self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
373 | + self::assertNotNull($result); |
|
374 | + self::assertInstanceOf( |
|
375 | + Vehicle::class, |
|
376 | + Vehicle::fromArray($result) |
|
377 | + ); |
|
378 | + self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
379 | 379 | |
380 | - array_pop(self::$createdVehicles); |
|
381 | - } |
|
380 | + array_pop(self::$createdVehicles); |
|
381 | + } |
|
382 | 382 | |
383 | - public function testGetVehicleProfiles() |
|
384 | - { |
|
385 | - $vehicleProfile = new VehicleProfile(); |
|
383 | + public function testGetVehicleProfiles() |
|
384 | + { |
|
385 | + $vehicleProfile = new VehicleProfile(); |
|
386 | 386 | |
387 | - $vehProfileParams = new VehicleProfileParameters(); |
|
387 | + $vehProfileParams = new VehicleProfileParameters(); |
|
388 | 388 | |
389 | - $vehProfileParams->with_pagination = true; |
|
390 | - $vehProfileParams->page = 1; |
|
391 | - $vehProfileParams->perPage = 10; |
|
389 | + $vehProfileParams->with_pagination = true; |
|
390 | + $vehProfileParams->page = 1; |
|
391 | + $vehProfileParams->perPage = 10; |
|
392 | 392 | |
393 | - $result = $vehicleProfile->getVehicleProfiles($vehProfileParams->toArray()); |
|
393 | + $result = $vehicleProfile->getVehicleProfiles($vehProfileParams->toArray()); |
|
394 | 394 | |
395 | - self::assertNotNull($result); |
|
396 | - self::assertInstanceOf( |
|
397 | - VehicleProfilesResponse::class, |
|
398 | - VehicleProfilesResponse::fromArray($result) |
|
399 | - ); |
|
400 | - } |
|
395 | + self::assertNotNull($result); |
|
396 | + self::assertInstanceOf( |
|
397 | + VehicleProfilesResponse::class, |
|
398 | + VehicleProfilesResponse::fromArray($result) |
|
399 | + ); |
|
400 | + } |
|
401 | 401 | |
402 | - public function testCreateVehicleProfile() |
|
403 | - { |
|
404 | - $vehicleProfile = new VehicleProfile(); |
|
402 | + public function testCreateVehicleProfile() |
|
403 | + { |
|
404 | + $vehicleProfile = new VehicleProfile(); |
|
405 | 405 | |
406 | - $profile = new VehicleProfile(); |
|
406 | + $profile = new VehicleProfile(); |
|
407 | 407 | |
408 | - $profile->name = "Heavy Duty - 48 Semitrailer ".date('Y-m-d H:i'); |
|
409 | - $profile->height_units = VehicleSizeUnits::METER; |
|
410 | - $profile->width_units = VehicleSizeUnits::METER; |
|
411 | - $profile->length_units = VehicleSizeUnits::METER; |
|
412 | - $profile->height = 3.5; |
|
413 | - $profile->width = 2.5; |
|
414 | - $profile->length = 16; |
|
415 | - $profile->is_predefined = false; |
|
416 | - $profile->is_default = false; |
|
417 | - $profile->weight_units = VehicleWeightUnits::KILOGRAM; |
|
418 | - $profile->weight = 35000; |
|
419 | - $profile->max_weight_per_axle = 17500; |
|
420 | - $profile->fuel_type = FuelTypes::UNLEADED_87; |
|
421 | - $profile->fuel_consumption_city = 6; |
|
422 | - $profile->fuel_consumption_highway = 11; |
|
423 | - $profile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
424 | - $profile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
408 | + $profile->name = "Heavy Duty - 48 Semitrailer ".date('Y-m-d H:i'); |
|
409 | + $profile->height_units = VehicleSizeUnits::METER; |
|
410 | + $profile->width_units = VehicleSizeUnits::METER; |
|
411 | + $profile->length_units = VehicleSizeUnits::METER; |
|
412 | + $profile->height = 3.5; |
|
413 | + $profile->width = 2.5; |
|
414 | + $profile->length = 16; |
|
415 | + $profile->is_predefined = false; |
|
416 | + $profile->is_default = false; |
|
417 | + $profile->weight_units = VehicleWeightUnits::KILOGRAM; |
|
418 | + $profile->weight = 35000; |
|
419 | + $profile->max_weight_per_axle = 17500; |
|
420 | + $profile->fuel_type = FuelTypes::UNLEADED_87; |
|
421 | + $profile->fuel_consumption_city = 6; |
|
422 | + $profile->fuel_consumption_highway = 11; |
|
423 | + $profile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
424 | + $profile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
425 | 425 | |
426 | 426 | |
427 | - $result = $vehicleProfile->createVehicleProfile($profile->toArray()); |
|
427 | + $result = $vehicleProfile->createVehicleProfile($profile->toArray()); |
|
428 | 428 | |
429 | - self::assertNotNull($result); |
|
430 | - self::assertInstanceOf( |
|
431 | - VehicleProfile::class, |
|
432 | - VehicleProfile::fromArray($result) |
|
433 | - ); |
|
429 | + self::assertNotNull($result); |
|
430 | + self::assertInstanceOf( |
|
431 | + VehicleProfile::class, |
|
432 | + VehicleProfile::fromArray($result) |
|
433 | + ); |
|
434 | 434 | |
435 | - self::$createdVehicleProfiles[] = $result; |
|
436 | - } |
|
435 | + self::$createdVehicleProfiles[] = $result; |
|
436 | + } |
|
437 | 437 | |
438 | - public function testDeleteVehicleProfile() |
|
439 | - { |
|
440 | - $vehicleProfile = new VehicleProfile(); |
|
438 | + public function testDeleteVehicleProfile() |
|
439 | + { |
|
440 | + $vehicleProfile = new VehicleProfile(); |
|
441 | 441 | |
442 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
442 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
443 | 443 | |
444 | - $result = $vehicleProfile->removeVehicleProfile($vehProfileId); |
|
444 | + $result = $vehicleProfile->removeVehicleProfile($vehProfileId); |
|
445 | 445 | |
446 | - self::assertNotNull($result); |
|
447 | - self::assertInstanceOf( |
|
448 | - VehicleProfile::class, |
|
449 | - VehicleProfile::fromArray($result) |
|
450 | - ); |
|
446 | + self::assertNotNull($result); |
|
447 | + self::assertInstanceOf( |
|
448 | + VehicleProfile::class, |
|
449 | + VehicleProfile::fromArray($result) |
|
450 | + ); |
|
451 | 451 | |
452 | - array_pop(self::$createdVehicleProfiles); |
|
453 | - } |
|
452 | + array_pop(self::$createdVehicleProfiles); |
|
453 | + } |
|
454 | 454 | |
455 | - public function testGetVehicleProfileById() |
|
456 | - { |
|
457 | - $vehicleProfile = new VehicleProfile(); |
|
458 | - |
|
459 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
455 | + public function testGetVehicleProfileById() |
|
456 | + { |
|
457 | + $vehicleProfile = new VehicleProfile(); |
|
458 | + |
|
459 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
460 | 460 | |
461 | - $result = $vehicleProfile->getVehicleProfileById($vehProfileId); |
|
461 | + $result = $vehicleProfile->getVehicleProfileById($vehProfileId); |
|
462 | 462 | |
463 | - self::assertNotNull($result); |
|
464 | - self::assertInstanceOf( |
|
465 | - VehicleProfile::class, |
|
466 | - VehicleProfile::fromArray($result) |
|
467 | - ); |
|
468 | - self::assertEquals($vehProfileId,$result['vehicle_profile_id']); |
|
469 | - } |
|
470 | - |
|
471 | - public function testGetVehicleByLicensePlate() |
|
472 | - { |
|
473 | - $vehicle = new Vehicle(); |
|
474 | - |
|
475 | - $vehParams = new VehicleParameters(); |
|
476 | - $vehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
477 | - |
|
478 | - $result = $vehicle->getVehicleByLicensePlate($vehParams); |
|
463 | + self::assertNotNull($result); |
|
464 | + self::assertInstanceOf( |
|
465 | + VehicleProfile::class, |
|
466 | + VehicleProfile::fromArray($result) |
|
467 | + ); |
|
468 | + self::assertEquals($vehProfileId,$result['vehicle_profile_id']); |
|
469 | + } |
|
470 | + |
|
471 | + public function testGetVehicleByLicensePlate() |
|
472 | + { |
|
473 | + $vehicle = new Vehicle(); |
|
474 | + |
|
475 | + $vehParams = new VehicleParameters(); |
|
476 | + $vehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
477 | + |
|
478 | + $result = $vehicle->getVehicleByLicensePlate($vehParams); |
|
479 | 479 | |
480 | - self::assertNotNull($result); |
|
481 | - self::assertInstanceOf( |
|
482 | - VehicleResponse::class, |
|
483 | - VehicleResponse::fromArray($result) |
|
484 | - ); |
|
485 | - } |
|
486 | - |
|
487 | - public function testSearchVehicles() |
|
488 | - { |
|
489 | - $this->markTestSkipped('This method is deprecated until resolving the response issue.'); |
|
490 | - |
|
491 | - $vehicle = new Vehicle(); |
|
492 | - |
|
493 | - $searchParams = new VehicleSearchParameters(); |
|
494 | - |
|
495 | - $searchParams->vehicle_ids = array_column(self::$createdVehicles, 'vehicle_id'); |
|
496 | - $searchParams->lat = 29.748868; |
|
497 | - $searchParams->lng = -95.358473; |
|
498 | - |
|
499 | - $result = $vehicle->searchVehicles($searchParams); |
|
500 | - |
|
501 | - self::assertNotNull($result); |
|
502 | - self::assertInstanceOf( |
|
503 | - Vehicle::class, |
|
504 | - VehicleResponse::fromArray($result[0]) |
|
505 | - ); |
|
506 | - } |
|
507 | - |
|
508 | - public function testUpdateVehicle() |
|
509 | - { |
|
510 | - $vehicle = new Vehicle(); |
|
511 | - |
|
512 | - $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated'; |
|
513 | - $vehicle->vehicle_vin = '11111111111111111'; |
|
514 | - $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
480 | + self::assertNotNull($result); |
|
481 | + self::assertInstanceOf( |
|
482 | + VehicleResponse::class, |
|
483 | + VehicleResponse::fromArray($result) |
|
484 | + ); |
|
485 | + } |
|
486 | + |
|
487 | + public function testSearchVehicles() |
|
488 | + { |
|
489 | + $this->markTestSkipped('This method is deprecated until resolving the response issue.'); |
|
490 | + |
|
491 | + $vehicle = new Vehicle(); |
|
492 | + |
|
493 | + $searchParams = new VehicleSearchParameters(); |
|
494 | + |
|
495 | + $searchParams->vehicle_ids = array_column(self::$createdVehicles, 'vehicle_id'); |
|
496 | + $searchParams->lat = 29.748868; |
|
497 | + $searchParams->lng = -95.358473; |
|
498 | + |
|
499 | + $result = $vehicle->searchVehicles($searchParams); |
|
500 | + |
|
501 | + self::assertNotNull($result); |
|
502 | + self::assertInstanceOf( |
|
503 | + Vehicle::class, |
|
504 | + VehicleResponse::fromArray($result[0]) |
|
505 | + ); |
|
506 | + } |
|
507 | + |
|
508 | + public function testUpdateVehicle() |
|
509 | + { |
|
510 | + $vehicle = new Vehicle(); |
|
511 | + |
|
512 | + $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated'; |
|
513 | + $vehicle->vehicle_vin = '11111111111111111'; |
|
514 | + $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
515 | 515 | |
516 | - $result = $vehicle->updateVehicle($vehicle->toArray()); |
|
516 | + $result = $vehicle->updateVehicle($vehicle->toArray()); |
|
517 | 517 | |
518 | - self::assertNotNull($result); |
|
519 | - self::assertInstanceOf( |
|
520 | - Vehicle::class, |
|
521 | - Vehicle::fromArray($result) |
|
522 | - ); |
|
523 | - } |
|
518 | + self::assertNotNull($result); |
|
519 | + self::assertInstanceOf( |
|
520 | + Vehicle::class, |
|
521 | + Vehicle::fromArray($result) |
|
522 | + ); |
|
523 | + } |
|
524 | 524 | |
525 | - public function testUpdateVehicleProfile() |
|
526 | - { |
|
527 | - $vehicleProfile = new VehicleProfile(); |
|
525 | + public function testUpdateVehicleProfile() |
|
526 | + { |
|
527 | + $vehicleProfile = new VehicleProfile(); |
|
528 | 528 | |
529 | - $vehProfileId = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
529 | + $vehProfileId = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
530 | 530 | |
531 | - $vehicleProfile->name = self::$createdVehicleProfiles[0]['name'].'Updated'; |
|
532 | - $vehicleProfile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
533 | - $vehicleProfile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
534 | - $vehicleProfile->vehicle_profile_id = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
531 | + $vehicleProfile->name = self::$createdVehicleProfiles[0]['name'].'Updated'; |
|
532 | + $vehicleProfile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
533 | + $vehicleProfile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
534 | + $vehicleProfile->vehicle_profile_id = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
535 | 535 | |
536 | - $result = $vehicleProfile->updateVehicleProfile($vehicleProfile->toArray()); |
|
536 | + $result = $vehicleProfile->updateVehicleProfile($vehicleProfile->toArray()); |
|
537 | 537 | |
538 | - self::assertNotNull($result); |
|
539 | - self::assertInstanceOf( |
|
540 | - VehicleProfile::class, |
|
541 | - VehicleProfile::fromArray($result) |
|
542 | - ); |
|
543 | - } |
|
538 | + self::assertNotNull($result); |
|
539 | + self::assertInstanceOf( |
|
540 | + VehicleProfile::class, |
|
541 | + VehicleProfile::fromArray($result) |
|
542 | + ); |
|
543 | + } |
|
544 | 544 | |
545 | - public static function tearDownAfterClass() |
|
546 | - { |
|
547 | - $vehicle = new Vehicle(); |
|
545 | + public static function tearDownAfterClass() |
|
546 | + { |
|
547 | + $vehicle = new Vehicle(); |
|
548 | 548 | |
549 | - $vehParams = new VehicleParameters(); |
|
549 | + $vehParams = new VehicleParameters(); |
|
550 | 550 | |
551 | - foreach (self::$createdVehicles as $veh1) { |
|
552 | - if (isset($veh1['vehicle_id'])) { |
|
553 | - $vehParams->vehicle_id = $veh1['vehicle_id']; |
|
554 | - $result1 = $vehicle->removeVehicle($vehParams->toArray()); |
|
555 | - } |
|
556 | - } |
|
551 | + foreach (self::$createdVehicles as $veh1) { |
|
552 | + if (isset($veh1['vehicle_id'])) { |
|
553 | + $vehParams->vehicle_id = $veh1['vehicle_id']; |
|
554 | + $result1 = $vehicle->removeVehicle($vehParams->toArray()); |
|
555 | + } |
|
556 | + } |
|
557 | 557 | |
558 | - $vehProfile = new VehicleProfile(); |
|
558 | + $vehProfile = new VehicleProfile(); |
|
559 | 559 | |
560 | - foreach (self::$createdVehicleProfiles as $prof1) { |
|
561 | - if (isset($prof1['vehicle_profile_id'])) { |
|
562 | - $result2 = $vehProfile->removeVehicleProfile($prof1['vehicle_profile_id']); |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
560 | + foreach (self::$createdVehicleProfiles as $prof1) { |
|
561 | + if (isset($prof1['vehicle_profile_id'])) { |
|
562 | + $result2 = $vehProfile->removeVehicleProfile($prof1['vehicle_profile_id']); |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | 566 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | 'license_end_date' => '2031-01-01', |
189 | 189 | ]); |
190 | 190 | |
191 | - $this->assertEquals($class6TruckParams->vehicle_alias , 'GMC TopKick C5500 TST 6'); |
|
192 | - $this->assertEquals($class6TruckParams->vehicle_vin , 'SAJXA01A06FN08012'); |
|
193 | - $this->assertEquals($class6TruckParams->vehicle_license_plate , 'CVH4561'); |
|
194 | - $this->assertEquals($class6TruckParams->vehicle_model , 'TopKick C5500'); |
|
195 | - $this->assertEquals($class6TruckParams->vehicle_model_year , 1995); |
|
196 | - $this->assertEquals($class6TruckParams->vehicle_year_acquired , 2008); |
|
197 | - $this->assertEquals($class6TruckParams->vehicle_reg_country_id , 223); |
|
198 | - $this->assertEquals($class6TruckParams->vehicle_reg_state_id , 12); |
|
199 | - $this->assertEquals($class6TruckParams->vehicle_make , 'GMC'); |
|
200 | - $this->assertEquals($class6TruckParams->vehicle_type_id , 'pickup_truck'); |
|
201 | - $this->assertEquals($class6TruckParams->vehicle_cost_new , 60000); |
|
202 | - $this->assertEquals($class6TruckParams->purchased_new ,true); |
|
203 | - $this->assertEquals($class6TruckParams->mpg_city , 8); |
|
204 | - $this->assertEquals($class6TruckParams->mpg_highway , 14); |
|
205 | - $this->assertEquals($class6TruckParams->fuel_type , 'diesel'); |
|
206 | - $this->assertEquals($class6TruckParams->license_start_date , '2021-01-01'); |
|
207 | - $this->assertEquals($class6TruckParams->license_end_date , '2031-01-01'); |
|
191 | + $this->assertEquals($class6TruckParams->vehicle_alias, 'GMC TopKick C5500 TST 6'); |
|
192 | + $this->assertEquals($class6TruckParams->vehicle_vin, 'SAJXA01A06FN08012'); |
|
193 | + $this->assertEquals($class6TruckParams->vehicle_license_plate, 'CVH4561'); |
|
194 | + $this->assertEquals($class6TruckParams->vehicle_model, 'TopKick C5500'); |
|
195 | + $this->assertEquals($class6TruckParams->vehicle_model_year, 1995); |
|
196 | + $this->assertEquals($class6TruckParams->vehicle_year_acquired, 2008); |
|
197 | + $this->assertEquals($class6TruckParams->vehicle_reg_country_id, 223); |
|
198 | + $this->assertEquals($class6TruckParams->vehicle_reg_state_id, 12); |
|
199 | + $this->assertEquals($class6TruckParams->vehicle_make, 'GMC'); |
|
200 | + $this->assertEquals($class6TruckParams->vehicle_type_id, 'pickup_truck'); |
|
201 | + $this->assertEquals($class6TruckParams->vehicle_cost_new, 60000); |
|
202 | + $this->assertEquals($class6TruckParams->purchased_new, true); |
|
203 | + $this->assertEquals($class6TruckParams->mpg_city, 8); |
|
204 | + $this->assertEquals($class6TruckParams->mpg_highway, 14); |
|
205 | + $this->assertEquals($class6TruckParams->fuel_type, 'diesel'); |
|
206 | + $this->assertEquals($class6TruckParams->license_start_date, '2021-01-01'); |
|
207 | + $this->assertEquals($class6TruckParams->license_end_date, '2031-01-01'); |
|
208 | 208 | |
209 | 209 | |
210 | 210 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | { |
440 | 440 | $vehicleProfile = new VehicleProfile(); |
441 | 441 | |
442 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
442 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles) - 1]['vehicle_profile_id']; |
|
443 | 443 | |
444 | 444 | $result = $vehicleProfile->removeVehicleProfile($vehProfileId); |
445 | 445 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | { |
457 | 457 | $vehicleProfile = new VehicleProfile(); |
458 | 458 | |
459 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
459 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles) - 1]['vehicle_profile_id']; |
|
460 | 460 | |
461 | 461 | $result = $vehicleProfile->getVehicleProfileById($vehProfileId); |
462 | 462 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | VehicleProfile::class, |
466 | 466 | VehicleProfile::fromArray($result) |
467 | 467 | ); |
468 | - self::assertEquals($vehProfileId,$result['vehicle_profile_id']); |
|
468 | + self::assertEquals($vehProfileId, $result['vehicle_profile_id']); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | public function testGetVehicleByLicensePlate() |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | { |
510 | 510 | $vehicle = new Vehicle(); |
511 | 511 | |
512 | - $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated'; |
|
512 | + $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'].' Updated'; |
|
513 | 513 | $vehicle->vehicle_vin = '11111111111111111'; |
514 | 514 | $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
515 | 515 |
@@ -6,21 +6,21 @@ |
||
6 | 6 | |
7 | 7 | class CustomNoteTypeUnitTests extends \PHPUnit\Framework\TestCase |
8 | 8 | { |
9 | - public function testFromArray() |
|
10 | - { |
|
11 | - $customNoteType = CustomNoteType::fromArray([ |
|
12 | - 'note_custom_entry_id' => 'ABCBA1228FA18888DBEECBFA2DA7777C850E15CA', |
|
13 | - 'note_id' => '3237302', |
|
14 | - 'note_custom_type_id' => '10', |
|
15 | - 'note_custom_value' => 'Backdoor', |
|
16 | - 'note_custom_type' => 'Dropoff Location' |
|
17 | - ]); |
|
9 | + public function testFromArray() |
|
10 | + { |
|
11 | + $customNoteType = CustomNoteType::fromArray([ |
|
12 | + 'note_custom_entry_id' => 'ABCBA1228FA18888DBEECBFA2DA7777C850E15CA', |
|
13 | + 'note_id' => '3237302', |
|
14 | + 'note_custom_type_id' => '10', |
|
15 | + 'note_custom_value' => 'Backdoor', |
|
16 | + 'note_custom_type' => 'Dropoff Location' |
|
17 | + ]); |
|
18 | 18 | |
19 | - $this->assertEquals('ABCBA1228FA18888DBEECBFA2DA7777C850E15CA', $customNoteType->note_custom_entry_id); |
|
20 | - $this->assertEquals('3237302', $customNoteType->note_id); |
|
21 | - $this->assertEquals('10', $customNoteType->note_custom_type_id); |
|
22 | - $this->assertEquals('Backdoor', $customNoteType->note_custom_value); |
|
23 | - $this->assertEquals('Dropoff Location', $customNoteType->note_custom_type); |
|
24 | - } |
|
19 | + $this->assertEquals('ABCBA1228FA18888DBEECBFA2DA7777C850E15CA', $customNoteType->note_custom_entry_id); |
|
20 | + $this->assertEquals('3237302', $customNoteType->note_id); |
|
21 | + $this->assertEquals('10', $customNoteType->note_custom_type_id); |
|
22 | + $this->assertEquals('Backdoor', $customNoteType->note_custom_value); |
|
23 | + $this->assertEquals('Dropoff Location', $customNoteType->note_custom_type); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -8,202 +8,202 @@ |
||
8 | 8 | use Route4Me\Route4Me; |
9 | 9 | |
10 | 10 | class AvoidanceZoneUnitTests extends \PHPUnit\Framework\TestCase { |
11 | - protected $avoidanceZone; |
|
12 | - protected $createdAvoidanceZones; |
|
13 | - |
|
14 | - public function setUp() |
|
15 | - { |
|
16 | - $this->avoidanceZone = new AvoidanceZone(); |
|
17 | - |
|
18 | - Route4Me::setApiKey(Constants::API_KEY); |
|
19 | - |
|
20 | - $createdAvoidanceZones = []; |
|
21 | - |
|
22 | - $rectTerritoryParams['type'] = TerritoryTypes::RECT; |
|
23 | - $rectTerritoryParams['data'] = [ |
|
24 | - '43.51668853502909,-109.3798828125', |
|
25 | - '46.98025235521883,-101.865234375', |
|
26 | - ]; |
|
27 | - |
|
28 | - $AvoidanceZoneParameters = AvoidanceZone::fromArray([ |
|
29 | - 'territory_name' => 'Test Rectangular Avoidance Zone '.strval(rand(10000, 99999)), |
|
30 | - 'territory_color' => 'ff7700', |
|
31 | - 'territory' => $rectTerritoryParams, |
|
32 | - ]); |
|
33 | - |
|
34 | - $rectAvoidanceZone = AvoidanceZone::fromArray( |
|
35 | - AvoidanceZone::addAvoidanceZone($AvoidanceZoneParameters) |
|
36 | - ); |
|
37 | - |
|
38 | - $this->createdAvoidanceZones[] = $rectAvoidanceZone; |
|
39 | - |
|
40 | - $circleTerritoryParams['type'] = TerritoryTypes::CIRCLE; |
|
41 | - $circleTerritoryParams['data'] = [ |
|
42 | - '37.569752822786455,-77.47833251953125', |
|
43 | - '5000', |
|
44 | - ]; |
|
45 | - |
|
46 | - $AvoidanceZoneParameters = AvoidanceZone::fromArray([ |
|
47 | - 'territory_name' => 'Test Rectangular Avoidance Zone '.strval(rand(10000, 99999)), |
|
48 | - 'territory_color' => 'ff7700', |
|
49 | - 'territory' => $circleTerritoryParams, |
|
50 | - ]); |
|
51 | - |
|
52 | - $circleAvoidanceZone = AvoidanceZone::fromArray( |
|
53 | - AvoidanceZone::addAvoidanceZone($AvoidanceZoneParameters) |
|
54 | - ); |
|
55 | - |
|
56 | - $this->createdAvoidanceZones[] = $circleAvoidanceZone; |
|
57 | - } |
|
58 | - |
|
59 | - public function testFromArray() |
|
60 | - { |
|
61 | - $circleTerritoryParams['type'] = TerritoryTypes::CIRCLE; |
|
62 | - $circleTerritoryParams['data'] = [ |
|
63 | - '37.569752822786455,-77.47833251953125', |
|
64 | - '5000', |
|
65 | - ]; |
|
66 | - |
|
67 | - $avoidanceZone = AvoidanceZone::fromArray([ |
|
68 | - 'territory_name' => "Rect Territory Name", |
|
69 | - 'territory_color' => "ff0000", |
|
70 | - 'territory' => $circleTerritoryParams |
|
71 | - ]); |
|
72 | - |
|
73 | - $this->assertEquals($avoidanceZone->territory_name, "Rect Territory Name"); |
|
74 | - $this->assertEquals($avoidanceZone->territory_color, "ff0000"); |
|
75 | - $this->assertEquals($avoidanceZone->territory['type'], TerritoryTypes::CIRCLE); |
|
76 | - $this->assertEquals($avoidanceZone->territory['data'], [ |
|
77 | - '37.569752822786455,-77.47833251953125', |
|
78 | - '5000', |
|
79 | - ]); |
|
80 | - } |
|
81 | - |
|
82 | - public function testToArray() |
|
83 | - { |
|
84 | - $rectTerritoryParams['type'] = TerritoryTypes::RECT; |
|
85 | - $rectTerritoryParams['data'] = [ |
|
86 | - '43.51668853502909,-109.3798828125', |
|
87 | - '46.98025235521883,-101.865234375', |
|
88 | - ]; |
|
89 | - |
|
90 | - $avoidanceZone = AvoidanceZone::fromArray([ |
|
91 | - 'territory_name' => "Rect Territory Name", |
|
92 | - 'territory_color' => "ff0000", |
|
93 | - 'territory' => $rectTerritoryParams |
|
94 | - ]); |
|
95 | - |
|
96 | - $this->assertEquals($avoidanceZone->toArray(), |
|
97 | - [ |
|
98 | - 'territory_name' => "Rect Territory Name", |
|
99 | - 'territory_color' => "ff0000", |
|
100 | - 'territory' => $rectTerritoryParams |
|
101 | - ] |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - public function testGetAvoidanceZones() |
|
106 | - { |
|
107 | - $avoidanceZones = AvoidanceZone::getAvoidanceZones([]); |
|
108 | - |
|
109 | - $this->assertNotNull($avoidanceZones); |
|
110 | - $this->assertTrue(is_array($avoidanceZones)); |
|
111 | - $first=AvoidanceZone::fromArray($avoidanceZones[0]); |
|
112 | - $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$first]); |
|
113 | - } |
|
114 | - |
|
115 | - public function testGetAvoidanceZone() |
|
116 | - { |
|
117 | - $avoidanceZones = AvoidanceZone::getAvoidanceZones([]); |
|
118 | - |
|
119 | - $avoidanceZoneId = $avoidanceZones[0]['territory_id']; |
|
120 | - $this->assertNotNull($avoidanceZoneId); |
|
121 | - |
|
122 | - $avoidanceZone = AvoidanceZone::fromArray(AvoidanceZone::getAvoidanceZone($avoidanceZoneId)); |
|
123 | - |
|
124 | - $this->assertNotNull($avoidanceZone); |
|
125 | - $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$avoidanceZone]); |
|
126 | - } |
|
127 | - |
|
128 | - public function testAddAvoidanceZone() |
|
129 | - { |
|
130 | - $polyTerritoryParams['type'] = TerritoryTypes::POLY; |
|
131 | - $polyTerritoryParams['data'] = [ |
|
132 | - '37.769752822786455,-77.67833251953125', |
|
133 | - '37.75886716305343,-77.68974800109863', |
|
134 | - '37.74763966054455,-77.6917221069336', |
|
135 | - '37.74655084306813,-77.68863220214844', |
|
136 | - '37.7502255383101,-77.68125076293945', |
|
137 | - '37.74797991274437,-77.67498512268066', |
|
138 | - '37.73327960206065,-77.6411678314209', |
|
139 | - '37.74430510679532,-77.63172645568848', |
|
140 | - '37.76641925847049,-77.66846199035645', |
|
141 | - ]; |
|
142 | - |
|
143 | - $AvoidanceZoneParameters = AvoidanceZone::fromArray([ |
|
144 | - 'territory_name' => 'Test Rectangular Avoidance Zone '.strval(rand(10000, 99999)), |
|
145 | - 'territory_color' => 'ff7700', |
|
146 | - 'territory' => $polyTerritoryParams, |
|
147 | - ]); |
|
148 | - |
|
149 | - $polyAvoidanceZone = AvoidanceZone::fromArray( |
|
150 | - AvoidanceZone::addAvoidanceZone($AvoidanceZoneParameters) |
|
151 | - ); |
|
152 | - |
|
153 | - $this->createdAvoidanceZones[] = $polyAvoidanceZone; |
|
154 | - |
|
155 | - $this->assertNotNull($polyAvoidanceZone); |
|
156 | - $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$polyAvoidanceZone]); |
|
157 | - $this->assertEquals(TerritoryTypes::POLY, $polyAvoidanceZone->territory['type']); |
|
158 | - } |
|
159 | - |
|
160 | - public function testDeleteAvoidanceZone() |
|
161 | - { |
|
162 | - $territoryId = $this->createdAvoidanceZones[sizeof($this->createdAvoidanceZones)-1]->territory_id; |
|
163 | - $result = $this->avoidanceZone->deleteAvoidanceZone($territoryId); |
|
164 | - //$result = AvoidanceZone::deleteAvoidanceZone($territoryId); |
|
165 | - |
|
166 | - $this->assertNotNull($result); |
|
167 | - $this->assertTrue($result['status']); |
|
168 | - |
|
169 | - $this->createdAvoidanceZones[] = array_pop($this->createdAvoidanceZones); |
|
170 | - } |
|
171 | - |
|
172 | - public function testUpdateAvoidanceZone() |
|
173 | - { |
|
174 | - $territoryId = $this->createdAvoidanceZones[0]->territory_id; |
|
175 | - |
|
176 | - $avoidanceZoneParameters = [ |
|
177 | - 'territory_id' => $territoryId, |
|
178 | - 'territory_name' => 'Test Territory Updated', |
|
179 | - 'territory_color' => 'ff5500' |
|
180 | - ]; |
|
181 | - |
|
182 | - $updatedRoute = AvoidanceZone::fromArray( |
|
183 | - $this->avoidanceZone->updateAvoidanceZone($avoidanceZoneParameters) |
|
184 | - ); |
|
185 | - |
|
186 | - $this->assertNotNull($updatedRoute); |
|
187 | - $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$updatedRoute]); |
|
188 | - $this->assertEquals('Test Territory Updated',$updatedRoute->territory_name, "The territory name not updated"); |
|
189 | - $this->assertEquals('ff5500',$updatedRoute->territory_color, "The territory color not updated"); |
|
190 | - } |
|
191 | - |
|
192 | - public function tearDown() |
|
193 | - { |
|
194 | - foreach ($this->createdAvoidanceZones as $avZone) |
|
195 | - { |
|
196 | - $territoryId = $avZone->territory_id; |
|
197 | - |
|
198 | - $result = $this->avoidanceZone->deleteAvoidanceZone($territoryId); |
|
199 | - |
|
200 | - if ($result==true) { |
|
201 | - echo "The test avoidance zone with territory_id=".$territoryId." removed. <br>"; |
|
202 | - } |
|
203 | - else { |
|
204 | - echo "Cannot remove the test avoidance zone with territory_id=".$territoryId."<br>"; |
|
205 | - } |
|
206 | - |
|
207 | - } |
|
208 | - } |
|
11 | + protected $avoidanceZone; |
|
12 | + protected $createdAvoidanceZones; |
|
13 | + |
|
14 | + public function setUp() |
|
15 | + { |
|
16 | + $this->avoidanceZone = new AvoidanceZone(); |
|
17 | + |
|
18 | + Route4Me::setApiKey(Constants::API_KEY); |
|
19 | + |
|
20 | + $createdAvoidanceZones = []; |
|
21 | + |
|
22 | + $rectTerritoryParams['type'] = TerritoryTypes::RECT; |
|
23 | + $rectTerritoryParams['data'] = [ |
|
24 | + '43.51668853502909,-109.3798828125', |
|
25 | + '46.98025235521883,-101.865234375', |
|
26 | + ]; |
|
27 | + |
|
28 | + $AvoidanceZoneParameters = AvoidanceZone::fromArray([ |
|
29 | + 'territory_name' => 'Test Rectangular Avoidance Zone '.strval(rand(10000, 99999)), |
|
30 | + 'territory_color' => 'ff7700', |
|
31 | + 'territory' => $rectTerritoryParams, |
|
32 | + ]); |
|
33 | + |
|
34 | + $rectAvoidanceZone = AvoidanceZone::fromArray( |
|
35 | + AvoidanceZone::addAvoidanceZone($AvoidanceZoneParameters) |
|
36 | + ); |
|
37 | + |
|
38 | + $this->createdAvoidanceZones[] = $rectAvoidanceZone; |
|
39 | + |
|
40 | + $circleTerritoryParams['type'] = TerritoryTypes::CIRCLE; |
|
41 | + $circleTerritoryParams['data'] = [ |
|
42 | + '37.569752822786455,-77.47833251953125', |
|
43 | + '5000', |
|
44 | + ]; |
|
45 | + |
|
46 | + $AvoidanceZoneParameters = AvoidanceZone::fromArray([ |
|
47 | + 'territory_name' => 'Test Rectangular Avoidance Zone '.strval(rand(10000, 99999)), |
|
48 | + 'territory_color' => 'ff7700', |
|
49 | + 'territory' => $circleTerritoryParams, |
|
50 | + ]); |
|
51 | + |
|
52 | + $circleAvoidanceZone = AvoidanceZone::fromArray( |
|
53 | + AvoidanceZone::addAvoidanceZone($AvoidanceZoneParameters) |
|
54 | + ); |
|
55 | + |
|
56 | + $this->createdAvoidanceZones[] = $circleAvoidanceZone; |
|
57 | + } |
|
58 | + |
|
59 | + public function testFromArray() |
|
60 | + { |
|
61 | + $circleTerritoryParams['type'] = TerritoryTypes::CIRCLE; |
|
62 | + $circleTerritoryParams['data'] = [ |
|
63 | + '37.569752822786455,-77.47833251953125', |
|
64 | + '5000', |
|
65 | + ]; |
|
66 | + |
|
67 | + $avoidanceZone = AvoidanceZone::fromArray([ |
|
68 | + 'territory_name' => "Rect Territory Name", |
|
69 | + 'territory_color' => "ff0000", |
|
70 | + 'territory' => $circleTerritoryParams |
|
71 | + ]); |
|
72 | + |
|
73 | + $this->assertEquals($avoidanceZone->territory_name, "Rect Territory Name"); |
|
74 | + $this->assertEquals($avoidanceZone->territory_color, "ff0000"); |
|
75 | + $this->assertEquals($avoidanceZone->territory['type'], TerritoryTypes::CIRCLE); |
|
76 | + $this->assertEquals($avoidanceZone->territory['data'], [ |
|
77 | + '37.569752822786455,-77.47833251953125', |
|
78 | + '5000', |
|
79 | + ]); |
|
80 | + } |
|
81 | + |
|
82 | + public function testToArray() |
|
83 | + { |
|
84 | + $rectTerritoryParams['type'] = TerritoryTypes::RECT; |
|
85 | + $rectTerritoryParams['data'] = [ |
|
86 | + '43.51668853502909,-109.3798828125', |
|
87 | + '46.98025235521883,-101.865234375', |
|
88 | + ]; |
|
89 | + |
|
90 | + $avoidanceZone = AvoidanceZone::fromArray([ |
|
91 | + 'territory_name' => "Rect Territory Name", |
|
92 | + 'territory_color' => "ff0000", |
|
93 | + 'territory' => $rectTerritoryParams |
|
94 | + ]); |
|
95 | + |
|
96 | + $this->assertEquals($avoidanceZone->toArray(), |
|
97 | + [ |
|
98 | + 'territory_name' => "Rect Territory Name", |
|
99 | + 'territory_color' => "ff0000", |
|
100 | + 'territory' => $rectTerritoryParams |
|
101 | + ] |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + public function testGetAvoidanceZones() |
|
106 | + { |
|
107 | + $avoidanceZones = AvoidanceZone::getAvoidanceZones([]); |
|
108 | + |
|
109 | + $this->assertNotNull($avoidanceZones); |
|
110 | + $this->assertTrue(is_array($avoidanceZones)); |
|
111 | + $first=AvoidanceZone::fromArray($avoidanceZones[0]); |
|
112 | + $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$first]); |
|
113 | + } |
|
114 | + |
|
115 | + public function testGetAvoidanceZone() |
|
116 | + { |
|
117 | + $avoidanceZones = AvoidanceZone::getAvoidanceZones([]); |
|
118 | + |
|
119 | + $avoidanceZoneId = $avoidanceZones[0]['territory_id']; |
|
120 | + $this->assertNotNull($avoidanceZoneId); |
|
121 | + |
|
122 | + $avoidanceZone = AvoidanceZone::fromArray(AvoidanceZone::getAvoidanceZone($avoidanceZoneId)); |
|
123 | + |
|
124 | + $this->assertNotNull($avoidanceZone); |
|
125 | + $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$avoidanceZone]); |
|
126 | + } |
|
127 | + |
|
128 | + public function testAddAvoidanceZone() |
|
129 | + { |
|
130 | + $polyTerritoryParams['type'] = TerritoryTypes::POLY; |
|
131 | + $polyTerritoryParams['data'] = [ |
|
132 | + '37.769752822786455,-77.67833251953125', |
|
133 | + '37.75886716305343,-77.68974800109863', |
|
134 | + '37.74763966054455,-77.6917221069336', |
|
135 | + '37.74655084306813,-77.68863220214844', |
|
136 | + '37.7502255383101,-77.68125076293945', |
|
137 | + '37.74797991274437,-77.67498512268066', |
|
138 | + '37.73327960206065,-77.6411678314209', |
|
139 | + '37.74430510679532,-77.63172645568848', |
|
140 | + '37.76641925847049,-77.66846199035645', |
|
141 | + ]; |
|
142 | + |
|
143 | + $AvoidanceZoneParameters = AvoidanceZone::fromArray([ |
|
144 | + 'territory_name' => 'Test Rectangular Avoidance Zone '.strval(rand(10000, 99999)), |
|
145 | + 'territory_color' => 'ff7700', |
|
146 | + 'territory' => $polyTerritoryParams, |
|
147 | + ]); |
|
148 | + |
|
149 | + $polyAvoidanceZone = AvoidanceZone::fromArray( |
|
150 | + AvoidanceZone::addAvoidanceZone($AvoidanceZoneParameters) |
|
151 | + ); |
|
152 | + |
|
153 | + $this->createdAvoidanceZones[] = $polyAvoidanceZone; |
|
154 | + |
|
155 | + $this->assertNotNull($polyAvoidanceZone); |
|
156 | + $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$polyAvoidanceZone]); |
|
157 | + $this->assertEquals(TerritoryTypes::POLY, $polyAvoidanceZone->territory['type']); |
|
158 | + } |
|
159 | + |
|
160 | + public function testDeleteAvoidanceZone() |
|
161 | + { |
|
162 | + $territoryId = $this->createdAvoidanceZones[sizeof($this->createdAvoidanceZones)-1]->territory_id; |
|
163 | + $result = $this->avoidanceZone->deleteAvoidanceZone($territoryId); |
|
164 | + //$result = AvoidanceZone::deleteAvoidanceZone($territoryId); |
|
165 | + |
|
166 | + $this->assertNotNull($result); |
|
167 | + $this->assertTrue($result['status']); |
|
168 | + |
|
169 | + $this->createdAvoidanceZones[] = array_pop($this->createdAvoidanceZones); |
|
170 | + } |
|
171 | + |
|
172 | + public function testUpdateAvoidanceZone() |
|
173 | + { |
|
174 | + $territoryId = $this->createdAvoidanceZones[0]->territory_id; |
|
175 | + |
|
176 | + $avoidanceZoneParameters = [ |
|
177 | + 'territory_id' => $territoryId, |
|
178 | + 'territory_name' => 'Test Territory Updated', |
|
179 | + 'territory_color' => 'ff5500' |
|
180 | + ]; |
|
181 | + |
|
182 | + $updatedRoute = AvoidanceZone::fromArray( |
|
183 | + $this->avoidanceZone->updateAvoidanceZone($avoidanceZoneParameters) |
|
184 | + ); |
|
185 | + |
|
186 | + $this->assertNotNull($updatedRoute); |
|
187 | + $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$updatedRoute]); |
|
188 | + $this->assertEquals('Test Territory Updated',$updatedRoute->territory_name, "The territory name not updated"); |
|
189 | + $this->assertEquals('ff5500',$updatedRoute->territory_color, "The territory color not updated"); |
|
190 | + } |
|
191 | + |
|
192 | + public function tearDown() |
|
193 | + { |
|
194 | + foreach ($this->createdAvoidanceZones as $avZone) |
|
195 | + { |
|
196 | + $territoryId = $avZone->territory_id; |
|
197 | + |
|
198 | + $result = $this->avoidanceZone->deleteAvoidanceZone($territoryId); |
|
199 | + |
|
200 | + if ($result==true) { |
|
201 | + echo "The test avoidance zone with territory_id=".$territoryId." removed. <br>"; |
|
202 | + } |
|
203 | + else { |
|
204 | + echo "Cannot remove the test avoidance zone with territory_id=".$territoryId."<br>"; |
|
205 | + } |
|
206 | + |
|
207 | + } |
|
208 | + } |
|
209 | 209 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $this->assertNotNull($avoidanceZones); |
110 | 110 | $this->assertTrue(is_array($avoidanceZones)); |
111 | - $first=AvoidanceZone::fromArray($avoidanceZones[0]); |
|
111 | + $first = AvoidanceZone::fromArray($avoidanceZones[0]); |
|
112 | 112 | $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$first]); |
113 | 113 | } |
114 | 114 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function testDeleteAvoidanceZone() |
161 | 161 | { |
162 | - $territoryId = $this->createdAvoidanceZones[sizeof($this->createdAvoidanceZones)-1]->territory_id; |
|
162 | + $territoryId = $this->createdAvoidanceZones[sizeof($this->createdAvoidanceZones) - 1]->territory_id; |
|
163 | 163 | $result = $this->avoidanceZone->deleteAvoidanceZone($territoryId); |
164 | 164 | //$result = AvoidanceZone::deleteAvoidanceZone($territoryId); |
165 | 165 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | |
186 | 186 | $this->assertNotNull($updatedRoute); |
187 | 187 | $this->assertContainsOnlyInstancesOf('Route4Me\AvoidanceZone', [$updatedRoute]); |
188 | - $this->assertEquals('Test Territory Updated',$updatedRoute->territory_name, "The territory name not updated"); |
|
189 | - $this->assertEquals('ff5500',$updatedRoute->territory_color, "The territory color not updated"); |
|
188 | + $this->assertEquals('Test Territory Updated', $updatedRoute->territory_name, "The territory name not updated"); |
|
189 | + $this->assertEquals('ff5500', $updatedRoute->territory_color, "The territory color not updated"); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | public function tearDown() |
@@ -199,8 +199,7 @@ |
||
199 | 199 | |
200 | 200 | if ($result==true) { |
201 | 201 | echo "The test avoidance zone with territory_id=".$territoryId." removed. <br>"; |
202 | - } |
|
203 | - else { |
|
202 | + } else { |
|
204 | 203 | echo "Cannot remove the test avoidance zone with territory_id=".$territoryId."<br>"; |
205 | 204 | } |
206 | 205 |