objectManager = Bootstrap::getObjectManager(); $this->transportBuilder = $this->objectManager->get(TransportBuilderMock::class); $this->quoteIdMaskFactory = $this->objectManager->get(QuoteIdMaskFactory::class); $this->formKey = $this->objectManager->get(FormKey::class); } /** * @magentoDataFixture Magento/Sales/_files/guest_quote_with_addresses.php * @return void */ public function testSendEmailOnOrderPlace(): void { /** @var Quote $quote */ $quote = $this->objectManager->create(Quote::class); $quote->load('guest_quote', 'reserved_order_id'); $checkoutSession = $this->objectManager->get(CheckoutSession::class); $checkoutSession->setQuoteId($quote->getId()); /** @var QuoteIdMask $quoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create(); $quoteIdMask->load($quote->getId(), 'quote_id'); $cartId = $quoteIdMask->getMaskedId(); /** @var GuestCartManagementInterface $cartManagement */ $cartManagement = $this->objectManager->get(GuestCartManagementInterface::class); $orderId = $cartManagement->placeOrder($cartId); $order = $this->objectManager->get(OrderRepository::class)->get($orderId); $message = $this->transportBuilder->getSentMessage(); $subject = __('Your %1 order confirmation', $order->getStore()->getFrontendName())->render(); $assert = $this->logicalAnd( new StringContains($order->getBillingAddress()->getName()), new StringContains( 'Thank you for your order from ' . $order->getStore()->getFrontendName() ), new StringContains( "Your Order #{$order->getIncrementId()}" ) ); $this->assertEquals($message->getSubject(), $subject); $this->assertThat($message->getRawMessage(), $assert); } }