1111use Magento \Checkout \Test \Fixture \PlaceOrder as PlaceOrderFixture ;
1212use Magento \Checkout \Test \Fixture \SetBillingAddress as SetBillingAddressFixture ;
1313use Magento \Checkout \Test \Fixture \SetDeliveryMethod as SetDeliveryMethodFixture ;
14- use Magento \Checkout \Test \Fixture \SetGuestEmail as SetGuestEmailFixture ;
1514use Magento \Checkout \Test \Fixture \SetPaymentMethod as SetPaymentMethodFixture ;
1615use Magento \Checkout \Test \Fixture \SetShippingAddress as SetShippingAddressFixture ;
16+ use Magento \Customer \Test \Fixture \Customer as CustomerFixture ;
1717use Magento \Framework \App \Area ;
1818use Magento \Framework \Exception \LocalizedException ;
1919use Magento \Framework \Mail \EmailMessageInterface ;
2020use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
21- use Magento \Quote \Test \Fixture \GuestCart as GuestCartFixture ;
21+ use Magento \Quote \Test \Fixture \CustomerCart as CustomerCartFixture ;
2222use Magento \TestFramework \Fixture \Config ;
2323use Magento \TestFramework \Fixture \DataFixture ;
2424use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
3232 */
3333class AdminOrderAsyncEmailTest extends TestCase
3434{
35+ /**
36+ * Customer email address for async order notification testing
37+ */
38+ private const CUSTOMER_EMAIL = 'async-customer@example.com ' ;
39+
3540 /**
3641 * @var TransportBuilderMock
3742 */
@@ -57,6 +62,7 @@ function (EmailMessageInterface $message): void {
5762
5863 /**
5964 * Verifies that an order email is dispatched only after the async cron job runs.
65+ * Uses a registered customer with accessible email as per test preconditions.
6066 *
6167 * @return void
6268 * @throws LocalizedException
@@ -67,12 +73,12 @@ function (EmailMessageInterface $message): void {
6773 Config('sales_email/general/async_sending ' , '1 ' ),
6874 Config('sales_email/order/enabled ' , '1 ' ),
6975 Config('sales_email/general/sending_limit ' , '10 ' ),
76+ DataFixture(CustomerFixture::class, ['email ' => 'async-customer@example.com ' ], as: 'customer ' ),
7077 DataFixture(ProductFixture::class, as: 'product ' ),
71- DataFixture(GuestCartFixture ::class, as: 'cart ' ),
78+ DataFixture(CustomerCartFixture ::class, [ ' customer_id ' => ' $customer.id$ ' ] , as: 'cart ' ),
7279 DataFixture(AddProductToCartFixture::class, ['cart_id ' => '$cart.id$ ' , 'product_id ' => '$product.id$ ' ]),
7380 DataFixture(SetBillingAddressFixture::class, ['cart_id ' => '$cart.id$ ' ]),
7481 DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$cart.id$ ' ]),
75- DataFixture(SetGuestEmailFixture::class, ['cart_id ' => '$cart.id$ ' , 'email ' => 'async-customer@example.com ' ]),
7682 DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
7783 DataFixture(SetPaymentMethodFixture::class, ['cart_id ' => '$cart.id$ ' , 'method ' => 'checkmo ' ]),
7884 DataFixture(PlaceOrderFixture::class, ['cart_id ' => '$cart.id$ ' ], 'order ' ),
@@ -124,7 +130,7 @@ public function testAsynchronousOrderEmailDispatchedByCron(): void
124130 'Order confirmation subject should contain the word "Order". '
125131 );
126132 $ this ->assertEquals (
127- ' async-customer@example.com ' ,
133+ self :: CUSTOMER_EMAIL ,
128134 $ email ->getTo ()[0 ]->getEmail (),
129135 'Email should be addressed to the customer used during checkout. '
130136 );
0 commit comments