Skip to content

Commit 8d20946

Browse files
MAGETWO-98013: [2.3] Configurable product is displayed as In Stock in product grid when it's set to out of stock
1 parent f665cca commit 8d20946

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/QuantityAndStockStatusTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Ui\DataProvider\Product;
99

10+
use Magento\Catalog\Api\ProductRepositoryInterface;
1011
use Magento\CatalogInventory\Model\Stock\StockItemRepository;
1112
use Magento\CatalogInventory\Ui\DataProvider\Product\AddIsInStockFieldToCollection;
1213
use PHPUnit\Framework\TestCase;
@@ -39,19 +40,21 @@ protected function setUp()
3940
* Test product stock status in the products grid column
4041
*
4142
* @magentoDataFixture Magento/Catalog/_files/quantity_and_stock_status_attribute_used_in_grid.php
42-
* @magentoDataFixture Magento/Checkout/_files/simple_product.php
43+
* @magentoDataFixture Magento/Catalog/_files/products.php
4344
*/
4445
public function testProductStockStatus()
4546
{
46-
$productId = 1;
47+
/** @var ProductRepositoryInterface $productRepository */
48+
$productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
49+
$product = $productRepository->get('simple');
50+
$productId = $product->getId();
4751

4852
/** @var StockItemRepository $stockItemRepository */
49-
$stockItemRepository = $this->objectManager
50-
->create(StockItemRepository::class);
53+
$stockItemRepository = $this->objectManager->create(StockItemRepository::class);
54+
5155
$stockItem = $stockItemRepository->get($productId);
5256
$stockItem->setIsInStock(false);
5357
$stockItemRepository->save($stockItem);
54-
5558
$savedStockItem = $stockItemRepository->get($productId);
5659
$savedStockStatus = $savedStockItem->getData('is_in_stock');
5760

0 commit comments

Comments
 (0)