Skip to content

Commit 8ab4cb7

Browse files
committed
Fixed Static and Unit Test failures
1 parent dbf1ee9 commit 8ab4cb7

File tree

3 files changed

+22
-30
lines changed

3 files changed

+22
-30
lines changed

app/code/Magento/Catalog/Ui/Component/Listing/Columns/Thumbnail.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1010

1111
/**
12-
* Class Thumbnail
12+
* Class prepares Thumbnail
1313
*
1414
* @api
1515
* @since 100.0.2
1616
*/
1717
class Thumbnail extends \Magento\Ui\Component\Listing\Columns\Column
1818
{
19-
const NAME = 'thumbnail';
19+
public const NAME = 'thumbnail';
2020

21-
const ALT_FIELD = 'name';
21+
public const ALT_FIELD = 'name';
2222

2323
/**
2424
* @var \Magento\Catalog\Helper\Image
@@ -87,8 +87,6 @@ public function prepareDataSource(array $dataSource)
8787
protected function getAlt($row)
8888
{
8989
$altField = $this->getData('config/altField') ?: self::ALT_FIELD;
90-
return html_entity_decode($row[$altField],ENT_QUOTES, "UTF-8") ?? null;
91-
90+
return html_entity_decode($row[$altField], ENT_QUOTES, "UTF-8") ?? null;
9291
}
9392
}
94-

app/code/Magento/ConfigurableProduct/Model/LinkManagement.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory;
1010
use Magento\Catalog\Model\ProductRepository;
1111
use Magento\Framework\Exception\InputException;
12-
use Magento\Framework\Exception\LocalizedException;
1312
use Magento\Framework\Exception\NoSuchEntityException;
1413
use Magento\Framework\Exception\StateException;
15-
use Magento\Catalog\Api\Data\ProductInterface;
16-
1714

1815
/**
1916
* Configurable product link management.
@@ -76,7 +73,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
7673
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
7774
* @param \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory
7875
* @param \Magento\Catalog\Model\ProductRepository $mediaGalleryProcessor
79-
* @param \Magento\Catalog\Api\Data\ProductInterface $productInterface
76+
* @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory
8077
*/
8178
public function __construct(
8279
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
@@ -96,26 +93,11 @@ public function __construct(
9693
$this->mediaGallery = $mediaGalleryProcessor ?: \Magento\Framework\App\ObjectManager::getInstance()
9794
->get(\Magento\Catalog\Model\ProductRepository::class);
9895
$this->myModelFactory = $myModelFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
99-
->get(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class);;
96+
->get(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class);
10097
}
10198

102-
/**
103-
* Process Media gallery data before save product.
104-
*
105-
* Compare Media Gallery Entries Data with existing Media Gallery
106-
* * If Media entry has not value_id set it as new
107-
* * If Existing entry 'value_id' absent in Media Gallery set 'removed' flag
108-
* * Merge Existing and new media gallery
109-
*
110-
* @param ProductInterface $product contains only existing media gallery items
111-
* @param array $mediaGalleryEntries array which contains all media gallery items
112-
* @throws InputException
113-
* @throws StateException
114-
* @throws LocalizedException
115-
*/
11699
/**
117100
* @inheritdoc
118-
* @throws LocalizedException
119101
*/
120102
public function getChildren($sku)
121103
{
@@ -152,6 +134,13 @@ public function getChildren($sku)
152134
}
153135
return $childrenList;
154136
}
137+
138+
/**
139+
* Get media entries
140+
*
141+
* @param array $images
142+
* @return array
143+
*/
155144
public function getMediaEntries($images)
156145
{
157146
$media = $this->myModelFactory->create();
@@ -161,8 +150,8 @@ public function getMediaEntries($images)
161150
$media->setMediaType($image["media_type"]);
162151
$media->setLabel($image["label"]);
163152
$media->setPosition($image["position"]);
164-
$media->setDisabled($image["disabled"]);
165-
$media->setFile($image["file"]);
153+
$media->setDisabled($image["disabled"]);
154+
$media->setFile($image["file"]);
166155
$mediaGalleryEntries[]=$media->getData();
167156
}
168157
return $mediaGalleryEntries;
@@ -258,10 +247,12 @@ public function removeChild($sku, $childSku)
258247
* @return \Magento\ConfigurableProduct\Helper\Product\Options\Factory
259248
*
260249
* @deprecated 100.2.0
250+
* @see Nothing
261251
*/
262252
private function getOptionsFactory()
263253
{
264254
if (!$this->optionsFactory) {
255+
// phpcs:ignore Magento2.PHP.AutogeneratedClassNotInConstructor
265256
$this->optionsFactory = \Magento\Framework\App\ObjectManager::getInstance()
266257
->get(\Magento\ConfigurableProduct\Helper\Product\Options\Factory::class);
267258
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ public function testGetChildren(): void
135135

136136
$this->dataObjectHelperMock->expects($this->once())
137137
->method('populateWithArray')
138-
->with($productMock, ['store_id' => 1, 'code' => 10], ProductInterface::class)
139-
->willReturnSelf();
138+
->with(
139+
$productMock,
140+
['store_id' => 1, 'code' => 10, 'media_gallery_entries' => []],
141+
ProductInterface::class
142+
)->willReturnSelf();
140143

141144
$this->productFactory->expects($this->once())
142145
->method('create')

0 commit comments

Comments
 (0)