|
7 | 7 |
|
8 | 8 | namespace Magento\Catalog\Ui\DataProvider\Product;
|
9 | 9 |
|
| 10 | +use Magento\Catalog\Api\ProductRepositoryInterface; |
10 | 11 | use Magento\CatalogInventory\Model\Stock\StockItemRepository;
|
11 | 12 | use Magento\CatalogInventory\Ui\DataProvider\Product\AddIsInStockFieldToCollection;
|
12 | 13 | use PHPUnit\Framework\TestCase;
|
@@ -39,19 +40,21 @@ protected function setUp()
|
39 | 40 | * Test product stock status in the products grid column
|
40 | 41 | *
|
41 | 42 | * @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 |
43 | 44 | */
|
44 | 45 | public function testProductStockStatus()
|
45 | 46 | {
|
46 |
| - $productId = 1; |
| 47 | + /** @var ProductRepositoryInterface $productRepository */ |
| 48 | + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); |
| 49 | + $product = $productRepository->get('simple'); |
| 50 | + $productId = $product->getId(); |
47 | 51 |
|
48 | 52 | /** @var StockItemRepository $stockItemRepository */
|
49 |
| - $stockItemRepository = $this->objectManager |
50 |
| - ->create(StockItemRepository::class); |
| 53 | + $stockItemRepository = $this->objectManager->create(StockItemRepository::class); |
| 54 | + |
51 | 55 | $stockItem = $stockItemRepository->get($productId);
|
52 | 56 | $stockItem->setIsInStock(false);
|
53 | 57 | $stockItemRepository->save($stockItem);
|
54 |
| - |
55 | 58 | $savedStockItem = $stockItemRepository->get($productId);
|
56 | 59 | $savedStockStatus = $savedStockItem->getData('is_in_stock');
|
57 | 60 |
|
|
0 commit comments