Skip to content

Commit

Permalink
Fix set config values without configFixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazar65 committed Jun 15, 2019
1 parent 875647e commit aaf6dc8
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions app/code/Magento/InventoryGraphQl/Test/Api/OnlyXLeftTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@ class OnlyXLeftTest extends GraphQlAbstract
protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
$preparedValueFactory = $this->objectManager->get(\Magento\Config\Model\PreparedValueFactory::class);
$resource = $this->objectManager->get(\Magento\Config\Model\ResourceModel\Config\Data::class);
$value = $preparedValueFactory->create(
'cataloginventory/options/stock_threshold_qty',
99,
'default',
0
);
$resource->save($value);
$reinitableConfig = $this->objectManager->create(
\Magento\Framework\App\Config\ReinitableConfigInterface::class
);
$reinitableConfig->reinit();
}

/**
* Verify "Only x left" after order placement on default stock, main website.
*
* @magentoConfigFixture default_store cataloginventory/options/stock_threshold_qty 99
* @magentoApiDataFixture Magento/Checkout/_files/simple_product.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_default_source.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/create_quote_on_default_website.php
Expand Down Expand Up @@ -67,7 +79,6 @@ public function testOnlyXLeftDefaultStockMainWebsite()
/**
* Verify "Only x left" after order placement on default stock, additional website.
*
* @magentoConfigFixture store_for_eu_website_store cataloginventory/options/stock_threshold_qty 99
* @magentoApiDataFixture Magento/Checkout/_files/simple_product.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_default_source.php
Expand Down Expand Up @@ -100,7 +111,6 @@ public function testOnlyXLeftDefaultStockAdditionalWebsite()
/**
* Verify "Only x left" after order placement on additional stock, main website.
*
* @magentoConfigFixture default_store cataloginventory/options/stock_threshold_qty 99
* @magentoApiDataFixture Magento/Checkout/_files/simple_product.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php
Expand Down Expand Up @@ -134,7 +144,6 @@ public function testOnlyXLeftAdditionalStockMainWebsite()
/**
* Verify "Only x left" after order placement on additional stock, additional website.
*
* @magentoConfigFixture default_store cataloginventory/options/stock_threshold_qty 99
* @magentoApiDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php
* @magentoApiDataFixture Magento/Checkout/_files/simple_product.php
* @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php
Expand Down Expand Up @@ -208,4 +217,13 @@ private function assignWebsiteToStock(int $stockId, string $websiteCode): void
$extensionAttributes->setSalesChannels($salesChannels);
$stockRepository->save($stock);
}

/**
* @inheritDoc
*/
protected function tearDown()
{
$resource = $this->objectManager->get(\Magento\Config\Model\ResourceModel\Config\Data::class);
$resource->clearScopeData('default', 0);
}
}

0 comments on commit aaf6dc8

Please sign in to comment.