@@ -318,14 +318,20 @@ public function testAddProduct($productInfo, $requestInfo)
318318 $ this ->productRepository ->expects ($ this ->any ())
319319 ->method ('getById ' )
320320 ->will ($ this ->returnValue ($ product ));
321+
322+ $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
323+ 'checkout_cart_product_add_before ' ,
324+ ['info ' => $ requestInfo , 'product ' => $ product ]
325+ );
326+
321327 $ this ->quoteMock ->expects ($ this ->once ())
322328 ->method ('addProduct ' )
323329 ->will ($ this ->returnValue (1 ));
324330 $ this ->checkoutSessionMock ->expects ($ this ->once ())
325331 ->method ('getQuote ' )
326332 ->will ($ this ->returnValue ($ this ->quoteMock ));
327333
328- $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
334+ $ this ->eventManagerMock ->expects ($ this ->at (1 ))->method ('dispatch ' )->with (
329335 'checkout_cart_product_add_after ' ,
330336 ['quote_item ' => 1 , 'product ' => $ product ]
331337 );
@@ -363,6 +369,10 @@ public function testAddProductException()
363369 $ this ->productRepository ->expects ($ this ->any ())
364370 ->method ('getById ' )
365371 ->will ($ this ->returnValue ($ product ));
372+ $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
373+ 'checkout_cart_product_add_before ' ,
374+ ['info ' => 4 , 'product ' => $ product ]
375+ );
366376 $ this ->quoteMock ->expects ($ this ->once ())
367377 ->method ('addProduct ' )
368378 ->will ($ this ->returnValue ('error ' ));
@@ -399,6 +409,11 @@ public function testAddProductExceptionBadParams()
399409 ->method ('getById ' )
400410 ->will ($ this ->returnValue ($ product ));
401411
412+ $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
413+ 'checkout_cart_product_add_before ' ,
414+ ['info ' => 'bad ' , 'product ' => $ product ]
415+ );
416+
402417 $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
403418 'checkout_cart_product_add_after ' ,
404419 ['quote_item ' => 1 , 'product ' => $ product ]
0 commit comments