@@ -250,15 +250,26 @@ public function testLoadByHashWithShipmentIdWrongCode()
250
250
$ this ->assertEmpty ($ this ->info ->getTrackingInfo ());
251
251
}
252
252
253
- public function testLoadByHashWithTrackId ()
254
- {
253
+ /**
254
+ * @dataProvider loadByHashWithTrackIdDataProvider
255
+ * @param string $protectCodeHash
256
+ * @param string $protectCode
257
+ * @param string $numberDetail
258
+ * @param array $trackDetails
259
+ * @return void
260
+ */
261
+ public function testLoadByHashWithTrackId (
262
+ string $ protectCodeHash ,
263
+ string $ protectCode ,
264
+ string $ numberDetail ,
265
+ array $ trackDetails
266
+ ) {
255
267
$ hash = base64_encode ('hash ' );
256
268
$ decodedHash = [
257
269
'key ' => 'track_id ' ,
258
270
'id ' => 1 ,
259
- 'hash ' => ' protected_code ' ,
271
+ 'hash ' => $ protectCodeHash ,
260
272
];
261
- $ trackDetails = 'track_details ' ;
262
273
$ this ->helper ->expects ($ this ->atLeastOnce ())
263
274
->method ('decodeTrackingHash ' )
264
275
->with ($ hash )
@@ -269,13 +280,34 @@ public function testLoadByHashWithTrackId()
269
280
->getMock ();
270
281
$ track ->expects ($ this ->atLeastOnce ())->method ('load ' )->with ($ decodedHash ['id ' ])->willReturnSelf ();
271
282
$ track ->expects ($ this ->atLeastOnce ())->method ('getId ' )->willReturn ($ decodedHash ['id ' ]);
272
- $ track ->expects ($ this ->atLeastOnce ())->method ('getProtectCode ' )->willReturn ($ decodedHash [ ' hash ' ] );
273
- $ track ->expects ($ this ->atLeastOnce ())->method ('getNumberDetail ' )->willReturn ($ trackDetails );
283
+ $ track ->expects ($ this ->atLeastOnce ())->method ('getProtectCode ' )->willReturn ($ protectCode );
284
+ $ track ->expects ($ this ->any ())->method ('getNumberDetail ' )->willReturn ($ numberDetail );
274
285
275
286
$ this ->trackFactory ->expects ($ this ->atLeastOnce ())->method ('create ' )->willReturn ($ track );
276
287
$ this ->info ->loadByHash ($ hash );
277
288
278
- $ this ->assertEquals ([[$ trackDetails ]], $ this ->info ->getTrackingInfo ());
289
+ $ this ->assertEquals ($ trackDetails , $ this ->info ->getTrackingInfo ());
290
+ }
291
+
292
+ /**
293
+ * @return array
294
+ */
295
+ public function loadByHashWithTrackIdDataProvider ()
296
+ {
297
+ return [
298
+ [
299
+ 'hash ' => 'protected_code ' ,
300
+ 'protect_code ' => 'protected_code ' ,
301
+ 'number_detail ' => 'track_details ' ,
302
+ 'track_details ' => [['track_details ' ]],
303
+ ],
304
+ [
305
+ 'hash ' => '0 ' ,
306
+ 'protect_code ' => '0e6640 ' ,
307
+ 'number_detail ' => '' ,
308
+ 'track_details ' => [],
309
+ ],
310
+ ];
279
311
}
280
312
281
313
public function testLoadByHashWithWrongCode ()
0 commit comments