@@ -318,14 +318,20 @@ public function testAddProduct($productInfo, $requestInfo)
318
318
$ this ->productRepository ->expects ($ this ->any ())
319
319
->method ('getById ' )
320
320
->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
+
321
327
$ this ->quoteMock ->expects ($ this ->once ())
322
328
->method ('addProduct ' )
323
329
->will ($ this ->returnValue (1 ));
324
330
$ this ->checkoutSessionMock ->expects ($ this ->once ())
325
331
->method ('getQuote ' )
326
332
->will ($ this ->returnValue ($ this ->quoteMock ));
327
333
328
- $ this ->eventManagerMock ->expects ($ this ->at (0 ))->method ('dispatch ' )->with (
334
+ $ this ->eventManagerMock ->expects ($ this ->at (1 ))->method ('dispatch ' )->with (
329
335
'checkout_cart_product_add_after ' ,
330
336
['quote_item ' => 1 , 'product ' => $ product ]
331
337
);
@@ -363,17 +369,19 @@ public function testAddProductException()
363
369
$ this ->productRepository ->expects ($ this ->any ())
364
370
->method ('getById ' )
365
371
->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
+
366
378
$ this ->quoteMock ->expects ($ this ->once ())
367
379
->method ('addProduct ' )
368
380
->will ($ this ->returnValue ('error ' ));
369
381
$ this ->checkoutSessionMock ->expects ($ this ->once ())
370
382
->method ('getQuote ' )
371
383
->will ($ this ->returnValue ($ this ->quoteMock ));
372
384
373
- $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
374
- 'checkout_cart_product_add_after ' ,
375
- ['quote_item ' => 1 , 'product ' => $ product ]
376
- );
377
385
$ this ->expectException (\Magento \Framework \Exception \LocalizedException::class);
378
386
$ this ->cart ->addProduct (4 , 4 );
379
387
}
@@ -399,6 +407,11 @@ public function testAddProductExceptionBadParams()
399
407
->method ('getById ' )
400
408
->will ($ this ->returnValue ($ product ));
401
409
410
+ $ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
411
+ 'checkout_cart_product_add_before ' ,
412
+ ['info ' => 'bad ' , 'product ' => $ product ]
413
+ );
414
+
402
415
$ this ->eventManagerMock ->expects ($ this ->never ())->method ('dispatch ' )->with (
403
416
'checkout_cart_product_add_after ' ,
404
417
['quote_item ' => 1 , 'product ' => $ product ]
0 commit comments