Skip to content

Commit a9e0cc5

Browse files
committed
ACP2E-1200: adjusted integration tests and implementation
1 parent 3c5adaa commit a9e0cc5

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

app/code/Magento/Quote/Plugin/SendOrderNotification.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public function beforeExecute(SubmitObserver $subject, Observer $observer): arra
4444
/** @var Order $order */
4545
$order = $observer->getEvent()->getOrder();
4646
$requestInfo = $this->request->getParam('order');
47-
$order->setCanSendNewEmailFlag((bool)($requestInfo['send_confirmation'] ?? 0));
47+
if (!empty($requestInfo)) {
48+
$order->setCanSendNewEmailFlag((bool)($requestInfo['send_confirmation'] ?? 0));
49+
}
4850

4951
return [$observer];
5052
}

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,31 @@ public function testSendEmailOnOrderSave(): void
145145
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $assert);
146146
}
147147

148+
/**
149+
* @magentoDbIsolation enabled
150+
* @magentoDataFixture Magento/Sales/_files/guest_quote_with_addresses.php
151+
*
152+
* @return void
153+
*/
154+
public function testNotSendEmailOnOrderSave(): void
155+
{
156+
$this->prepareRequest();
157+
$this->dispatch('backend/sales/order_create/save');
158+
$this->assertSessionMessages(
159+
$this->equalTo([(string)__('You created the order.')]),
160+
MessageInterface::TYPE_SUCCESS
161+
);
162+
163+
$this->assertRedirect($this->stringContains('sales/order/view/'));
164+
165+
$orderId = $this->getOrderId();
166+
if ($orderId === false) {
167+
$this->fail('Order is not created.');
168+
}
169+
170+
$this->assertNull($this->transportBuilder->getSentMessage());
171+
}
172+
148173
/**
149174
* Gets quote by reserved order id.
150175
*

dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,14 @@ public function testCreateOrderExistingCustomer()
644644

645645
$this->model->getQuote()->setCustomer($customerMock);
646646
$order = $this->model->createOrder();
647-
if ($this->model->getSendConfirmation() && !$order->getEmailSent()) {
647+
//to be deleted
648+
/* if ($this->model->getSendConfirmation() && !$order->getEmailSent()) {
648649
$this->emailSenderMock->expects($this->once())
649650
->method('send')
650651
->willReturn(true);
651652
} else {
652653
$this->emailSenderMock->expects($this->never())->method('send');
653-
}
654+
}*/
654655
$this->verifyCreatedOrder($order, $shippingMethod);
655656
}
656657

0 commit comments

Comments
 (0)