@@ -315,14 +315,20 @@ public function testAddProduct($productInfo, $requestInfo)
315
315
$ this ->productRepository ->expects ($ this ->any ())
316
316
->method ('getById ' )
317
317
->will ($ this ->returnValue ($ product ));
318
+
319
+ $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
320
+ 'checkout_cart_product_add_before ' ,
321
+ ['info ' => $ requestInfo , 'product ' => $ product ]
322
+ );
323
+
318
324
$ this ->quoteMock ->expects ($ this ->once ())
319
325
->method ('addProduct ' )
320
326
->will ($ this ->returnValue (1 ));
321
327
$ this ->checkoutSessionMock ->expects ($ this ->once ())
322
328
->method ('getQuote ' )
323
329
->will ($ this ->returnValue ($ this ->quoteMock ));
324
330
325
- $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
331
+ $ this ->eventManagerMock ->expects ($ this ->at (1 ))->method ('dispatch ' )->with (
326
332
'checkout_cart_product_add_after ' ,
327
333
['quote_item ' => 1 , 'product ' => $ product ]
328
334
);
@@ -360,6 +366,12 @@ public function testAddProductException()
360
366
$ this ->productRepository ->expects ($ this ->any ())
361
367
->method ('getById ' )
362
368
->will ($ this ->returnValue ($ product ));
369
+
370
+ $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
371
+ 'checkout_cart_product_add_before ' ,
372
+ ['info ' => 4 , 'product ' => $ product ]
373
+ );
374
+
363
375
$ this ->quoteMock ->expects ($ this ->once ())
364
376
->method ('addProduct ' )
365
377
->will ($ this ->returnValue ('error ' ));
@@ -396,6 +408,11 @@ public function testAddProductExceptionBadParams()
396
408
->method ('getById ' )
397
409
->will ($ this ->returnValue ($ product ));
398
410
411
+ $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
412
+ 'checkout_cart_product_add_before ' ,
413
+ ['info ' => 'bad ' , 'product ' => $ product ]
414
+ );
415
+
399
416
$ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
400
417
'checkout_cart_product_add_after ' ,
401
418
['quote_item ' => 1 , 'product ' => $ product ]
0 commit comments