9
9
10
10
use Magento \Config \Model \ResourceModel \Config ;
11
11
use Magento \Framework \App \Config \ReinitableConfigInterface ;
12
+ use Magento \Catalog \Api \ProductRepositoryInterface ;
12
13
use Magento \Framework \App \Config \ScopeConfigInterface ;
13
14
use Magento \TestFramework \ObjectManager ;
14
15
use Magento \TestFramework \TestCase \GraphQlAbstract ;
19
20
*/
20
21
class ProductOnlyXLeftInStockTest extends GraphQlAbstract
21
22
{
23
+ /**
24
+ * @var ProductRepositoryInterface
25
+ */
26
+ private $ productRepository ;
22
27
/**
23
28
* @var Config $config
24
29
*/
@@ -42,6 +47,7 @@ protected function setUp(): void
42
47
parent ::setUp ();
43
48
44
49
$ objectManager = ObjectManager::getInstance ();
50
+ $ this ->productRepository = $ objectManager ->create (ProductRepositoryInterface::class);
45
51
$ this ->resourceConfig = $ objectManager ->get (Config::class);
46
52
$ this ->scopeConfig = $ objectManager ->get (ScopeConfigInterface::class);
47
53
$ this ->reinitConfig = $ objectManager ->get (ReinitableConfigInterface::class);
@@ -106,13 +112,13 @@ public function testQueryProductOnlyXLeftInStockOutstock()
106
112
$ productSku = 'simple ' ;
107
113
$ showOutOfStock = $ this ->scopeConfig ->getValue (Configuration::XML_PATH_SHOW_OUT_OF_STOCK );
108
114
109
- $ this ->resourceConfig ->saveConfig (
110
- \Magento \CatalogInventory \Model \Configuration::XML_PATH_SHOW_OUT_OF_STOCK ,
111
- 1 ,
112
- ScopeConfigInterface::SCOPE_TYPE_DEFAULT
113
- );
115
+ $ this ->resourceConfig ->saveConfig (Configuration::XML_PATH_SHOW_OUT_OF_STOCK , 1 );
114
116
$ this ->reinitConfig ->reinit ();
115
117
118
+ // need to resave product to reindex it with new configuration.
119
+ $ product = $ this ->productRepository ->get ($ productSku );
120
+ $ this ->productRepository ->save ($ product );
121
+
116
122
$ query = <<<QUERY
117
123
{
118
124
products(filter: {sku: {eq: " {$ productSku }"}})
0 commit comments