Skip to content

Commit 455d7d6

Browse files
committed
Merge branch 'pr-32768' into 2.4-develop-prs
2 parents 8618ee9 + 80ac082 commit 455d7d6

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ImageContentData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@
4343
<entity name="MagentoPlaceHolderImageContent" type="ImageContent">
4444
<data key="baseImage_md5">c0459a796c5b8ee74254472c235a7460</data>
4545
</entity>
46+
<entity name="TestImageWithDotInFilenameImageContent" extends="MagentoLogoImageContent" type="ImageContent">
47+
<data key="baseImage_md5">4aa2a3c3eefd29898585a8dd781e5bfd</data>
48+
<data key="name" unique="prefix">m.agento-logo.png</data>
49+
</entity>
4650
</entities>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,11 @@
431431
<data key="file">test_image.jpg</data>
432432
<data key="filename">test_image</data>
433433
</entity>
434+
<entity name="TestImageWithDotInFilename" extends="MagentoLogo" type="image">
435+
<data key="title" unique="suffix">TestImageWithDotInFilename</data>
436+
<data key="file">m.agento-logo.png</data>
437+
<data key="filename">m.agento-logo</data>
438+
</entity>
434439
<entity name="ProductWithUnicode" type="product">
435440
<data key="name" unique="suffix">&#38657;&#20135;&#21697;</data>
436441
<data key="sku" unique="suffix">&#38657;&#20135;&#21697;</data>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontProductImageWithDotTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Product Image"/>
15+
<title value="Product image with dot in filename should be visible on frontend after catalog image cache flush"/>
16+
<description value="Product image with dot in filename should be visible on frontend after catalog image cache flush"/>
17+
<group value="Catalog"/>
18+
<severity value="AVERAGE"/>
19+
</annotations>
20+
<before>
21+
<magentoCLI command="config:set system/upload_configuration/enable_resize 0" stepKey="disableImageResizing"/>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<magentoCLI command="config:set system/upload_configuration/enable_resize 1" stepKey="enableImageResizing"/>
26+
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteProduct">
27+
<argument name="sku" value="{{SimpleProduct.sku}}"/>
28+
</actionGroup>
29+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilter"/>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin"/>
31+
</after>
32+
33+
<!--Create product-->
34+
<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="openNewProductPage"/>
35+
<actionGroup ref="FillMainProductFormActionGroup" stepKey="fillSimpleProductMain">
36+
<argument name="product" value="SimpleProduct"/>
37+
</actionGroup>
38+
39+
<!-- Add image to product -->
40+
<actionGroup ref="AddProductImageActionGroup" stepKey="addImageForSimpleProduct">
41+
<argument name="image" value="TestImageWithDotInFilename"/>
42+
</actionGroup>
43+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/>
44+
45+
<!-- Flush catalog image cache -->
46+
<actionGroup ref="AdminGoToCacheManagementPageActionGroup" stepKey="goToCacheManagementPage"/>
47+
<actionGroup ref="AdminClickFlushCatalogImagesCacheActionGroup" stepKey="clearCatalogImageCache"/>
48+
49+
<!-- Assert product in storefront product page -->
50+
<actionGroup ref="AssertProductNameAndSkuInStorefrontProductPageActionGroup" stepKey="assertProductInStorefrontProductPage">
51+
<argument name="product" value="SimpleProduct"/>
52+
</actionGroup>
53+
54+
<!-- Assert product image in storefront product page -->
55+
<grabAttributeFrom userInput="src" selector="{{StorefrontProductMediaSection.imageFile(TestImageWithDotInFilename.filename)}}" stepKey="productImageURL"/>
56+
<helper class="Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertImageContentIsEqual" stepKey="assertProductImageEqualToOriginalImage">
57+
<argument name="url">{$productImageURL}</argument>
58+
<argument name="expectedString">{{TestImageWithDotInFilenameImageContent.baseImage_md5}}</argument>
59+
<argument name="message">Url: "{$productImageURL}" did not render image: {{TestImageWithDotInFilename.file}}</argument>
60+
</helper>
61+
</test>
62+
</tests>

app/code/Magento/MediaStorage/App/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private function setPlaceholderImage(): void
259259
*/
260260
private function getOriginalImage(string $resizedImagePath): string
261261
{
262-
return preg_replace('|^.*?((?:/([^/])/([^/])/\2\3)?/?[^/]+$)|', '$1', $resizedImagePath);
262+
return preg_replace('|^.*((?:/[^/]+){3})$|', '$1', $resizedImagePath);
263263
}
264264

265265
/**
9.66 KB
Loading

0 commit comments

Comments
 (0)