Skip to content

Commit 6c913ce

Browse files
committed
MAGETWO-54257: "Stock Status" attribute is not changed for Variation Simple Product
1 parent 65a6e41 commit 6c913ce

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/VariationHandlerTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Magento\ConfigurableProduct\Model\Product;
1010

11+
use Magento\TestFramework\Helper\Bootstrap;
12+
1113
/**
1214
* @magentoAppIsolation enabled
1315
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
@@ -26,19 +28,22 @@ class VariationHandlerTest extends \PHPUnit_Framework_TestCase
2628
*/
2729
protected $_product;
2830

31+
/** @var \Magento\CatalogInventory\Api\StockRegistryInterface */
32+
protected $stockRegistry;
33+
2934
protected function setUp()
3035
{
31-
$this->_product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
36+
$this->_product = Bootstrap::getObjectManager()->create(
3237
'Magento\Catalog\Model\Product'
3338
);
3439
$this->_product->load(1);
35-
// fixture
3640

37-
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
41+
$this->_model = Bootstrap::getObjectManager()->create(
3842
'Magento\ConfigurableProduct\Model\Product\VariationHandler'
3943
);
4044
// prevent fatal errors by assigning proper "singleton" of type instance to the product
4145
$this->_product->setTypeInstance($this->_model);
46+
$this->stockRegistry = Bootstrap::getObjectManager()->get('Magento\CatalogInventory\Api\StockRegistryInterface');
4247
}
4348

4449
/**
@@ -52,15 +57,18 @@ public function testGenerateSimpleProducts($productsData)
5257
$generatedProducts = $this->_model->generateSimpleProducts($this->_product, $productsData);
5358
$this->assertEquals(3, count($generatedProducts));
5459
foreach ($generatedProducts as $productId) {
60+
$stockItem = $this->stockRegistry->getStockItem($productId);
5561
/** @var $product \Magento\Catalog\Model\Product */
56-
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
62+
$product = Bootstrap::getObjectManager()->create(
5763
'Magento\Catalog\Model\Product'
5864
);
5965
$product->load($productId);
6066
$this->assertNotNull($product->getName());
6167
$this->assertNotNull($product->getSku());
6268
$this->assertNotNull($product->getPrice());
6369
$this->assertNotNull($product->getWeight());
70+
$this->assertEquals('1', $stockItem->getIsInStock());
71+
6472
}
6573
}
6674

@@ -71,14 +79,12 @@ public function testGenerateSimpleProducts($productsData)
7179
*/
7280
public function testGenerateSimpleProductsWithPartialData($productsData)
7381
{
74-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
75-
/** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */
76-
$stockRegistry = $objectManager->get('Magento\CatalogInventory\Api\StockRegistryInterface');
7782
$this->_product->setNewVariationsAttributeSetId(4);
7883
$generatedProducts = $this->_model->generateSimpleProducts($this->_product, $productsData);
84+
$parentStockItem = $this->stockRegistry->getStockItem($this->_product->getId());
7985
foreach ($generatedProducts as $productId) {
80-
$stockItem = $stockRegistry->getStockItem($productId);
81-
$this->assertEquals('0', $stockItem->getManageStock());
86+
$stockItem = $this->stockRegistry->getStockItem($productId);
87+
$this->assertEquals($parentStockItem->getManageStock(), $stockItem->getManageStock());
8288
$this->assertEquals('1', $stockItem->getIsInStock());
8389
}
8490
}

0 commit comments

Comments
 (0)