Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
VladimirZaets authored Nov 26, 2019
2 parents f2d026d + 3fc0360 commit 2bd4cb5
Show file tree
Hide file tree
Showing 17 changed files with 686 additions and 3 deletions.
98 changes: 98 additions & 0 deletions app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Captcha\Test\Unit\CustomerData;

use Magento\Captcha\Helper\Data as CaptchaHelper;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Captcha\CustomerData\Captcha;
use Magento\Captcha\Model\DefaultModel;
use Magento\Customer\Api\Data\CustomerInterface as CustomerData;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\TestCase;

class CaptchaTest extends TestCase
{
/**
* @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject
*/
private $helperMock;

/**
* @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject
*/
private $customerSessionMock;

/**
* @var Captcha
*/
private $model;

/**
* @var array
*/
private $formIds;

/**
* @var ObjectManagerHelper
*/
protected $objectManagerHelper;

/**
* Create mocks and model
*/
protected function setUp()
{
$this->helperMock = $this->createMock(CaptchaHelper::class);
$this->customerSessionMock = $this->createMock(CustomerSession::class);
$this->formIds = [
'user_login'
];
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $this->objectManagerHelper->getObject(
Captcha::class,
[
'helper' => $this->helperMock,
'formIds' => $this->formIds,
'customerSession' => $this->customerSessionMock
]
);
}

/**
* Test getSectionData() when user is login and require captcha
*/
public function testGetSectionDataWhenLoginAndRequireCaptcha()
{
$emailLogin = '[email protected]';

$userLoginModel = $this->createMock(DefaultModel::class);
$userLoginModel->expects($this->any())->method('isRequired')->with($emailLogin)
->willReturn(true);
$this->helperMock->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel);

$this->customerSessionMock->expects($this->any())->method('isLoggedIn')
->willReturn(true);

$customerDataMock = $this->createMock(CustomerData::class);
$customerDataMock->expects($this->any())->method('getEmail')->willReturn($emailLogin);
$this->customerSessionMock->expects($this->any())->method('getCustomerData')
->willReturn($customerDataMock);

/* Assert to test */
$this->assertEquals(
[
"user_login" => [
"isRequired" => true,
"timestamp" => time()
]
],
$this->model->getSectionData()
);
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ protected function _getNodeJson($node, $level = 0)
public function buildNodeName($node)
{
$result = $this->escapeHtml($node->getName());
$result .= ' (ID: ' . $node->getId() . ')';
if ($this->_withProductCount) {
$result .= ' (' . $node->getProductCount() . ')';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
userInput="$$createProduct1.name$$" stepKey="seeProductName4"/>
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
userInput="$$createProduct12.name$$" stepKey="seeProductName5"/>
<waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount"/>
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount"/>
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName"/>
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"
Expand All @@ -151,7 +151,7 @@
userInput="$$createProduct2.name$$" stepKey="seeProductName6"/>
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
userInput="$$createProduct12.name$$" stepKey="seeProductName7"/>
<waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount2"/>
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount2"/>
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName2"/>
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,23 @@
<click selector="{{AdminNewCatalogPriceRuleConditions.activeConditionApplyButton}}" stepKey="clickApply"/>
<waitForElementNotVisible selector="{{AdminNewCatalogPriceRuleConditions.activeConditionApplyButton}}" stepKey="waitForApplyButtonInvisibility"/>
</actionGroup>

<actionGroup name="newCatalogPriceRuleWithInvalidData">
<annotations>
<description>Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data.</description>
</annotations>
<arguments>
<argument name="catalogRule" defaultValue="catalogRuleWithInvalid"/>
</arguments>

<!-- Go to the admin Catalog rule grid and add a new one -->
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
<waitForPageLoad stepKey="waitForPriceRulePage"/>

<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
<fillField stepKey="fillPriority" selector="{{AdminNewCatalogPriceRule.priority}}" userInput="{{catalogRule.priority}}"/>
<scrollToTopOfPage stepKey="scrollToTop"/>
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/>
<waitForPageLoad stepKey="waitForApplied"/>
</actionGroup>
</actionGroups>
15 changes: 15 additions & 0 deletions app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,19 @@
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
<data key="defaultStoreView">Free Shipping in conditions</data>
</entity>

<entity name="catalogRuleWithInvalid" type="catalogRule">
<data key="name" unique="suffix">CatalogPriceRule</data>
<data key="description">Catalog Price Rule Description</data>
<data key="is_active">1</data>
<array key="customer_group_ids">
<item>0</item>
</array>
<array key="website_ids">
<item>1</item>
</array>
<data key="simple_action">by_percent</data>
<data key="discount_amount">10</data>
<data key="priority">ten</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
<element name="priority" type="input" selector="[name='sort_order']"/>
<element name="conditionsTab" type="block" selector="[data-index='block_promo_catalog_edit_tab_conditions']"/>
<element name="actionsTab" type="block" selector="[data-index='actions']"/>

<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
</section>

<section name="AdminNewCatalogPriceRuleActions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,27 @@
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createProduct.name$$" stepKey="seeProduct2"/>
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$123.00" stepKey="seeDiscountedPrice2"/>
</test>

<test name="AdminCreateCatalogPriceRuleWithInvalidDataTest">
<annotations>
<features value="CatalogRule"/>
<stories value="Create Catalog Price Rule"/>
<title value="Admin can not create catalog price rule with the invalid data"/>
<description value="Admin can not create catalog price rule with the invalid data"/>
<severity value="MAJOR"/>
<group value="CatalogRule"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
</before>
<after>
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
</after>

<actionGroup ref="newCatalogPriceRuleWithInvalidData" stepKey="createNewPriceRule">
<argument name="catalogRule" value="catalogRuleWithInvalid"/>
</actionGroup>

<see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seeSortOrderError"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
</item>
</argument>
<settings>
<validation>
<rule name="validate-digits" xsi:type="boolean">true</rule>
</validation>
<dataType>text</dataType>
<label translate="true">Priority</label>
<dataScope>sort_order</dataScope>
Expand Down
115 changes: 115 additions & 0 deletions app/code/Magento/Directory/Setup/Patch/Data/AddDataForColombia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Directory\Setup\Patch\Data;

use Magento\Directory\Setup\DataInstaller;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

/**
* Class AddDataForColombia
*/
class AddDataForColombia implements DataPatchInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

/**
* @var \Magento\Directory\Setup\DataInstallerFactory
*/
private $dataInstallerFactory;

/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
\Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->dataInstallerFactory = $dataInstallerFactory;
}

/**
* @inheritdoc
*/
public function apply()
{
/** @var DataInstaller $dataInstaller */
$dataInstaller = $this->dataInstallerFactory->create();
$dataInstaller->addCountryRegions(
$this->moduleDataSetup->getConnection(),
$this->getDataForColombia()
);
}

/**
* Colombia states data.
*
* @return array
*/
private function getDataForColombia()
{
return [
['CO', 'CO-AMA', 'Amazonas'],
['CO', 'CO-ANT', 'Antioquia'],
['CO', 'CO-ARA', 'Arauca'],
['CO', 'CO-ATL', 'Atlántico'],
['CO', 'CO-BOL', 'Bolívar'],
['CO', 'CO-BOY', 'Boyacá'],
['CO', 'CO-CAL', 'Caldas'],
['CO', 'CO-CAQ', 'Caquetá'],
['CO', 'CO-CAS', 'Casanare'],
['CO', 'CO-CAU', 'Cauca'],
['CO', 'CO-CES', 'Cesar'],
['CO', 'CO-CHO', 'Chocó'],
['CO', 'CO-COR', 'Córdoba'],
['CO', 'CO-CUN', 'Cundinamarca'],
['CO', 'CO-GUA', 'Guainía'],
['CO', 'CO-GUV', 'Guaviare'],
['CO', 'CO-HUL', 'Huila'],
['CO', 'CO-LAG', 'La Guajira'],
['CO', 'CO-MAG', 'Magdalena'],
['CO', 'CO-MET', 'Meta'],
['CO', 'CO-NAR', 'Nariño'],
['CO', 'CO-NSA', 'Norte de Santander'],
['CO', 'CO-PUT', 'Putumayo'],
['CO', 'CO-QUI', 'Quindío'],
['CO', 'CO-RIS', 'Risaralda'],
['CO', 'CO-SAP', 'San Andrés y Providencia'],
['CO', 'CO-SAN', 'Santander'],
['CO', 'CO-SUC', 'Sucre'],
['CO', 'CO-TOL', 'Tolima'],
['CO', 'CO-VAC', 'Valle del Cauca'],
['CO', 'CO-VAU', 'Vaupés'],
['CO', 'CO-VID', 'Vichada'],
];
}

/**
* @inheritdoc
*/
public static function getDependencies()
{
return [
InitializeDirectoryData::class,
];
}

/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
}
Loading

0 comments on commit 2bd4cb5

Please sign in to comment.