@@ -315,14 +315,20 @@ public function testAddProduct($productInfo, $requestInfo)
315315 $ this ->productRepository ->expects ($ this ->any ())
316316 ->method ('getById ' )
317317 ->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+
318324 $ this ->quoteMock ->expects ($ this ->once ())
319325 ->method ('addProduct ' )
320326 ->will ($ this ->returnValue (1 ));
321327 $ this ->checkoutSessionMock ->expects ($ this ->once ())
322328 ->method ('getQuote ' )
323329 ->will ($ this ->returnValue ($ this ->quoteMock ));
324330
325- $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
331+ $ this ->eventManagerMock ->expects ($ this ->at (1 ))->method ('dispatch ' )->with (
326332 'checkout_cart_product_add_after ' ,
327333 ['quote_item ' => 1 , 'product ' => $ product ]
328334 );
@@ -360,6 +366,12 @@ public function testAddProductException()
360366 $ this ->productRepository ->expects ($ this ->any ())
361367 ->method ('getById ' )
362368 ->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+
363375 $ this ->quoteMock ->expects ($ this ->once ())
364376 ->method ('addProduct ' )
365377 ->will ($ this ->returnValue ('error ' ));
@@ -396,6 +408,11 @@ public function testAddProductExceptionBadParams()
396408 ->method ('getById ' )
397409 ->will ($ this ->returnValue ($ product ));
398410
411+ $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
412+ 'checkout_cart_product_add_before ' ,
413+ ['info ' => 'bad ' , 'product ' => $ product ]
414+ );
415+
399416 $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
400417 'checkout_cart_product_add_after ' ,
401418 ['quote_item ' => 1 , 'product ' => $ product ]
0 commit comments