7
7
8
8
namespace Magento \GraphQl \Sales ;
9
9
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 ;
10
21
use Magento \Framework \Exception \AuthenticationException ;
11
22
use Magento \GraphQl \GetCustomerAuthenticationHeader ;
23
+ use Magento \Quote \Test \Fixture \CustomerCart ;
24
+ use Magento \TestFramework \Fixture \DataFixture ;
25
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
12
26
use Magento \TestFramework \Helper \Bootstrap ;
13
27
use Magento \TestFramework \TestCase \GraphQlAbstract ;
14
28
@@ -29,31 +43,59 @@ protected function setUp(): void
29
43
$ this ->customerAuthenticationHeader = $ objectManager ->get (GetCustomerAuthenticationHeader::class);
30
44
}
31
45
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
+ ]
38
78
public function testGetCustomerOrderConfigurableProduct (): void
39
79
{
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 ' );
41
84
$ customerOrderResponse = $ this ->getCustomerOrderQueryConfigurableProduct ($ orderNumber );
42
85
$ customerOrderItems = $ customerOrderResponse [0 ];
43
- $ this ->assertEquals ('Pending Payment ' , $ customerOrderItems ['status ' ]);
44
86
$ configurableItemInTheOrder = $ customerOrderItems ['items ' ][0 ];
45
87
$ this ->assertEquals (
46
- ' simple_10 ' ,
88
+ $ product -> getSku () ,
47
89
$ configurableItemInTheOrder ['product_sku ' ]
48
90
);
49
91
50
92
$ expectedConfigurableOptions = [
51
93
'__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
57
99
];
58
100
$ this ->assertEquals ($ expectedConfigurableOptions , $ configurableItemInTheOrder );
59
101
}
0 commit comments