Skip to content

Commit 24f1d73

Browse files
Merge remote-tracking branch 'remotes/github/MC-17653' into EPAM-PR-81
2 parents 5b9d3e8 + 6509f40 commit 24f1d73

File tree

7 files changed

+42
-11
lines changed

7 files changed

+42
-11
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1010
<section name="AdminProductFormSection">
11+
<element name="datepickerNewAttribute" type="input" selector="[data-index='{{attrName}}'] input" timeout="30" parameterized="true"/>
1112
<element name="attributeSet" type="select" selector="div[data-index='attribute_set_id'] .admin__field-control"/>
1213
<element name="attributeSetFilter" type="input" selector="div[data-index='attribute_set_id'] .admin__field-control input" timeout="30"/>
1314
<element name="attributeSetFilterResult" type="input" selector="div[data-index='attribute_set_id'] .action-menu-item._last" timeout="30"/>

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,34 @@
4747
<arguments>
4848
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
4949
</arguments>
50-
5150
<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
5251
<fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}" stepKey="fillName"/>
5352
<fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}" stepKey="fillDescription"/>
5453
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="{{catalogRule.website_ids}}" stepKey="selectSite"/>
5554
<click stepKey="openActionDropdown" selector="{{AdminNewCatalogPriceRule.actionsTab}}"/>
5655
<fillField stepKey="fillDiscountValue" selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="{{catalogRule.discount_amount}}"/>
5756
<scrollToTopOfPage stepKey="scrollToTop"/>
57+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/>
5858
<waitForPageLoad stepKey="waitForApplied"/>
5959
</actionGroup>
60+
61+
<actionGroup name="AdminCreateCatalogPriceRuleWithConditionActionGroup" extends="createCatalogPriceRule">
62+
<arguments>
63+
<argument name="catalogRuleType" type="entity" defaultValue="PriceRuleWithCondition"/>
64+
</arguments>
65+
<waitForPageLoad stepKey="waitForPageLoad" after="addNewRule"/>
66+
<click selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="expandConditions" before="openActionDropdown"/>
67+
<scrollTo selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="scrollToConditionsTab" after="expandConditions"/>
68+
<waitForElementVisible selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="waitForNewRule" after="scrollToConditionsTab"/>
69+
<click selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="clickNewRule" after="waitForNewRule"/>
70+
<selectOption selector="{{AdminNewCatalogPriceRuleConditions.conditionsDropdown}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="selectProductAttribute" after="clickNewRule"/>
71+
<waitForPageLoad stepKey="waitForAttributeLoad" after="selectProductAttribute"/>
72+
<!--Assert that attribute contains today date without time-->
73+
<comment userInput="Assert that attribute contains today date without time" stepKey="assertDate" after="waitForAttributeLoad"/>
74+
<generateDate date="now" format="Y-m-d" stepKey="today" after="assertDate"/>
75+
<grabTextFrom selector="{{PriceRuleConditionsSection.firstProductAttributeSelected}}" stepKey="grabTextFromSelectedAttribute" after="today"/>
76+
<assertEquals expected="$today" actual="$grabTextFromSelectedAttribute" stepKey="assertTodayDate" after="grabTextFromSelectedAttribute"/>
77+
</actionGroup>
6078
<actionGroup name="AdminCreateMultipleWebsiteCatalogPriceRule" extends="createCatalogPriceRule">
6179
<remove keyForRemoval="selectSite"/>
6280
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="['FirstWebsite', 'SecondWebsite']" stepKey="selectWebsite"/>

app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
<section name="AdminNewCatalogPriceRuleConditions">
4545
<element name="newCondition" type="button" selector=".rule-param.rule-param-new-child"/>
46+
<element name="conditionsDropdown" type="select" selector="select[data-form-part='catalog_rule_form'][data-ui-id='newchild-0-select-rule-conditions-1-new-child']"/>
4647
<element name="conditionSelect" type="select" selector="select#conditions__{{var}}__new_child" parameterized="true"/>
4748
<element name="targetEllipsis" type="button" selector="//li[{{var}}]//a[@class='label'][text() = '...']" parameterized="true"/>
4849
<element name="targetEllipsisValue" type="button" selector="//ul[@id='conditions__{{var}}__children']//a[contains(text(), '{{var1}}')]" parameterized="true" timeout="30"/>

app/code/Magento/Rule/Model/Condition/AbstractCondition.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Rule\Model\Condition;
89

@@ -17,6 +18,7 @@
1718
* @method setFormName()
1819
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
1920
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
21+
* phpcs:disable Magento2.Classes.AbstractApi
2022
* @api
2123
* @since 100.0.2
2224
*/
@@ -390,7 +392,7 @@ public function getValueParsed()
390392
$value = reset($value);
391393
}
392394
if (!is_array($value) && $this->isArrayOperatorType() && $value) {
393-
$value = preg_split('#\s*[,;]\s*#', $value, null, PREG_SPLIT_NO_EMPTY);
395+
$value = preg_split('#\s*[,;]\s*#', (string) $value, -1, PREG_SPLIT_NO_EMPTY);
394396
}
395397
$this->setValueParsed($value);
396398
}
@@ -419,8 +421,11 @@ public function getValue()
419421
{
420422
if ($this->getInputType() == 'date' && !$this->getIsValueParsed()) {
421423
// date format intentionally hard-coded
424+
$date = $this->getData('value');
425+
$date = (\is_numeric($date) ? '@' : '') . $date;
422426
$this->setValue(
423-
(new \DateTime($this->getData('value')))->format('Y-m-d H:i:s')
427+
(new \DateTime($date, new \DateTimeZone((string) $this->_localeDate->getConfigTimezone())))
428+
->format('Y-m-d H:i:s')
424429
);
425430
$this->setIsValueParsed(true);
426431
}
@@ -432,6 +437,7 @@ public function getValue()
432437
*
433438
* @return array|string
434439
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
440+
* phpcs:disable Generic.Metrics.NestingLevel
435441
*/
436442
public function getValueName()
437443
{
@@ -469,6 +475,7 @@ public function getValueName()
469475
}
470476
return $value;
471477
}
478+
//phpcs:enable Generic.Metrics.NestingLevel
472479

473480
/**
474481
* Get inherited conditions selectors
@@ -674,6 +681,9 @@ public function getValueElement()
674681
$elementParams['placeholder'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
675682
$elementParams['autocomplete'] = 'off';
676683
$elementParams['readonly'] = 'true';
684+
$elementParams['value_name'] =
685+
(new \DateTime($elementParams['value'], new \DateTimeZone($this->_localeDate->getConfigTimezone())))
686+
->format('Y-m-d');
677687
}
678688
return $this->getForm()->addField(
679689
$this->getPrefix() . '__' . $this->getId() . '__value',
@@ -879,7 +889,7 @@ protected function _compareValues($validatedValue, $value, $strict = true)
879889
return $validatedValue == $value;
880890
}
881891

882-
$validatePattern = preg_quote($validatedValue, '~');
892+
$validatePattern = preg_quote((string) $validatedValue, '~');
883893
if ($strict) {
884894
$validatePattern = '^' . $validatePattern . '$';
885895
}

app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public function validateAttributeDataProvider()
5555
['0', '==', 1, false],
5656
['1', '==', 1, true],
5757
['x', '==', 'x', true],
58-
['x', '==', 0, false],
58+
['x', '==', '0', false],
5959

6060
[1, '!=', 1, false],
6161
[0, '!=', 1, true],
6262
['0', '!=', 1, true],
6363
['1', '!=', 1, false],
6464
['x', '!=', 'x', false],
65-
['x', '!=', 0, true],
65+
['x', '!=', '0', true],
6666

6767
[1, '==', [1], true],
6868
[1, '!=', [1], false],
@@ -164,15 +164,15 @@ public function validateAttributeArrayInputTypeDataProvider()
164164

165165
[[1, 2, 3], '{}', '1', true, 'grid'],
166166
[[1, 2, 3], '{}', '8', false, 'grid'],
167-
[[1, 2, 3], '{}', 5, false, 'grid'],
167+
[[1, 2, 3], '{}', '5', false, 'grid'],
168168
[[1, 2, 3], '{}', [2, 3, 4], true, 'grid'],
169169
[[1, 2, 3], '{}', [4], false, 'grid'],
170170
[[3], '{}', [], false, 'grid'],
171171
[1, '{}', 1, false, 'grid'],
172172
[1, '!{}', [1, 2, 3], false, 'grid'],
173173
[[1], '{}', null, false, 'grid'],
174-
[null, '{}', null, true, 'input'],
175-
[null, '!{}', null, false, 'input'],
174+
['null', '{}', 'null', true, 'input'],
175+
['null', '!{}', 'null', false, 'input'],
176176
[null, '{}', [1], false, 'input'],
177177

178178
[[1, 2, 3], '()', 1, true, 'select'],

app/code/Magento/SalesRule/Test/Mftf/Section/PriceRuleConditionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<element name="rulesDropdown" type="select" selector="select[data-form-part='sales_rule_form'][data-ui-id='newchild-0-select-rule-conditions-1-new-child']"/>
1212
<element name="addProductAttributesButton" type="text" selector="#conditions__1--1__children>li>span>a"/>
1313
<element name="productAttributesDropdown" type="select" selector="#conditions__1--1__new_child"/>
14+
<element name="firstProductAttributeSelected" type="select" selector="#conditions__1__children .rule-param:nth-of-type(2) a:nth-child(1)"/>
1415
<element name="changeCategoriesButton" type="text" selector="#conditions__1--1__children>li>span.rule-param:nth-of-type(2)>a"/>
1516
<element name="categoriesChooser" type="text" selector="#conditions__1--1__children>li>span.rule-param:nth-of-type(2)>span>label>a"/>
1617
<element name="treeRoot" type="text" selector=".x-tree-root-ct.x-tree-lines"/>

app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ public function testValidateCategoriesIgnoresVisibility(): void
247247
* @param boolean $isValid
248248
* @param string $conditionValue
249249
* @param string $operator
250-
* @param double $productPrice
250+
* @param string $productPrice
251251
* @dataProvider localisationProvider
252252
*/
253-
public function testQuoteLocaleFormatPrice($isValid, $conditionValue, $operator = '>=', $productPrice = 2000.00)
253+
public function testQuoteLocaleFormatPrice($isValid, $conditionValue, $operator = '>=', $productPrice = '2000.00')
254254
{
255255
$attr = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class)
256256
->disableOriginalConstructor()

0 commit comments

Comments
 (0)