@@ -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,17 +369,19 @@ public function testAddProductException()
363369 $ this ->productRepository ->expects ($ this ->any ())
364370 ->method ('getById ' )
365371 ->will ($ this ->returnValue ($ product ));
372+
373+ $ this ->eventManagerMock ->expects ($ this ->once ())->method ('dispatch ' )->with (
374+ 'checkout_cart_product_add_before ' ,
375+ ['info ' => 4 , 'product ' => $ product ]
376+ );
377+
366378 $ this ->quoteMock ->expects ($ this ->once ())
367379 ->method ('addProduct ' )
368380 ->will ($ this ->returnValue ('error ' ));
369381 $ this ->checkoutSessionMock ->expects ($ this ->once ())
370382 ->method ('getQuote ' )
371383 ->will ($ this ->returnValue ($ this ->quoteMock ));
372384
373- $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
374- 'checkout_cart_product_add_after ' ,
375- ['quote_item ' => 1 , 'product ' => $ product ]
376- );
377385 $ this ->expectException (\Magento \Framework \Exception \LocalizedException::class);
378386 $ this ->cart ->addProduct (4 , 4 );
379387 }
@@ -399,6 +407,11 @@ public function testAddProductExceptionBadParams()
399407 ->method ('getById ' )
400408 ->will ($ this ->returnValue ($ product ));
401409
410+ $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
411+ 'checkout_cart_product_add_before ' ,
412+ ['info ' => 'bad ' , 'product ' => $ product ]
413+ );
414+
402415 $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
403416 'checkout_cart_product_add_after ' ,
404417 ['quote_item ' => 1 , 'product ' => $ product ]
0 commit comments