Skip to content

Commit 421a73f

Browse files
committed
MC-39709: Create automated test for: "Display a hidden product image using layered navigation"
1 parent 2a4641b commit 421a73f

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
9+
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Store\Model\Store;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
13+
14+
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_image.php');
15+
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php');
16+
17+
$objectManager = Bootstrap::getObjectManager();
18+
/** @var ProductRepositoryInterface $productRepository */
19+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
20+
$productRepository->cleanCache();
21+
$product = $productRepository->get('simple');
22+
$product->setStoreId(Store::DEFAULT_STORE_ID)
23+
->setImage('/m/a/magento_image.jpg')
24+
->setSmallImage('/m/a/magento_image.jpg')
25+
->setThumbnail('/m/a/magento_image.jpg')
26+
->setData(
27+
'media_gallery',
28+
[
29+
'images' => [
30+
[
31+
ProductAttributeMediaGalleryEntryInterface::FILE => '/m/a/magento_image.jpg',
32+
ProductAttributeMediaGalleryEntryInterface::POSITION => 1,
33+
ProductAttributeMediaGalleryEntryInterface::LABEL => 'Image Alt Text',
34+
ProductAttributeMediaGalleryEntryInterface::DISABLED => 1,
35+
ProductAttributeMediaGalleryEntryInterface::MEDIA_TYPE => 'image',
36+
],
37+
],
38+
]
39+
)
40+
->setCanSaveCustomOptions(true);
41+
42+
$productRepository->save($product);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
9+
10+
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');
11+
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_image_rollback.php');

dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,23 @@ protected function setUp(): void
4444

4545
/**
4646
* @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
47+
*
4748
* @return void
4849
*/
4950
public function testGetSwatchAttributesAsArray(): void
5051
{
5152
$product = $this->productRepository->get('simple2');
5253
$this->assertEmpty($this->helper->getSwatchAttributesAsArray($product));
5354
}
55+
56+
/**
57+
* @magentoDataFixture Magento/Catalog/_files/product_with_disabled_image.php
58+
*
59+
* @return void
60+
*/
61+
public function testGetProductMediaGalleryWithHiddenImage(): void
62+
{
63+
$result = $this->helper->getProductMediaGallery($this->productRepository->get('simple'));
64+
$this->assertEmpty($result);
65+
}
5466
}

0 commit comments

Comments
 (0)