77
88namespace Magento \GraphQl \Sales ;
99
10+ use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
11+ use Magento \ConfigurableProduct \Test \Fixture \AddProductToCart as AddConfigurableProductToCartFixture ;
12+ use Magento \NegotiableQuote \Test \Fixture \QuoteIdMask ;
13+ use Magento \Checkout \Test \Fixture \PlaceOrder as PlaceOrderFixture ;
14+ use Magento \Checkout \Test \Fixture \SetBillingAddress as SetBillingAddressFixture ;
15+ use Magento \Checkout \Test \Fixture \SetDeliveryMethod as SetDeliveryMethodFixture ;
16+ use Magento \Checkout \Test \Fixture \SetPaymentMethod as SetPaymentMethodFixture ;
17+ use Magento \Checkout \Test \Fixture \SetShippingAddress as SetShippingAddressFixture ;
18+ use Magento \ConfigurableProduct \Test \Fixture \Attribute as AttributeFixture ;
19+ use Magento \ConfigurableProduct \Test \Fixture \Product as ConfigurableProductFixture ;
20+ use Magento \Customer \Test \Fixture \Customer ;
1021use Magento \Framework \Exception \AuthenticationException ;
1122use Magento \GraphQl \GetCustomerAuthenticationHeader ;
23+ use Magento \Quote \Test \Fixture \CustomerCart ;
24+ use Magento \TestFramework \Fixture \DataFixture ;
25+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
1226use Magento \TestFramework \Helper \Bootstrap ;
1327use Magento \TestFramework \TestCase \GraphQlAbstract ;
1428
@@ -29,31 +43,59 @@ protected function setUp(): void
2943 $ this ->customerAuthenticationHeader = $ objectManager ->get (GetCustomerAuthenticationHeader::class);
3044 }
3145
32- /**
33- * Test customer order details with configurable product with child items
34- *
35- * @magentoApiDataFixture Magento/Customer/_files/customer.php
36- * @magentoApiDataFixture Magento/Sales/_files/customer_order_with_configurable_product.php
37- */
46+ #[
47+ DataFixture(Customer::class, ['email ' => 'customer@example.com ' ], as: 'customer ' ),
48+ DataFixture(ProductFixture::class, as: 'product ' ),
49+ DataFixture(AttributeFixture::class, as: 'attribute ' ),
50+ DataFixture(
51+ ConfigurableProductFixture::class,
52+ ['_options ' => ['$attribute$ ' ], '_links ' => ['$product$ ' ]],
53+ 'configurable_product '
54+ ),
55+ DataFixture(
56+ CustomerCart::class,
57+ [
58+ 'customer_id ' => '$customer.id$ '
59+ ],
60+ 'quote '
61+ ),
62+ DataFixture(QuoteIdMask::class, ['cart_id ' => '$quote.id$ ' ], 'quoteIdMask ' ),
63+ DataFixture(
64+ AddConfigurableProductToCartFixture::class,
65+ [
66+ 'cart_id ' => '$quote.id$ ' ,
67+ 'product_id ' => '$configurable_product.id$ ' ,
68+ 'child_product_id ' => '$product.id$ ' ,
69+ 'qty ' => 1
70+ ],
71+ ),
72+ DataFixture(SetBillingAddressFixture::class, ['cart_id ' => '$quote.id$ ' ]),
73+ DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$quote.id$ ' ]),
74+ DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$quote.id$ ' ]),
75+ DataFixture(SetPaymentMethodFixture::class, ['cart_id ' => '$quote.id$ ' ]),
76+ DataFixture(PlaceOrderFixture::class, ['cart_id ' => '$quote.id$ ' ], 'order ' ),
77+ ]
3878 public function testGetCustomerOrderConfigurableProduct (): void
3979 {
40- $ orderNumber = '100000001 ' ;
80+ $ order = DataFixtureStorageManager::getStorage ()->get ('order ' );
81+ $ orderNumber = $ order ->getIncrementId ();
82+ $ product = DataFixtureStorageManager::getStorage ()->get ('product ' );
83+ $ configurableProduct = DataFixtureStorageManager::getStorage ()->get ('configurable_product ' );
4184 $ customerOrderResponse = $ this ->getCustomerOrderQueryConfigurableProduct ($ orderNumber );
4285 $ customerOrderItems = $ customerOrderResponse [0 ];
43- $ this ->assertEquals ('Pending Payment ' , $ customerOrderItems ['status ' ]);
4486 $ configurableItemInTheOrder = $ customerOrderItems ['items ' ][0 ];
4587 $ this ->assertEquals (
46- ' simple_10 ' ,
88+ $ product -> getSku () ,
4789 $ configurableItemInTheOrder ['product_sku ' ]
4890 );
4991
5092 $ expectedConfigurableOptions = [
5193 '__typename ' => 'ConfigurableOrderItem ' ,
52- 'product_sku ' => ' simple_10 ' ,
53- 'product_name ' => ' Configurable Product ' ,
54- 'parent_sku ' => ' configurable ' ,
55- 'product_url_key ' => ' configurable-product ' ,
56- 'quantity_ordered ' => 2
94+ 'product_sku ' => $ product -> getSku () ,
95+ 'product_name ' => $ configurableProduct -> getName () ,
96+ 'parent_sku ' => $ configurableProduct -> getSku () ,
97+ 'product_url_key ' => $ configurableProduct -> getUrlKey () ,
98+ 'quantity_ordered ' => 1
5799 ];
58100 $ this ->assertEquals ($ expectedConfigurableOptions , $ configurableItemInTheOrder );
59101 }
0 commit comments