|
8 | 8 | namespace Magento\ConfigurableProduct\Block\Product\View\Type;
|
9 | 9 |
|
10 | 10 | use Magento\Catalog\Block\Product\ListProduct;
|
| 11 | +use Magento\Eav\Model\Entity\Collection\AbstractCollection; |
11 | 12 | use Magento\Framework\ObjectManagerInterface;
|
12 | 13 | use Magento\Framework\View\LayoutInterface;
|
13 | 14 | use Magento\TestFramework\Helper\Bootstrap;
|
|
18 | 19 | *
|
19 | 20 | * @magentoDbIsolation disabled
|
20 | 21 | * @magentoAppIsolation enabled
|
| 22 | + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php |
21 | 23 | */
|
22 | 24 | class ConfigurableViewOnCategoryPageTest extends TestCase
|
23 | 25 | {
|
@@ -46,28 +48,35 @@ protected function setUp()
|
46 | 48 | /**
|
47 | 49 | * @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
|
48 | 50 | *
|
49 |
| - * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php |
50 |
| - * |
51 | 51 | * @return void
|
52 | 52 | */
|
53 | 53 | public function testOutOfStockProductWithEnabledConfigView(): void
|
54 | 54 | {
|
55 | 55 | $collection = $this->listingBlock->getLoadedProductCollection();
|
56 |
| - $this->assertEquals(1, $collection->getSize()); |
57 |
| - $this->assertCount(1, $collection->getItems()); |
| 56 | + $this->assertCollectionSize(1, $collection); |
58 | 57 | }
|
59 | 58 |
|
60 | 59 | /**
|
61 | 60 | * @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 0
|
62 | 61 | *
|
63 |
| - * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php |
64 |
| - * |
65 | 62 | * @return void
|
66 | 63 | */
|
67 | 64 | public function testOutOfStockProductWithDisabledConfigView(): void
|
68 | 65 | {
|
69 | 66 | $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()); |
72 | 81 | }
|
73 | 82 | }
|
0 commit comments