Skip to content

Commit c44c07e

Browse files
ENGCOM-7988: Fix date timestamp typo ( Created and Modified date are different for newly saved Image Preview) #29452
2 parents 83f426d + d413f88 commit c44c07e

6 files changed

+60
-23
lines changed

app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Framework\Filesystem;
1313
use Magento\Framework\Filesystem\Directory\ReadInterface;
1414
use Magento\Framework\Filesystem\Driver\File;
15-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1615
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
1716
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
1817
use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface;
@@ -24,11 +23,6 @@
2423
*/
2524
class CreateAssetFromFile
2625
{
27-
/**
28-
* Date format
29-
*/
30-
private const DATE_FORMAT = 'Y-m-d H:i:s';
31-
3226
/**
3327
* @var Filesystem
3428
*/
@@ -39,11 +33,6 @@ class CreateAssetFromFile
3933
*/
4034
private $driver;
4135

42-
/**
43-
* @var TimezoneInterface;
44-
*/
45-
private $date;
46-
4736
/**
4837
* @var AssetInterfaceFactory
4938
*/
@@ -67,7 +56,6 @@ class CreateAssetFromFile
6756
/**
6857
* @param Filesystem $filesystem
6958
* @param File $driver
70-
* @param TimezoneInterface $date
7159
* @param AssetInterfaceFactory $assetFactory
7260
* @param GetContentHash $getContentHash
7361
* @param ExtractMetadataInterface $extractMetadata
@@ -76,15 +64,13 @@ class CreateAssetFromFile
7664
public function __construct(
7765
Filesystem $filesystem,
7866
File $driver,
79-
TimezoneInterface $date,
8067
AssetInterfaceFactory $assetFactory,
8168
GetContentHash $getContentHash,
8269
ExtractMetadataInterface $extractMetadata,
8370
GetFileInfo $getFileInfo
8471
) {
8572
$this->filesystem = $filesystem;
8673
$this->driver = $driver;
87-
$this->date = $date;
8874
$this->assetFactory = $assetFactory;
8975
$this->getContentHash = $getContentHash;
9076
$this->extractMetadata = $extractMetadata;
@@ -112,8 +98,6 @@ public function execute(string $path): AssetInterface
11298
'path' => $path,
11399
'title' => $metadata->getTitle() ?: $file->getBasename(),
114100
'description' => $metadata->getDescription(),
115-
'createdAt' => $this->date->date($file->getCTime())->format(self::DATE_FORMAT),
116-
'updatedAt' => $this->date->date($file->getMTime())->format(self::DATE_FORMAT),
117101
'width' => $width,
118102
'height' => $height,
119103
'hash' => $this->getHash($path),

app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,16 @@ public function execute(int $id, MetadataInterface $data): void
7676

7777
$updatedAsset = $this->assetFactory->create(
7878
[
79+
'id' => $asset->getId(),
7980
'path' => $asset->getPath(),
80-
'contentType' => $asset->getContentType(),
81+
'title' => $data->getTitle() ?? $asset->getTitle(),
82+
'description' => $data->getDescription() ?? $asset->getDescription(),
8183
'width' => $asset->getWidth(),
8284
'height' => $asset->getHeight(),
8385
'size' => $asset->getSize(),
84-
'id' => $asset->getId(),
85-
'title' => $data->getTitle() ?? $asset->getTitle(),
86-
'description' => $data->getDescription() ?? $asset->getDescription(),
87-
'source' => $asset->getSource(),
8886
'hash' => $asset->getHash(),
89-
'created_at' => $asset->getCreatedAt(),
90-
'updated_at' => $asset->getUpdatedAt()
87+
'contentType' => $asset->getContentType(),
88+
'source' => $asset->getSource()
9189
]
9290
);
9391

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup">
12+
<annotations>
13+
<description>Assert that created_at updated_at time NOT equals</description>
14+
</annotations>
15+
16+
<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.createdAtDate}}" stepKey="grabCreatedTime"/>
17+
<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.updatedAtDate}}" stepKey="grabModifietTime"/>
18+
<assertNotEquals stepKey="verifyContentType">
19+
<actualResult type="variable">grabCreatedTime</actualResult>
20+
<expectedResult type="variable">grabModifietTime</expectedResult>
21+
</assertNotEquals>
22+
23+
</actionGroup>
24+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup">
12+
<annotations>
13+
<description>Assert that created_at updated_at time are the same for newly uploaded image </description>
14+
</annotations>
15+
16+
<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.createdAtDate}}" stepKey="grabCreatedTime"/>
17+
<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.updatedAtDate}}" stepKey="grabModifietTime"/>
18+
<assertEquals stepKey="verifyContentType">
19+
<actualResult type="variable">grabCreatedTime</actualResult>
20+
<expectedResult type="variable">grabModifietTime</expectedResult>
21+
</assertEquals>
22+
23+
</actionGroup>
24+
</actionGroups>

app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryViewDetailsSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<element name="edit" type="button" selector="//div[@class='media-gallery-image-details-modal']//button[contains(@class, 'edit')]"/>
1919
<element name="delete" type="button" selector="//div[@class='media-gallery-image-details-modal']//button[contains(@class, 'delete')]"/>
2020
<element name="confirmDelete" type="button" selector=".action-accept"/>
21+
<element name="createdAtDate" type="button" selector="//div[@class='attribute']/span[contains(text(), 'Created')]/following-sibling::div"/>
22+
<element name="updatedAtDate" type="button" selector="//div[@class='attribute']/span[contains(text(), 'Modified')]/following-sibling::div"/>
2123
<element name="addImage" type="button" selector=".add-image-action"/>
2224
<element name="cancel" type="button" selector="#image-details-action-cancel"/>
2325
<element name="usedInLink" type="button" parameterized="true" selector="//div[@class='attribute']/span[contains(text(), 'Used In')]/following-sibling::div/a[contains(text(), '{{entityName}}')]"/>

app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminStandaloneMediaGalleryEditImageDetailsTest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage">
3030
<argument name="image" value="ImageUpload"/>
3131
</actionGroup>
32+
<actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="clickViewDetails"/>
33+
<actionGroup ref="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup" stepKey="verifyCreatedAndUpdatedAtDate" />
34+
<wait time="100" stepKey="waitForUpdateTimeToBeGreater"/>
35+
<actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeViewDetails"/>
3236
<actionGroup ref="AdminEnhancedMediaGalleryEditImageDetailsActionGroup" stepKey="editImageDetails"/>
3337
<actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage">
3438
<argument name="image" value="UpdatedImageDetails"/>
@@ -40,6 +44,7 @@
4044
<actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDetailsActionGroup" stepKey="verifyImageDetails">
4145
<argument name="image" value="UpdatedImageDetails"/>
4246
</actionGroup>
47+
<actionGroup ref="AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup" stepKey="assertUpdatedAtTimeChanged" />
4348
<actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDescriptionActionGroup" stepKey="verifyImageDescription">
4449
<argument name="description" value="UpdatedImageDetails.description"/>
4550
</actionGroup>

0 commit comments

Comments
 (0)