Skip to content

Commit 60ba4ee

Browse files
committed
Merge branch 'ACP2E-1749' of https://github.com/magento-l3/magento2ce into PR-L3-03132023
2 parents e6aa757 + 0efa5eb commit 60ba4ee

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminSaveProductByCustomDateWithCustomDateAttributeTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Adding Custom Date Attribute To Products"/>
14+
<title value="Issue while saving the date type product attribute"/>
15+
<description value="When we add the 01/01/1970 to the product attribute of the custom date type, it is throwing an error."/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="AC-8290"/>
18+
<useCaseId value="ACP2E-1749"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/>
28+
</before>
29+
<after>
30+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
31+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
32+
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteAttribute">
33+
<argument name="ProductAttribute" value="dateProductAttribute"/>
34+
</actionGroup>
35+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
36+
<argument name="indices" value=""/>
37+
</actionGroup>
38+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="resetGridFilter"/>
39+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
40+
</after>
41+
42+
<!-- Generate date for use as default value, needs to be MM/d/YYYY and mm/d/yy -->
43+
<generateDate date="now" format="m/j/Y" stepKey="generateDefaultDate"/>
44+
45+
<!-- Navigate to Stores > Attributes > Product. -->
46+
<actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="goToProductAttributes"/>
47+
48+
<!-- Create new Product Attribute as Date, with code and default value. -->
49+
<actionGroup ref="CreateProductAttributeWithDateFieldActionGroup" stepKey="createAttribute">
50+
<argument name="attribute" value="dateProductAttribute"/>
51+
<argument name="date" value="{$generateDefaultDate}"/>
52+
</actionGroup>
53+
54+
<!-- Go to default attribute set edit page -->
55+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/>
56+
<!-- Assert created attribute in unassigned section -->
57+
<see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.unassignedAttributesTree}}" stepKey="seeAttributeInUnassigned"/>
58+
<!-- Assign attribute to product group -->
59+
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
60+
<argument name="group" value="Product Details"/>
61+
<argument name="attribute" value="{{dateProductAttribute.attribute_code}}"/>
62+
</actionGroup>
63+
<!-- Assert attribute in a group -->
64+
<see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.groupTree}}" stepKey="seeAttributeInGroup"/>
65+
<!-- Save attribute set -->
66+
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>
67+
68+
<!-- Open Product Edit Page and set custom attribute value 01/01/1970 and save the product-->
69+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForProduct">
70+
<argument name="product" value="$createProduct$"/>
71+
</actionGroup>
72+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
73+
<argument name="product" value="$createProduct$"/>
74+
</actionGroup>
75+
<fillField selector="{{AdminProductFormSection.newAddedAttributeInput(dateProductAttribute.attribute_code)}}" userInput="01/01/1970" stepKey="fillCustomDateValue"/>
76+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
77+
<!-- Open Product Index Page and filter the product by date 01/01/1970 -->
78+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex2"/>
79+
<actionGroup ref="FilterProductGridByCustomDateRangeActionGroup" stepKey="filterProductGridByCustomDateRange">
80+
<argument name="code" value="{{dateProductAttribute.attribute_code}}"/>
81+
<argument name="date" value="1/01/1970"/>
82+
</actionGroup>
83+
<!-- Check products filtering and see the product custom date 01/01/1970 successfully appeared -->
84+
<see selector="{{AdminProductGridSection.productGridNameProduct($createProduct.name$)}}" userInput="$createProduct.name$" stepKey="seeProductName"/>
85+
</test>
86+
</tests>

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ private function appendTimeIfNeeded(string $date, bool $includeTime, string $tim
376376
$timezone
377377
);
378378
$timestamp = $formatter->parse($date);
379-
if (!$timestamp) {
379+
if ($timestamp === false) {
380380
throw new LocalizedException(
381381
new Phrase(
382382
'Could not append time to DateTime'

0 commit comments

Comments
 (0)