Skip to content

Commit f0ea57e

Browse files
committed
29251 test web-api test fix
1 parent 150a818 commit f0ea57e

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

app/code/Magento/ConfigurableProductGraphQl/etc/graphql/di.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<plugin name="used_products_cache_graphql" type="Magento\ConfigurableProduct\Model\Plugin\Frontend\UsedProductsCache" />
4949
</type>
5050

51-
<type name="Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface">
52-
<plugin name="Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder_GraphQl" type="Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder"/>
53-
</type>
51+
<!-- <type name="Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface">-->
52+
<!-- <plugin name="Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder_GraphQl" type="Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder"/>-->
53+
<!-- </type>-->
5454
</config>

dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartSingleMutationTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
namespace Magento\GraphQl\ConfigurableProduct;
99

1010
use Exception;
11+
use Magento\Config\Model\ResourceModel\Config;
12+
use Magento\Framework\App\Config\ReinitableConfigInterface;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
1114
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
1215
use Magento\TestFramework\Helper\Bootstrap;
1316
use Magento\TestFramework\TestCase\GraphQlAbstract;
17+
use Magento\CatalogInventory\Model\Configuration;
1418

1519
/**
1620
* Add configurable product to cart testcases
@@ -22,13 +26,31 @@ class AddConfigurableProductToCartSingleMutationTest extends GraphQlAbstract
2226
*/
2327
private $getMaskedQuoteIdByReservedOrderId;
2428

29+
/**
30+
* @var Config $config
31+
*/
32+
private $resourceConfig;
33+
34+
/**
35+
* @var ScopeConfigInterface
36+
*/
37+
private $scopeConfig;
38+
39+
/**
40+
* @var ReinitableConfigInterface
41+
*/
42+
private $reinitConfig;
43+
2544
/**
2645
* @inheritdoc
2746
*/
2847
protected function setUp(): void
2948
{
3049
$objectManager = Bootstrap::getObjectManager();
3150
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
51+
$this->resourceConfig = $objectManager->get(Config::class);
52+
$this->scopeConfig = $objectManager->get(ScopeConfigInterface::class);
53+
$this->reinitConfig = $objectManager->get(ReinitableConfigInterface::class);
3254
}
3355

3456
/**
@@ -166,9 +188,20 @@ public function testAddNonExistentConfigurableProductParentToCart()
166188
*/
167189
public function testOutOfStockVariationToCart()
168190
{
191+
$showOutOfStock = $this->scopeConfig->getValue(Configuration::XML_PATH_SHOW_OUT_OF_STOCK);
192+
193+
// Changing SHOW_OUT_OF_STOCK to show the out of stock option, otherwise graphql won't display it.
194+
$this->resourceConfig->saveConfig(Configuration::XML_PATH_SHOW_OUT_OF_STOCK, 1);
195+
$this->reinitConfig->reinit();
196+
169197
$product = $this->getConfigurableProductInfo();
170198
$attributeId = (int) $product['configurable_options'][0]['attribute_id'];
171199
$valueIndex = $product['configurable_options'][0]['values'][0]['value_index'];
200+
// Asserting that the first value is the right option we want to add to cart
201+
$this->assertEquals(
202+
$product['configurable_options'][0]['values'][0]['label'],
203+
'Option 1'
204+
);
172205
$parentSku = $product['sku'];
173206

174207
$configurableOptionsQuery = $this->generateSuperAttributesUIDQuery($attributeId, $valueIndex);
@@ -191,6 +224,8 @@ public function testOutOfStockVariationToCart()
191224
$response['addProductsToCart']['user_errors'][0]['message'],
192225
$expectedErrorMessages
193226
);
227+
$this->resourceConfig->saveConfig(Configuration::XML_PATH_SHOW_OUT_OF_STOCK, $showOutOfStock);
228+
$this->reinitConfig->reinit();
194229
}
195230

196231
/**

0 commit comments

Comments
 (0)