diff --git a/app/code/Magento/InventoryGraphQl/Test/Api/OnlyXLeftTest.php b/app/code/Magento/InventoryGraphQl/Test/Api/OnlyXLeftTest.php index 48d1d4c8f82d..d12245a9eb4b 100644 --- a/app/code/Magento/InventoryGraphQl/Test/Api/OnlyXLeftTest.php +++ b/app/code/Magento/InventoryGraphQl/Test/Api/OnlyXLeftTest.php @@ -8,6 +8,9 @@ namespace Magento\InventoryGraphQl\Test\Api; use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Config\Model\PreparedValueFactory; +use Magento\Config\Model\ResourceModel\Config\Data; +use Magento\Framework\App\Config\ReinitableConfigInterface; use Magento\Framework\ObjectManagerInterface; use Magento\InventoryApi\Api\StockRepositoryInterface; use Magento\InventorySalesApi\Api\Data\SalesChannelInterface; @@ -32,16 +35,26 @@ class OnlyXLeftTest extends GraphQlAbstract protected function setUp() { $this->objectManager = Bootstrap::getObjectManager(); + $preparedValueFactory = $this->objectManager->get(PreparedValueFactory::class); + $resource = $this->objectManager->get(Data::class); + $value = $preparedValueFactory->create( + 'cataloginventory/options/stock_threshold_qty', + 101, + 'default', + 0 + ); + $resource->save($value); + $reinitableConfig = $this->objectManager->create( + ReinitableConfigInterface::class + ); + $reinitableConfig->reinit(); } /** - * Verify "Only x left" after order placement on default stock, main website. + * Verify "Only x left" 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 - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/order_simple_product.php + * @magentoApiDataFixture Magento/Catalog/_files/products_new.php + * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ public function testOnlyXLeftDefaultStockMainWebsite() @@ -61,18 +74,15 @@ public function testOnlyXLeftDefaultStockMainWebsite() $response = $this->graphQlQuery($query); $this->assertArrayHasKey(0, $response['products']['items']); - $this->assertEquals('33', $response['products']['items'][0]['only_x_left_in_stock']); + $this->assertEquals('100', $response['products']['items'][0]['only_x_left_in_stock']); } /** * 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 - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/create_quote_on_default_website.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/order_simple_product.php + * @magentoApiDataFixture Magento/Catalog/_files/products_new.php + * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ public function testOnlyXLeftDefaultStockAdditionalWebsite() @@ -94,20 +104,17 @@ public function testOnlyXLeftDefaultStockAdditionalWebsite() $headerMap = ['Store' => 'store_for_eu_website']; $response = $this->graphQlQuery($query, [], '', $headerMap); $this->assertArrayHasKey(0, $response['products']['items']); - $this->assertEquals('33', $response['products']['items'][0]['only_x_left_in_stock']); + $this->assertEquals('100', $response['products']['items'][0]['only_x_left_in_stock']); } /** * 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 Magento/Catalog/_files/products_new.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_multi_source.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/create_quote_on_default_website.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/order_simple_product.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ public function testOnlyXLeftAdditionalStockMainWebsite() @@ -134,15 +141,12 @@ 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 Magento/Catalog/_files/products_new.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_multi_source.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/create_quote_on_default_website.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryShipping/Test/_files/order_simple_product.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ public function testOnlyXLeftAdditionalStockAdditionalWebsite() @@ -208,4 +212,13 @@ private function assignWebsiteToStock(int $stockId, string $websiteCode): void $extensionAttributes->setSalesChannels($salesChannels); $stockRepository->save($stock); } + + /** + * @inheritDoc + */ + protected function tearDown() + { + $resource = $this->objectManager->get(Data::class); + $resource->clearScopeData('default', 0); + } } diff --git a/app/code/Magento/InventoryGraphQl/Test/_files/several_source_items.php b/app/code/Magento/InventoryGraphQl/Test/_files/several_source_items.php deleted file mode 100644 index e8be74a2b789..000000000000 --- a/app/code/Magento/InventoryGraphQl/Test/_files/several_source_items.php +++ /dev/null @@ -1,79 +0,0 @@ -get(DataObjectHelper::class); -/** @var SourceItemInterfaceFactory $sourceItemFactory */ -$sourceItemFactory = Bootstrap::getObjectManager()->get(SourceItemInterfaceFactory::class); -/** @var SourceItemsSaveInterface $sourceItemsSave */ -$sourceItemsSave = Bootstrap::getObjectManager()->get(SourceItemsSaveInterface::class); - -//die('123'); - -/** - * SKU-1 - EU-source-1(id:10) - 5.5qty - * SKU-1 - EU-source-2(id:20) - 3qty - * SKU-1 - EU-source-3(id:30) - 10qty (out of stock) - * SKU-1 - EU-source-4(id:40) - 10qty (disabled source) - * - * SKU-2 - US-source-1(id:30) - 5qty - * - * SKU-3 - EU-source-2(id:20) - 6qty (out of stock) - */ -$sourcesItemsData = [ - [ - SourceItemInterface::SOURCE_CODE => 'eu-1', - SourceItemInterface::SKU => 'SKU-1', - SourceItemInterface::QUANTITY => 5.5, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'eu-2', - SourceItemInterface::SKU => 'SKU-1', - SourceItemInterface::QUANTITY => 3, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'eu-3', - SourceItemInterface::SKU => 'SKU-1', - SourceItemInterface::QUANTITY => 10, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'eu-disabled', - SourceItemInterface::SKU => 'SKU-1', - SourceItemInterface::QUANTITY => 10, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'us-1', - SourceItemInterface::SKU => 'SKU-2', - SourceItemInterface::QUANTITY => 5, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'eu-2', - SourceItemInterface::SKU => 'SKU-3', - SourceItemInterface::QUANTITY => 6, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, - ], -]; - -$sourceItems = []; -foreach ($sourcesItemsData as $sourceItemData) { - /** @var SourceItemInterface $source */ - $sourceItem = $sourceItemFactory->create(); - $dataObjectHelper->populateWithArray($sourceItem, $sourceItemData, SourceItemInterface::class); - $sourceItems[] = $sourceItem; -} -$sourceItemsSave->execute($sourceItems); diff --git a/app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_default_source.php b/app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_default_source.php deleted file mode 100644 index a3bf634a52d7..000000000000 --- a/app/code/Magento/InventoryShipping/Test/_files/source_items_for_simple_on_default_source.php +++ /dev/null @@ -1,35 +0,0 @@ -get(DataObjectHelper::class); -/** @var SourceItemInterfaceFactory $sourceItemFactory */ -$sourceItemFactory = Bootstrap::getObjectManager()->get(SourceItemInterfaceFactory::class); -/** @var SourceItemsSaveInterface $sourceItemsSave */ -$sourceItemsSave = Bootstrap::getObjectManager()->get(SourceItemsSaveInterface::class); -/** @var DefaultSourceProviderInterface $defaultSourceProvider */ -$defaultSourceProvider = Bootstrap::getObjectManager()->get(DefaultSourceProviderInterface::class); - -$sourceItems = []; -/** @var SourceItemInterface $source */ -$sourceItem = $sourceItemFactory->create(); -$sourceItemData = [ - SourceItemInterface::SOURCE_CODE => $defaultSourceProvider->getCode(), - SourceItemInterface::SKU => 'simple', - SourceItemInterface::QUANTITY => 33, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, -]; -$dataObjectHelper->populateWithArray($sourceItem, $sourceItemData, SourceItemInterface::class); -$sourceItems[] = $sourceItem; -$sourceItemsSave->execute($sourceItems);