Skip to content

Commit b762938

Browse files
committed
MC-29293: Storefront: Configurable Product with Out Of Stock Child(s)
1 parent d05be5c commit b762938

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableViewOnCategoryPageTest.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\ConfigurableProduct\Block\Product\View\Type;
99

1010
use Magento\Catalog\Block\Product\ListProduct;
11+
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
1112
use Magento\Framework\ObjectManagerInterface;
1213
use Magento\Framework\View\LayoutInterface;
1314
use Magento\TestFramework\Helper\Bootstrap;
@@ -18,6 +19,7 @@
1819
*
1920
* @magentoDbIsolation disabled
2021
* @magentoAppIsolation enabled
22+
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php
2123
*/
2224
class ConfigurableViewOnCategoryPageTest extends TestCase
2325
{
@@ -46,28 +48,35 @@ protected function setUp()
4648
/**
4749
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
4850
*
49-
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php
50-
*
5151
* @return void
5252
*/
5353
public function testOutOfStockProductWithEnabledConfigView(): void
5454
{
5555
$collection = $this->listingBlock->getLoadedProductCollection();
56-
$this->assertEquals(1, $collection->getSize());
57-
$this->assertCount(1, $collection->getItems());
56+
$this->assertCollectionSize(1, $collection);
5857
}
5958

6059
/**
6160
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 0
6261
*
63-
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php
64-
*
6562
* @return void
6663
*/
6764
public function testOutOfStockProductWithDisabledConfigView(): void
6865
{
6966
$collection = $this->listingBlock->getLoadedProductCollection();
70-
$this->assertEquals(0, $collection->getSize());
71-
$this->assertCount(0, $collection->getItems());
67+
$this->assertCollectionSize(0, $collection);
68+
}
69+
70+
/**
71+
* Check collection size
72+
*
73+
* @param int $expectedSize
74+
* @param AbstractCollection $collection
75+
* @return void
76+
*/
77+
private function assertCollectionSize(int $expectedSize, AbstractCollection $collection): void
78+
{
79+
$this->assertEquals($expectedSize, $collection->getSize());
80+
$this->assertCount($expectedSize, $collection->getItems());
7281
}
7382
}

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableViewOnProductPageTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ protected function setUp()
5757
parent::setUp();
5858

5959
$this->objectManager = Bootstrap::getObjectManager();
60-
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
60+
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
61+
$this->productRepository->cleanCache();
6162
$this->layout = $this->objectManager->get(LayoutInterface::class);
6263
$this->block = $this->layout->createBlock(Configurable::class);
6364
$this->json = $this->objectManager->get(SerializerInterface::class);

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/SalableTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ protected function setUp()
3434

3535
$this->objectManager = Bootstrap::getObjectManager();
3636
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
37+
$this->productRepository->cleanCache();
3738
}
3839

3940
/**

0 commit comments

Comments
 (0)