Skip to content

Commit 342c62b

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MAGETWO-91609' into EPAM-PR-18
2 parents 03d7bc8 + b34a4fc commit 342c62b

File tree

7 files changed

+315
-0
lines changed

7 files changed

+315
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
<element name="uploadImageFile" type="input" selector=".file-uploader-area>input"/>
1616
<element name="imageFileName" type="text" selector=".file-uploader-filename"/>
1717
<element name="removeImageButton" type="button" selector=".file-uploader-summary .action-remove"/>
18+
<element name="AddCMSBlock" type="select" selector="//*[@name='landing_page']"/>
1819
</section>
1920
</sections>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminCategoryDisplaySettingsSection">
12+
<element name="settingsHeader" type="button" selector="//*[contains(text(),'Display Settings')]" timeout="30"/>
13+
<element name="displayMode" type="button" selector="//*[@name='display_mode']"/>
14+
</section>
15+
</sections>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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="AdminCreateBlockWithWidget">
12+
<arguments>
13+
<argument name="addCondition" type="string"/>
14+
<argument name="isCondition" type="string"/>
15+
<argument name="fieldCondition" type="string"/>
16+
</arguments>
17+
18+
<click stepKey="clickShowHideButton" selector="{{BlockWYSIWYGSection.ShowHideBtn}}"/>
19+
<waitForElementVisible stepKey="waitForInsertWidgetButton" selector="{{CatalogWidgetSection.insertWidgetButton}}"/>
20+
21+
<selectOption stepKey="selectAllStoreView" userInput="All Store Views" selector="{{CatalogWidgetSection.storeViewOption}}"/>
22+
<fillField selector="{{BlockContentSection.TextArea}}" userInput="" stepKey="makeContentFieldEmpty"/>
23+
24+
<click selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="clickInsertWidgetButton"/>
25+
<waitForElementVisible stepKey="waitForInsertWidgetFrame" selector="{{InsertWidgetSection.widgetTypeDropDown}}" time="10"/>
26+
27+
<selectOption selector="{{InsertWidgetSection.widgetTypeDropDown}}" userInput="Catalog Products List" stepKey="selectCatalogProductListOption"/>
28+
<waitForElementVisible stepKey="waitForConditionsElementBecomeAvailable" selector="{{InsertWidgetSection.conditionsAddButton}}"/>
29+
30+
<click selector="{{InsertWidgetSection.conditionsAddButton}}" stepKey="clickToAddCondition"/>
31+
<waitForElementVisible stepKey="waitForSelectBoxOpened" selector="{{InsertWidgetSection.conditionsSelectBox}}"/>
32+
33+
<selectOption selector="{{InsertWidgetSection.conditionsSelectBox}}" userInput="{{addCondition}}" stepKey="selectConditionsSelectBox"/>
34+
<waitForElementVisible stepKey="seeConditionsAdded" selector="{{InsertWidgetSection.addCondition('1')}}"/>
35+
36+
<click selector="{{InsertWidgetSection.conditionIs}}" stepKey="clickToConditionIs"/>
37+
<selectOption selector="{{InsertWidgetSection.conditionOperator('1')}}" stepKey="selectOperatorGreaterThan" userInput="{{isCondition}}"/>
38+
39+
<click selector="{{InsertWidgetSection.addCondition('1')}}" stepKey="clickAddConditionItem"/>
40+
<waitForElementVisible stepKey="waitForConditionFieldOpened" selector="{{InsertWidgetSection.conditionField('1')}}"/>
41+
42+
<fillField selector="{{InsertWidgetSection.conditionField('1')}}" stepKey="setOperator" userInput="{{fieldCondition}}"/>
43+
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidget"/>
44+
45+
<waitForElementVisible stepKey="waitForInsertWidgetSaved" selector="{{InsertWidgetSection.save}}"/>
46+
<click stepKey="clickSaveButton" selector="{{InsertWidgetSection.save}}"/>
47+
<see userInput="You saved the block." stepKey="seeSavedBlockMsgOnForm"/>
48+
</actionGroup>
49+
</actionGroups>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="CatalogWidgetSection">
10+
<element name="insertWidgetButton" type="button" selector=".scalable.action-add-widget.plugin"/>
11+
<element name="storeViewOption" type="button" selector="//*[@name='store_id']"/>
12+
</section>
13+
14+
<section name="InsertWidgetSection">
15+
<element name="widgetTypeDropDown" type="select" selector="#select_widget_type"/>
16+
<element name="conditionsAddButton" type="button" selector=".rule-param.rule-param-new-child"/>
17+
<element name="conditionsSelectBox" type="button" selector="#conditions__1__new_child"/>
18+
<element name="addCondition" type="button" selector="//*[@id='conditions__1--{{arg1}}__value']/../preceding-sibling::a" parameterized="true"/>
19+
<element name="conditionField" type="button" selector="#conditions__1--{{arg2}}__value" parameterized="true"/>
20+
<element name="save" type="button" selector="#save-button"/>
21+
<element name="conditionIs" type="button" selector="//*[@id='conditions__1--1__attribute']/following-sibling::span[1]"/>
22+
<element name="conditionOperator" type="button" selector="#conditions__1--{{arg3}}__operator" parameterized="true"/>
23+
<element name="checkElementStorefrontByPrice" type="button" selector="//*[@class='product-items widget-product-grid']//*[contains(text(),'${{arg4}}.00')]" parameterized="true"/>
24+
</section>
25+
</sections>
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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="CatalogProductListWidgetOperatorsTest">
12+
<annotations>
13+
<features value="CatalogWidget"/>
14+
<stories value="MAGETWO-91609: Problems with operator more/less in the 'catalog Products List' widget"/>
15+
<title value="Checking operator more/less in the 'catalog Products List' widget"/>
16+
<description value="Check 'less than', 'equals or greater than', 'equals or less than' operators"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MAGETWO-94479"/>
19+
<group value="CatalogWidget"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="SimpleSubCategory" stepKey="simplecategory"/>
24+
<createData entity="SimpleProduct" stepKey="createFirstProduct">
25+
<requiredEntity createDataKey="simplecategory"/>
26+
<field key="price">10</field>
27+
</createData>
28+
<createData entity="SimpleProduct" stepKey="createSecondProduct">
29+
<requiredEntity createDataKey="simplecategory"/>
30+
<field key="price">50</field>
31+
</createData>
32+
<createData entity="SimpleProduct" stepKey="createThirdProduct">
33+
<requiredEntity createDataKey="simplecategory"/>
34+
<field key="price">100</field>
35+
</createData>
36+
37+
<createData entity="_defaultBlock" stepKey="createPreReqBlock"/>
38+
<!--User log in on back-end as admin-->
39+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
40+
<actionGroup ref="EnabledWYSIWYG" stepKey="enableWYSIWYG"/>
41+
</before>
42+
43+
<!--Open block with widget.-->
44+
<actionGroup ref="navigateToCreatedCMSBlockPage" stepKey="navigateToCreatedCMSBlockPage1">
45+
<argument name="CMSBlockPage" value="$$createPreReqBlock$$"/>
46+
</actionGroup>
47+
48+
<actionGroup ref="AdminCreateBlockWithWidget" stepKey="adminCreateBlockWithWidget">
49+
<argument name="addCondition" value="Price"/>
50+
<argument name="isCondition" value="greater than"/>
51+
<argument name="fieldCondition" value="20"/>
52+
</actionGroup>
53+
54+
<!--Go to Catalog > Categories (choose category where created products)-->
55+
<amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/>
56+
<waitForPageLoad stepKey="waitForCategoryPageLoadAddProducts" after="onCategoryIndexPage"/>
57+
<click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickExpandAll" after="waitForCategoryPageLoadAddProducts"/>
58+
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickCategoryLink"/>
59+
<waitForPageLoad stepKey="waitForCategoryPageLoad"/>
60+
61+
<!--Content > Add CMS Block: name saved block-->
62+
<waitForElementVisible selector="{{AdminCategoryContentSection.sectionHeader}}" stepKey="waitForContentSection"/>
63+
<conditionalClick selector="{{AdminCategoryContentSection.sectionHeader}}" dependentSelector="{{AdminCategoryContentSection.uploadButton}}" visible="false" stepKey="openContentSection"/>
64+
<waitForPageLoad stepKey="waitForContentLoad"/>
65+
66+
<selectOption selector="{{AdminCategoryContentSection.AddCMSBlock}}" stepKey="selectSavedBlock" userInput="{{_defaultBlock.title}}"/>
67+
68+
<!--Display Settings > Display Mode: Static block only-->
69+
<waitForElementVisible selector="{{AdminCategoryDisplaySettingsSection.settingsHeader}}" stepKey="waitForDisplaySettingsSection"/>
70+
<conditionalClick selector="{{AdminCategoryDisplaySettingsSection.settingsHeader}}" dependentSelector="{{AdminCategoryDisplaySettingsSection.displayMode}}" visible="false" stepKey="openDisplaySettingsSection"/>
71+
<waitForPageLoad stepKey="waitForDisplaySettingsLoad"/>
72+
<selectOption stepKey="selectStaticBlockOnlyOption" userInput="Static block only" selector="{{AdminCategoryDisplaySettingsSection.displayMode}}"/>
73+
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategoryWithProducts"/>
74+
<waitForPageLoad stepKey="waitForCategorySaved"/>
75+
<see userInput="You saved the category." stepKey="seeSuccessMessage"/>
76+
77+
<!--Go to Storefront > category-->
78+
<amOnPage url="$$simplecategory.name$$.html" stepKey="goToStorefrontCategoryPage"/>
79+
<waitForPageLoad stepKey="waitForStorefrontPageLoaded"/>
80+
81+
<!--Check operators Greater than-->
82+
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="dontSeeElementByPrice20"/>
83+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('50')}}" stepKey="seeElementByPrice50"/>
84+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('100')}}" stepKey="seeElementByPrice100"/>
85+
86+
<!--Open block with widget.-->
87+
<actionGroup ref="navigateToCreatedCMSBlockPage" stepKey="navigateToCreatedCMSBlockPage2">
88+
<argument name="CMSBlockPage" value="$$createPreReqBlock$$"/>
89+
</actionGroup>
90+
91+
<actionGroup ref="AdminCreateBlockWithWidget" stepKey="adminCreateBlockWithWidgetLessThan">
92+
<argument name="addCondition" value="Price"/>
93+
<argument name="isCondition" value="less than"/>
94+
<argument name="fieldCondition" value="20"/>
95+
</actionGroup>
96+
97+
<!--Go to Storefront > category-->
98+
<amOnPage url="$$simplecategory.name$$.html" stepKey="goToStorefrontCategoryPage2"/>
99+
<waitForPageLoad stepKey="waitForStorefrontPageLoaded2"/>
100+
101+
<!--Check operators Greater than-->
102+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="seeElementByPrice20"/>
103+
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('50')}}" stepKey="dontSeeElementByPrice50"/>
104+
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('100')}}" stepKey="dontSeeElementByPrice100"/>
105+
106+
<!--Open block with widget.-->
107+
<actionGroup ref="navigateToCreatedCMSBlockPage" stepKey="navigateToCreatedCMSBlockPage3">
108+
<argument name="CMSBlockPage" value="$$createPreReqBlock$$"/>
109+
</actionGroup>
110+
111+
<actionGroup ref="AdminCreateBlockWithWidget" stepKey="adminCreateBlockWithWidgetEqualsOrGreaterThan">
112+
<argument name="addCondition" value="Price"/>
113+
<argument name="isCondition" value="equals or greater than"/>
114+
<argument name="fieldCondition" value="50"/>
115+
</actionGroup>
116+
117+
<!--Go to Storefront > category-->
118+
<amOnPage url="$$simplecategory.name$$.html" stepKey="goToStorefrontCategoryPage3"/>
119+
<waitForPageLoad stepKey="waitForStorefrontPageLoaded3"/>
120+
121+
<!--Check operators Greater than-->
122+
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="dontSeeElementByPrice20s"/>
123+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('50')}}" stepKey="seeElementByPrice50s"/>
124+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('100')}}" stepKey="seeElementByPrice100s"/>
125+
126+
<!--Open block with widget.-->
127+
<actionGroup ref="navigateToCreatedCMSBlockPage" stepKey="navigateToCreatedCMSBlockPage4">
128+
<argument name="CMSBlockPage" value="$$createPreReqBlock$$"/>
129+
</actionGroup>
130+
131+
<actionGroup ref="AdminCreateBlockWithWidget" stepKey="adminCreateBlockWithWidgetEqualsOrLessThan">
132+
<argument name="addCondition" value="Price"/>
133+
<argument name="isCondition" value="equals or less than"/>
134+
<argument name="fieldCondition" value="50"/>
135+
</actionGroup>
136+
137+
<!--Go to Storefront > category-->
138+
<amOnPage url="$$simplecategory.name$$.html" stepKey="goToStorefrontCategoryPage4"/>
139+
<waitForPageLoad stepKey="waitForStorefrontPageLoaded4"/>
140+
141+
<!--Check operators Greater than-->
142+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="seeElementByPrice20s"/>
143+
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('50')}}" stepKey="seeElementByPrice50t"/>
144+
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('100')}}" stepKey="dontSeeElementByPrice100s"/>
145+
146+
<after>
147+
<actionGroup ref="DisabledWYSIWYG" stepKey="disableWYSIWYG"/>
148+
<deleteData createDataKey="createPreReqBlock" stepKey="deletePreReqBlock" />
149+
<deleteData createDataKey="simplecategory" stepKey="deleteSimpleCategory"/>
150+
<deleteData createDataKey="createFirstProduct" stepKey="deleteFirstProduct"/>
151+
<deleteData createDataKey="createSecondProduct" stepKey="deleteSecondProduct"/>
152+
<deleteData createDataKey="createThirdProduct" stepKey="deleteThirdProduct"/>
153+
<actionGroup ref="logout" stepKey="logout"/>
154+
</after>
155+
</test>
156+
</tests>

app/code/Magento/Rule/Model/Condition/Sql/Builder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ class Builder
3232
'==' => ':field = ?',
3333
'!=' => ':field <> ?',
3434
'>=' => ':field >= ?',
35+
'&gt;=' => ':field >= ?',
3536
'>' => ':field > ?',
37+
'&gt;' => ':field > ?',
3638
'<=' => ':field <= ?',
39+
'&lt;=' => ':field <= ?',
3740
'<' => ':field < ?',
41+
'&lt;' => ':field < ?',
3842
'{}' => ':field IN (?)',
3943
'!{}' => ':field NOT IN (?)',
4044
'()' => ':field IN (?)',

app/code/Magento/Rule/Test/Unit/Model/Condition/Sql/BuilderTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,69 @@ public function testAttachConditionToCollection()
7272

7373
$this->_builder->attachConditionToCollection($collection, $combine);
7474
}
75+
76+
/**
77+
* Test for attach condition to collection with operator in html format
78+
*
79+
* @covers \Magento\Rule\Model\Condition\Sql\Builder::attachConditionToCollection()
80+
* @return void;
81+
*/
82+
public function testAttachConditionAsHtmlToCollection()
83+
{
84+
$abstractCondition = $this->getMockForAbstractClass(
85+
\Magento\Rule\Model\Condition\AbstractCondition::class,
86+
[],
87+
'',
88+
false,
89+
false,
90+
true,
91+
['getOperatorForValidate', 'getMappedSqlField', 'getAttribute', 'getBindArgumentValue']
92+
);
93+
94+
$abstractCondition->expects($this->once())->method('getMappedSqlField')->will($this->returnValue('argument'));
95+
$abstractCondition->expects($this->once())->method('getOperatorForValidate')->will($this->returnValue('&gt;'));
96+
$abstractCondition->expects($this->at(1))->method('getAttribute')->will($this->returnValue('attribute'));
97+
$abstractCondition->expects($this->at(2))->method('getAttribute')->will($this->returnValue('attribute'));
98+
$abstractCondition->expects($this->once())->method('getBindArgumentValue')->will($this->returnValue(10));
99+
100+
$conditions = [$abstractCondition];
101+
$collection = $this->createPartialMock(
102+
\Magento\Eav\Model\Entity\Collection\AbstractCollection::class,
103+
[
104+
'getResource',
105+
'getSelect'
106+
]
107+
);
108+
$combine = $this->createPartialMock(
109+
\Magento\Rule\Model\Condition\Combine::class,
110+
[
111+
'getConditions',
112+
'getValue',
113+
'getAggregator'
114+
]
115+
);
116+
117+
$resource = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['getConnection']);
118+
$select = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['where']);
119+
$select->expects($this->never())->method('where');
120+
121+
$connection = $this->getMockForAbstractClass(
122+
\Magento\Framework\DB\Adapter\AdapterInterface::class,
123+
['quoteInto'],
124+
'',
125+
false
126+
);
127+
128+
$connection->expects($this->once())->method('quoteInto')->with(' > ?', 10)->will($this->returnValue(' > 10'));
129+
$collection->expects($this->once())->method('getResource')->will($this->returnValue($resource));
130+
$resource->expects($this->once())->method('getConnection')->will($this->returnValue($connection));
131+
$combine->expects($this->once())->method('getValue')->willReturn('attribute');
132+
$combine->expects($this->once())->method('getAggregator')->willReturn(' AND ');
133+
$combine->expects($this->at(0))->method('getConditions')->will($this->returnValue($conditions));
134+
$combine->expects($this->at(1))->method('getConditions')->will($this->returnValue($conditions));
135+
$combine->expects($this->at(2))->method('getConditions')->will($this->returnValue($conditions));
136+
$combine->expects($this->at(3))->method('getConditions')->will($this->returnValue($conditions));
137+
138+
$this->_builder->attachConditionToCollection($collection, $combine);
139+
}
75140
}

0 commit comments

Comments
 (0)