Skip to content

Commit

Permalink
馃悰 Use * for empty image set name (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-rose committed Dec 8, 2023
1 parent 6e00a41 commit 877be5c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ public function expandProductPageData(array $productData, ProductPageSearchTrans
$productImages = $productAbstractPageSearchTransfer->getProductImages();

$regrouped = [];

foreach ($imageSetsByLocale as $imageSet) {
foreach ($productImages as $productImage) {
if ($productImage['fk_product_image_set'] === $imageSet->getIdProductImageSet()) {
$regrouped[($imageSet->getName() ?? static::IMAGE_GROUP_NAME_EMPTY)][] = $productImage;
$key = $imageSet->getName();

$regrouped[$key === null || $key === '' ? $key : static::IMAGE_GROUP_NAME_EMPTY][] = $productImage;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,31 @@ public function testExpandProductPageData(): void

$this->plugin->expandProductPageData($productData, $this->pageSearchTransferMock);
}

/**
* @return void
*/
public function testExpandProductPageDataWithoutName(): void
{
$productData = [
ProductPageSearchConfig::PRODUCT_ABSTRACT_PAGE_LOAD_DATA => $this->productPayloadTransferMock,
'fk_locale' => 1,
];

$imageSets = [
1 => [$this->spyProductImageSetMock],
];

$productImage = [
'fk_product_image_set' => 44,
];

$this->productPayloadTransferMock->expects(static::atLeastOnce())->method('getImages')->willReturn($imageSets);
$this->spyProductImageSetMock->expects(static::atLeastOnce())->method('getIdProductImageSet')->willReturn(44);
$this->spyProductImageSetMock->expects(static::atLeastOnce())->method('getName')->willReturn('');
$this->pageSearchTransferMock->expects(static::atLeastOnce())->method('setGroupedProductImages');
$this->pageSearchTransferMock->expects(static::atLeastOnce())->method('getProductImages')->willReturn([$productImage]);

$this->plugin->expandProductPageData($productData, $this->pageSearchTransferMock);
}
}

0 comments on commit 877be5c

Please sign in to comment.