@@ -24,8 +24,28 @@ protected function setUp()
24
24
$ this ->productRepository = $ objectManager ->get ('Magento\Catalog\Api\ProductRepositoryInterface ' );
25
25
}
26
26
27
+ public static function tearDownAfterClass ()
28
+ {
29
+ $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
30
+ /** @var \Magento\CatalogInventory\Model\StockRegistry $stockRegistry */
31
+ $ stockRegistry = $ objectManager ->get ('Magento\CatalogInventory\Model\StockRegistry ' );
32
+ /** @var \Magento\CatalogInventory\Model\Stock\StockStatusRepository $stockStatusRepository */
33
+ $ stockStatusRepository = $ objectManager ->get ('Magento\CatalogInventory\Model\Stock\StockStatusRepository ' );
34
+ $ isSecureArea = $ objectManager ->get ('Magento\Framework\Registry ' )->registry ('isSecureArea ' );
35
+ $ objectManager ->get ('Magento\Framework\Registry ' )->unregister ('isSecureArea ' );
36
+ $ objectManager ->get ('Magento\Framework\Registry ' )->register ('isSecureArea ' , true );
37
+ $ objectManager ->get ('Magento\Framework\App\State ' )->setAreaCode ('adminhtml ' );
38
+ foreach ([3 , 2 , 1 ] as $ productId ) {
39
+ $ stockStatus = $ stockRegistry ->getStockStatus ($ productId , 1 );
40
+ $ stockStatusRepository ->delete ($ stockStatus );
41
+ }
42
+ $ objectManager ->get ('Magento\Framework\Registry ' )->unregister ('isSecureArea ' );
43
+ $ objectManager ->get ('Magento\Framework\Registry ' )->register ('isSecureArea ' , $ isSecureArea );
44
+ }
45
+
27
46
/**
28
47
* @magentoDataFixture Magento/Bundle/_files/product.php
48
+ * @magentoDbIsolation enabled
29
49
*/
30
50
public function testSaveSuccess ()
31
51
{
@@ -74,6 +94,7 @@ public function testSaveFailure()
74
94
}
75
95
76
96
$ this ->assertTrue ($ caughtException );
97
+ /** @var \Magento\Catalog\Model\Product $product */
77
98
$ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
78
99
->create ('Magento\Catalog\Model\Product ' )->load ($ product ->getId ());
79
100
$ this ->assertEquals (null , $ product ->getDescription ());
0 commit comments