@@ -54,8 +54,8 @@ protected function setUp(): void
5454 $ this ->objectManager = Bootstrap::getObjectManager ();
5555 $ this ->messageManager = $ this ->objectManager ->get (ManagerInterface::class);
5656 $ this ->emailSenderMock = $ this ->getMockBuilder (EmailSender::class)
57- ->disableOriginalConstructor ()
58- ->getMock ();
57+ ->disableOriginalConstructor ()
58+ ->getMock ();
5959 $ this ->model =$ this ->objectManager ->create (
6060 Create::class,
6161 ['messageManager ' => $ this ->messageManager , 'emailSender ' => $ this ->emailSenderMock ]
@@ -612,11 +612,8 @@ public function testCreateOrderExistingCustomerDifferentAddresses()
612612 * @magentoDataFixture Magento/Customer/_files/customer.php
613613 * @magentoDbIsolation disabled
614614 * @magentoAppIsolation enabled
615- * @dataProvider emailCheckProvider
616- * @param bool $sendConfirmation
617- * @param bool $emailSent
618615 */
619- public function testCreateOrderExistingCustomer ($ sendConfirmation , $ emailSent )
616+ public function testCreateOrderExistingCustomer ()
620617 {
621618 $ productIdFromFixture = 1 ;
622619 $ customerIdFromFixture = 1 ;
@@ -629,8 +626,7 @@ public function testCreateOrderExistingCustomer($sendConfirmation, $emailSent)
629626 'billing_address ' => array_merge ($ this ->getValidAddressData (), ['save_in_address_book ' => '1 ' ]),
630627 'shipping_method ' => $ shippingMethod ,
631628 'comment ' => ['customer_note ' => '' ],
632- 'send_confirmation ' => $ sendConfirmation ,
633- 'email_sent ' => $ emailSent ,
629+ 'send_confirmation ' => false ,
634630 ];
635631 $ paymentData = ['method ' => $ paymentMethod ];
636632
@@ -645,32 +641,12 @@ public function testCreateOrderExistingCustomer($sendConfirmation, $emailSent)
645641 $ customerIdFromFixture
646642 );
647643 $ customerMock = $ this ->getMockedCustomer ();
648- if ($ customerIdFromFixture && !$ emailSent ) {
649- $ this ->emailSenderMock ->expects ($ this ->once ())
650- ->method ('send ' )
651- ->willReturn (true );
652- } else {
653- $ this ->emailSenderMock ->expects ($ this ->never ())->method ('send ' );
654- }
655644
656645 $ this ->model ->getQuote ()->setCustomer ($ customerMock );
657646 $ order = $ this ->model ->createOrder ();
658647 $ this ->verifyCreatedOrder ($ order , $ shippingMethod );
659648 }
660649
661- /**
662- * Data provider for testApplySelectionOnTargetProvider.
663- *
664- * @return array
665- */
666- public function emailCheckProvider (): array
667- {
668- return [
669- [false , true ],
670- [true , false ]
671- ];
672- }
673-
674650 /**
675651 * @magentoDataFixture Magento/Sales/_files/quote.php
676652 * @magentoDataFixture Magento/Customer/_files/customer.php
@@ -850,6 +826,13 @@ private function verifyCreatedOrder($order, $shippingMethod)
850826 {
851827 /** Selectively check order data */
852828 $ orderData = $ order ->getData ();
829+ if (!$ order ->getEmailSent ()) {
830+ $ this ->emailSenderMock ->expects ($ this ->once ())
831+ ->method ('send ' )
832+ ->willReturn (true );
833+ } else {
834+ $ this ->emailSenderMock ->expects ($ this ->never ())->method ('send ' );
835+ }
853836 self ::assertNotEmpty ($ orderData ['increment_id ' ], 'Order increment ID is empty. ' );
854837 self ::assertEquals ($ this ->model ->getQuote ()->getId (), $ orderData ['quote_id ' ], 'Quote ID is invalid. ' );
855838 self ::assertEquals (
0 commit comments