Skip to content

Commit 12c6bbb

Browse files
committed
Fix static tests cover changes with integration tests
1 parent 78980b3 commit 12c6bbb

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

app/code/Magento/MediaContentCatalog/Observer/CategoryDelete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ public function __construct(
8282
) {
8383
$this->extractAssetsFromContent = $extractAssetsFromContent;
8484
$this->getContent = $getContent;
85+
$this->config = $config;
8586
$this->deleteContentAssetLinks = $deleteContentAssetLinks;
8687
$this->contentAssetLinkFactory = $contentAssetLinkFactory;
8788
$this->contentIdentityFactory = $contentIdentityFactory;
88-
$this->config = $config;
8989
$this->fields = $fields;
9090
}
9191

app/code/Magento/MediaContentCms/Observer/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function __construct(
5757
array $fields
5858
) {
5959
$this->contentIdentityFactory = $contentIdentityFactory;
60-
$this->updateContentAssetLinks = $updateContentAssetLinks;
6160
$this->config = $config;
61+
$this->updateContentAssetLinks = $updateContentAssetLinks;
6262
$this->fields = $fields;
6363
}
6464

dev/tests/integration/testsuite/Magento/MediaContentCatalog/Model/ResourceModel/GetAssetIdsByContentFieldTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ protected function setUp(): void
4343
* Test for getting asset id by category fields
4444
*
4545
* @dataProvider dataProvider
46+
* @magentoConfigFixture system/media_gallery/enabled 1
4647
* @magentoDataFixture Magento/MediaGallery/_files/media_asset.php
4748
* @magentoDataFixture Magento/MediaContentCatalog/_files/category_with_asset.php
4849
*
@@ -63,9 +64,9 @@ public function testCategoryFields(string $field, string $value, array $expected
6364
* Test for getting asset id by product fields
6465
*
6566
* @dataProvider dataProvider
67+
* @magentoConfigFixture system/media_gallery/enabled 1
6668
* @magentoDataFixture Magento/MediaGallery/_files/media_asset.php
6769
* @magentoDataFixture Magento/MediaContentCatalog/_files/product_with_asset.php
68-
*
6970
* @param string $field
7071
* @param string $value
7172
* @param array $expectedAssetIds
@@ -79,6 +80,22 @@ public function testProductFields(string $field, string $value, array $expectedA
7980
);
8081
}
8182

83+
/**
84+
* Test for getting asset when media gallery disabled
85+
*
86+
* @magentoConfigFixture system/media_gallery/enabled 0
87+
* @magentoDataFixture Magento/MediaGallery/_files/media_asset.php
88+
* @magentoDataFixture Magento/MediaContentCatalog/_files/product_with_asset.php
89+
* @throws InvalidArgumentException
90+
*/
91+
public function testProductFieldsWithDisabledMediaGallery(): void
92+
{
93+
$this->assertEquals(
94+
[],
95+
$this->getAssetIdsByContentField->execute(self::STATUS_FIELD, self::STATUS_ENABLED)
96+
);
97+
}
98+
8299
/**
83100
* Data provider for tests
84101
*

dev/tests/integration/testsuite/Magento/MediaContentCatalog/_files/product_with_asset.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
8-
use Magento\Catalog\Api\Data\ProductExtensionInterfaceFactory;
97
use Magento\Catalog\Api\ProductRepositoryInterface;
108
use Magento\Catalog\Model\Product;
119
use Magento\Catalog\Model\Product\Attribute\Source\Status;
@@ -14,8 +12,6 @@
1412
use Magento\TestFramework\Helper\Bootstrap;
1513
use Magento\TestFramework\ObjectManager;
1614

17-
Bootstrap::getInstance()->reinitialize();
18-
1915
/** @var ObjectManager $objectManager */
2016
$objectManager = Bootstrap::getObjectManager();
2117

0 commit comments

Comments
 (0)