Skip to content

Commit 2bd4cb5

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Accepted Community Pull Requests: - #25706: [Tax] Cover Tax CustomerData by Unit Test (by @edenduong) - #25717: add the id of the category to the category tree names (by @brosenberger) - #25719: ASI #Issue-723 Fixed the issue: "Image preview should be closed when the page is changed" (by @serhiyzhovnir) - #25686: Unit Test to cover class \Magento\Captcha\CustomerData\Captcha (by @edenduong) - #25702: [ImportExport] Cover Helper Data by Unit Test (by @edenduong) - #25313: feature/25312 Add Colombian regions (by @magudelo62) - #25172: Add validation in catalog rule and shopping cart rule form (by @edenduong) - #25566: The image details are not hidden when click on same image (by @engcom-Golf) Fixed GitHub Issues: - #723: Magento JMeter Performance Testing best practices (reported by @pmouawad) has been fixed in #25719 by @serhiyzhovnir in 2.3-develop branch Related commits: 1. f307e2e - #25312: Add Colombian regions (reported by @magudelo62) has been fixed in #25313 by @magudelo62 in 2.3-develop branch Related commits: 1. a9f499e - #690: Media image attribute in product listing (reported by @tzyganu) has been fixed in #25566 by @engcom-Golf in 2.3-develop branch Related commits: 1. f070206 2. c23393d 3. aa7195a 4. e29914e 5. a565ee0 6. b30b855 7. a7ffbd6 8. e5d143d
2 parents f2d026d + 3fc0360 commit 2bd4cb5

File tree

17 files changed

+686
-3
lines changed

17 files changed

+686
-3
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Captcha\Test\Unit\CustomerData;
10+
11+
use Magento\Captcha\Helper\Data as CaptchaHelper;
12+
use Magento\Customer\Model\Session as CustomerSession;
13+
use Magento\Captcha\CustomerData\Captcha;
14+
use Magento\Captcha\Model\DefaultModel;
15+
use Magento\Customer\Api\Data\CustomerInterface as CustomerData;
16+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
17+
use PHPUnit\Framework\TestCase;
18+
19+
class CaptchaTest extends TestCase
20+
{
21+
/**
22+
* @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
private $helperMock;
25+
26+
/**
27+
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
28+
*/
29+
private $customerSessionMock;
30+
31+
/**
32+
* @var Captcha
33+
*/
34+
private $model;
35+
36+
/**
37+
* @var array
38+
*/
39+
private $formIds;
40+
41+
/**
42+
* @var ObjectManagerHelper
43+
*/
44+
protected $objectManagerHelper;
45+
46+
/**
47+
* Create mocks and model
48+
*/
49+
protected function setUp()
50+
{
51+
$this->helperMock = $this->createMock(CaptchaHelper::class);
52+
$this->customerSessionMock = $this->createMock(CustomerSession::class);
53+
$this->formIds = [
54+
'user_login'
55+
];
56+
$this->objectManagerHelper = new ObjectManagerHelper($this);
57+
$this->model = $this->objectManagerHelper->getObject(
58+
Captcha::class,
59+
[
60+
'helper' => $this->helperMock,
61+
'formIds' => $this->formIds,
62+
'customerSession' => $this->customerSessionMock
63+
]
64+
);
65+
}
66+
67+
/**
68+
* Test getSectionData() when user is login and require captcha
69+
*/
70+
public function testGetSectionDataWhenLoginAndRequireCaptcha()
71+
{
72+
$emailLogin = 'test@localhost.com';
73+
74+
$userLoginModel = $this->createMock(DefaultModel::class);
75+
$userLoginModel->expects($this->any())->method('isRequired')->with($emailLogin)
76+
->willReturn(true);
77+
$this->helperMock->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel);
78+
79+
$this->customerSessionMock->expects($this->any())->method('isLoggedIn')
80+
->willReturn(true);
81+
82+
$customerDataMock = $this->createMock(CustomerData::class);
83+
$customerDataMock->expects($this->any())->method('getEmail')->willReturn($emailLogin);
84+
$this->customerSessionMock->expects($this->any())->method('getCustomerData')
85+
->willReturn($customerDataMock);
86+
87+
/* Assert to test */
88+
$this->assertEquals(
89+
[
90+
"user_login" => [
91+
"isRequired" => true,
92+
"timestamp" => time()
93+
]
94+
],
95+
$this->model->getSectionData()
96+
);
97+
}
98+
}

app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ protected function _getNodeJson($node, $level = 0)
407407
public function buildNodeName($node)
408408
{
409409
$result = $this->escapeHtml($node->getName());
410+
$result .= ' (ID: ' . $node->getId() . ')';
410411
if ($this->_withProductCount) {
411412
$result .= ' (' . $node->getProductCount() . ')';
412413
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
userInput="$$createProduct1.name$$" stepKey="seeProductName4"/>
132132
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
133133
userInput="$$createProduct12.name$$" stepKey="seeProductName5"/>
134-
<waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount"/>
134+
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount"/>
135135
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
136136
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName"/>
137137
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"
@@ -151,7 +151,7 @@
151151
userInput="$$createProduct2.name$$" stepKey="seeProductName6"/>
152152
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
153153
userInput="$$createProduct12.name$$" stepKey="seeProductName7"/>
154-
<waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount2"/>
154+
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount2"/>
155155
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
156156
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName2"/>
157157
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,23 @@
233233
<click selector="{{AdminNewCatalogPriceRuleConditions.activeConditionApplyButton}}" stepKey="clickApply"/>
234234
<waitForElementNotVisible selector="{{AdminNewCatalogPriceRuleConditions.activeConditionApplyButton}}" stepKey="waitForApplyButtonInvisibility"/>
235235
</actionGroup>
236+
237+
<actionGroup name="newCatalogPriceRuleWithInvalidData">
238+
<annotations>
239+
<description>Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data.</description>
240+
</annotations>
241+
<arguments>
242+
<argument name="catalogRule" defaultValue="catalogRuleWithInvalid"/>
243+
</arguments>
244+
245+
<!-- Go to the admin Catalog rule grid and add a new one -->
246+
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
247+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
248+
249+
<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
250+
<fillField stepKey="fillPriority" selector="{{AdminNewCatalogPriceRule.priority}}" userInput="{{catalogRule.priority}}"/>
251+
<scrollToTopOfPage stepKey="scrollToTop"/>
252+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/>
253+
<waitForPageLoad stepKey="waitForApplied"/>
254+
</actionGroup>
236255
</actionGroups>

app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,19 @@
173173
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
174174
<data key="defaultStoreView">Free Shipping in conditions</data>
175175
</entity>
176+
177+
<entity name="catalogRuleWithInvalid" type="catalogRule">
178+
<data key="name" unique="suffix">CatalogPriceRule</data>
179+
<data key="description">Catalog Price Rule Description</data>
180+
<data key="is_active">1</data>
181+
<array key="customer_group_ids">
182+
<item>0</item>
183+
</array>
184+
<array key="website_ids">
185+
<item>1</item>
186+
</array>
187+
<data key="simple_action">by_percent</data>
188+
<data key="discount_amount">10</data>
189+
<data key="priority">ten</data>
190+
</entity>
176191
</entities>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
<element name="priority" type="input" selector="[name='sort_order']"/>
3838
<element name="conditionsTab" type="block" selector="[data-index='block_promo_catalog_edit_tab_conditions']"/>
3939
<element name="actionsTab" type="block" selector="[data-index='actions']"/>
40+
41+
<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
4042
</section>
4143

4244
<section name="AdminNewCatalogPriceRuleActions">

app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,27 @@
196196
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createProduct.name$$" stepKey="seeProduct2"/>
197197
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$123.00" stepKey="seeDiscountedPrice2"/>
198198
</test>
199+
200+
<test name="AdminCreateCatalogPriceRuleWithInvalidDataTest">
201+
<annotations>
202+
<features value="CatalogRule"/>
203+
<stories value="Create Catalog Price Rule"/>
204+
<title value="Admin can not create catalog price rule with the invalid data"/>
205+
<description value="Admin can not create catalog price rule with the invalid data"/>
206+
<severity value="MAJOR"/>
207+
<group value="CatalogRule"/>
208+
</annotations>
209+
<before>
210+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
211+
</before>
212+
<after>
213+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
214+
</after>
215+
216+
<actionGroup ref="newCatalogPriceRuleWithInvalidData" stepKey="createNewPriceRule">
217+
<argument name="catalogRule" value="catalogRuleWithInvalid"/>
218+
</actionGroup>
219+
220+
<see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seeSortOrderError"/>
221+
</test>
199222
</tests>

app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@
208208
</item>
209209
</argument>
210210
<settings>
211+
<validation>
212+
<rule name="validate-digits" xsi:type="boolean">true</rule>
213+
</validation>
211214
<dataType>text</dataType>
212215
<label translate="true">Priority</label>
213216
<dataScope>sort_order</dataScope>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Directory\Setup\Patch\Data;
10+
11+
use Magento\Directory\Setup\DataInstaller;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
/**
16+
* Class AddDataForColombia
17+
*/
18+
class AddDataForColombia implements DataPatchInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var \Magento\Directory\Setup\DataInstallerFactory
27+
*/
28+
private $dataInstallerFactory;
29+
30+
/**
31+
* @param ModuleDataSetupInterface $moduleDataSetup
32+
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
33+
*/
34+
public function __construct(
35+
ModuleDataSetupInterface $moduleDataSetup,
36+
\Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
37+
) {
38+
$this->moduleDataSetup = $moduleDataSetup;
39+
$this->dataInstallerFactory = $dataInstallerFactory;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function apply()
46+
{
47+
/** @var DataInstaller $dataInstaller */
48+
$dataInstaller = $this->dataInstallerFactory->create();
49+
$dataInstaller->addCountryRegions(
50+
$this->moduleDataSetup->getConnection(),
51+
$this->getDataForColombia()
52+
);
53+
}
54+
55+
/**
56+
* Colombia states data.
57+
*
58+
* @return array
59+
*/
60+
private function getDataForColombia()
61+
{
62+
return [
63+
['CO', 'CO-AMA', 'Amazonas'],
64+
['CO', 'CO-ANT', 'Antioquia'],
65+
['CO', 'CO-ARA', 'Arauca'],
66+
['CO', 'CO-ATL', 'Atlántico'],
67+
['CO', 'CO-BOL', 'Bolívar'],
68+
['CO', 'CO-BOY', 'Boyacá'],
69+
['CO', 'CO-CAL', 'Caldas'],
70+
['CO', 'CO-CAQ', 'Caquetá'],
71+
['CO', 'CO-CAS', 'Casanare'],
72+
['CO', 'CO-CAU', 'Cauca'],
73+
['CO', 'CO-CES', 'Cesar'],
74+
['CO', 'CO-CHO', 'Chocó'],
75+
['CO', 'CO-COR', 'Córdoba'],
76+
['CO', 'CO-CUN', 'Cundinamarca'],
77+
['CO', 'CO-GUA', 'Guainía'],
78+
['CO', 'CO-GUV', 'Guaviare'],
79+
['CO', 'CO-HUL', 'Huila'],
80+
['CO', 'CO-LAG', 'La Guajira'],
81+
['CO', 'CO-MAG', 'Magdalena'],
82+
['CO', 'CO-MET', 'Meta'],
83+
['CO', 'CO-NAR', 'Nariño'],
84+
['CO', 'CO-NSA', 'Norte de Santander'],
85+
['CO', 'CO-PUT', 'Putumayo'],
86+
['CO', 'CO-QUI', 'Quindío'],
87+
['CO', 'CO-RIS', 'Risaralda'],
88+
['CO', 'CO-SAP', 'San Andrés y Providencia'],
89+
['CO', 'CO-SAN', 'Santander'],
90+
['CO', 'CO-SUC', 'Sucre'],
91+
['CO', 'CO-TOL', 'Tolima'],
92+
['CO', 'CO-VAC', 'Valle del Cauca'],
93+
['CO', 'CO-VAU', 'Vaupés'],
94+
['CO', 'CO-VID', 'Vichada'],
95+
];
96+
}
97+
98+
/**
99+
* @inheritdoc
100+
*/
101+
public static function getDependencies()
102+
{
103+
return [
104+
InitializeDirectoryData::class,
105+
];
106+
}
107+
108+
/**
109+
* @inheritdoc
110+
*/
111+
public function getAliases()
112+
{
113+
return [];
114+
}
115+
}

0 commit comments

Comments
 (0)