@@ -41,23 +41,23 @@ public function testAddConfigurableProductToCart()
41
41
42
42
$ quantity = 2 ;
43
43
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_1 ' );
44
- $ sku = $ product ['sku ' ];
44
+ $ parentSku = $ product ['sku ' ];
45
+ $ sku = 'simple_20 ' ;
45
46
$ attributeId = (int ) $ product ['configurable_options ' ][0 ]['attribute_id ' ];
46
47
$ optionId = $ product ['configurable_options ' ][0 ]['values ' ][1 ]['value_index ' ];
47
48
48
49
$ query = $ this ->getQuery (
49
50
$ maskedQuoteId ,
51
+ $ parentSku ,
50
52
$ sku ,
51
- $ attributeId ,
52
- $ optionId ,
53
53
$ quantity
54
54
);
55
55
56
56
$ response = $ this ->graphQlMutation ($ query );
57
57
58
58
$ cartItem = current ($ response ['addConfigurableProductsToCart ' ]['cart ' ]['items ' ]);
59
59
self ::assertEquals ($ quantity , $ cartItem ['quantity ' ]);
60
- self ::assertEquals ($ sku , $ cartItem ['product ' ]['sku ' ]);
60
+ self ::assertEquals ($ parentSku , $ cartItem ['product ' ]['sku ' ]);
61
61
self ::assertArrayHasKey ('configurable_options ' , $ cartItem );
62
62
63
63
$ option = current ($ cartItem ['configurable_options ' ]);
@@ -67,32 +67,6 @@ public function testAddConfigurableProductToCart()
67
67
self ::assertArrayHasKey ('value_label ' , $ option );
68
68
}
69
69
70
- /**
71
- * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
72
- * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
73
- * @expectedException \Exception
74
- * @expectedExceptionMessage You need to choose options for your item
75
- */
76
- public function testAddProductWithInvalidOptions ()
77
- {
78
- $ searchResponse = $ this ->graphQlQuery ($ this ->getFetchProductQuery ('configurable ' ));
79
- $ product = current ($ searchResponse ['products ' ]['items ' ]);
80
-
81
- $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_1 ' );
82
- $ sku = $ product ['sku ' ];
83
- $ attributeId = (int ) $ product ['configurable_options ' ][0 ]['attribute_id ' ];
84
-
85
- $ query = $ this ->getQuery (
86
- $ maskedQuoteId ,
87
- $ sku ,
88
- $ attributeId ,
89
- 9999 ,
90
- 1
91
- );
92
-
93
- $ this ->graphQlMutation ($ query );
94
- }
95
-
96
70
/**
97
71
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php
98
72
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
@@ -105,15 +79,13 @@ public function testAddProductIfQuantityIsNotAvailable()
105
79
$ product = current ($ searchResponse ['products ' ]['items ' ]);
106
80
107
81
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_order_1 ' );
108
- $ sku = $ product ['sku ' ];
109
- $ attributeId = (int ) $ product ['configurable_options ' ][0 ]['attribute_id ' ];
110
- $ optionId = $ product ['configurable_options ' ][0 ]['values ' ][1 ]['value_index ' ];
82
+ $ parentSku = $ product ['sku ' ];
83
+ $ sku = 'simple_20 ' ;
111
84
112
85
$ query = $ this ->getQuery (
113
86
$ maskedQuoteId ,
87
+ $ parentSku ,
114
88
$ sku ,
115
- $ attributeId ,
116
- $ optionId ,
117
89
2000
118
90
);
119
91
@@ -122,25 +94,20 @@ public function testAddProductIfQuantityIsNotAvailable()
122
94
123
95
/**
124
96
* @param string $maskedQuoteId
97
+ * @param string $parentSku
125
98
* @param string $sku
126
- * @param int $optionId
127
- * @param int $value
128
99
* @param int $quantity
129
100
* @return string
130
101
*/
131
- private function getQuery (string $ maskedQuoteId , string $ sku , int $ optionId , int $ value , int $ quantity ): string
102
+ private function getQuery (string $ maskedQuoteId , string $ parentSku , string $ sku , int $ quantity ): string
132
103
{
133
104
return <<<QUERY
134
105
mutation {
135
106
addConfigurableProductsToCart(
136
107
input:{
137
108
cart_id:" {$ maskedQuoteId }"
138
109
cart_items:{
139
- configurable_attributes:[{
140
- id: {$ optionId }
141
- value: {$ value }
142
- }
143
- ]
110
+ parent_sku: " {$ parentSku }"
144
111
data:{
145
112
sku:" {$ sku }"
146
113
quantity: {$ quantity }
0 commit comments