1010use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
1111use Magento \Checkout \Test \Fixture \SetBillingAddress as SetBillingAddressFixture ;
1212use Magento \Checkout \Test \Fixture \SetDeliveryMethod as SetDeliveryMethodFixture ;
13+ use Magento \Checkout \Test \Fixture \SetGuestEmail as SetGuestEmailFixture ;
1314use Magento \Checkout \Test \Fixture \SetPaymentMethod as SetPaymentMethodFixture ;
1415use Magento \Checkout \Test \Fixture \SetShippingAddress as SetShippingAddressFixture ;
1516use Magento \Customer \Test \Fixture \Customer as CustomerFixture ;
2223use Magento \InventorySalesApi \Test \Fixture \StockSalesChannels as StockSalesChannelsFixture ;
2324use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
2425use Magento \Quote \Test \Fixture \CustomerCart as CustomerCartFixture ;
26+ use Magento \Quote \Test \Fixture \GuestCart as GuestCartFixture ;
2527use Magento \Quote \Test \Fixture \QuoteIdMask ;
2628use Magento \TestFramework \Fixture \DataFixture ;
2729use Magento \TestFramework \Fixture \DataFixtureStorage ;
3436 *
3537 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3638 */
37- class PreventOversellingDuringConcurrentOrdersTest extends GraphQlAbstract
39+ class OrderPlacementTest extends GraphQlAbstract
3840{
3941 /**
4042 * @var DataFixtureStorage
@@ -251,14 +253,34 @@ public function testMultipleOrdersSucceedWithSufficientQuantity(): void
251253 $ this ->assertArrayHasKey ('order_number ' , $ response2 ['placeOrder ' ]['order ' ]);
252254 }
253255
256+ #[
257+ DataFixture(ProductFixture::class, ['sku ' => '4669 ' ], as: 'product ' ),
258+ DataFixture(GuestCartFixture::class, as: 'cart ' ),
259+ DataFixture(QuoteIdMask::class, ['cart_id ' => '$cart.id$ ' ], as: 'cartMask ' ),
260+ DataFixture(AddProductToCartFixture::class, ['cart_id ' => '$cart.id$ ' , 'product_id ' => '$product.id$ ' ]),
261+ DataFixture(SetBillingAddressFixture::class, ['cart_id ' => '$cart.id$ ' ]),
262+ DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$cart.id$ ' ]),
263+ DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
264+ DataFixture(SetGuestEmailFixture::class, ['cart_id ' => '$cart.id$ ' ]),
265+ DataFixture(SetPaymentMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
266+ ]
267+ public function testPlaceOrderWithNumericSku (): void
268+ {
269+ $ response = $ this ->placeOrder ($ this ->fixtures ->get ('cartMask ' )->getMaskedId ());
270+ $ this ->assertArrayHasKey ('placeOrder ' , $ response );
271+ $ this ->assertArrayHasKey ('order ' , $ response ['placeOrder ' ]);
272+ $ this ->assertArrayHasKey ('order_number ' , $ response ['placeOrder ' ]['order ' ]);
273+ $ this ->assertNotEmpty ($ response ['placeOrder ' ]['order ' ]['order_number ' ]);
274+ }
275+
254276 /**
255277 * Place order via GraphQL mutation
256278 *
257279 * @param string $maskedCartId
258- * @param string $customerToken
280+ * @param string|null $customerToken
259281 * @return array
260282 */
261- private function placeOrder (string $ maskedCartId , string $ customerToken ): array
283+ private function placeOrder (string $ maskedCartId , ? string $ customerToken = null ): array
262284 {
263285 $ query = <<<QUERY
264286mutation {
@@ -274,7 +296,7 @@ private function placeOrder(string $maskedCartId, string $customerToken): array
274296 $ query ,
275297 [],
276298 '' ,
277- ['Authorization ' => 'Bearer ' . $ customerToken ]
299+ $ customerToken ? ['Authorization ' => 'Bearer ' . $ customerToken] : [ ]
278300 );
279301 }
280302}
0 commit comments