Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4875 from magento-mpi/MPI-PR-2019-10-07
Browse files Browse the repository at this point in the history
MPI-PR-2019-10-07
  • Loading branch information
dhorytskyi authored Oct 17, 2019
2 parents fc387f4 + 64288fb commit e2ac8c8
Show file tree
Hide file tree
Showing 41 changed files with 1,319 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()) : 0;
<?php if ($block->getSortableUpdateCallback()) : ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.sortableUpdateCallback = <?= /* @noEscape */ $block->getSortableUpdateCallback() ?>;
<?php endif; ?>
<?php if ($block->getFilterKeyPressCallback()) : ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.filterKeyPressCallback = <?= /* @noEscape */ $block->getFilterKeyPressCallback() ?>;
<?php endif; ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.bindSortable();
<?php if ($block->getRowInitCallback()) : ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.initRowCallback = <?= /* @noEscape */ $block->getRowInitCallback() ?>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ $numColumns = count($block->getColumns());
<?php if ($block->getCheckboxCheckCallback()) : ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.checkboxCheckCallback = <?= /* @noEscape */ $block->getCheckboxCheckCallback() ?>;
<?php endif; ?>
<?php if ($block->getFilterKeyPressCallback()) : ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.filterKeyPressCallback = <?= /* @noEscape */ $block->getFilterKeyPressCallback() ?>;
<?php endif; ?>
<?php if ($block->getRowInitCallback()) : ?>
<?= $block->escapeJs($block->getJsObjectName()) ?>.initRowCallback = <?= /* @noEscape */ $block->getRowInitCallback() ?>;
<?= $block->escapeJs($block->getJsObjectName()) ?>.initGridRows();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Braintree\Error\Validation;
use Braintree\Result\Error;
use Braintree\Result\Successful;
use Braintree\Transaction;

/**
* Processes errors codes from Braintree response.
Expand Down Expand Up @@ -38,12 +39,14 @@ public function getErrorCodes($response): array
$result[] = $error->code;
}

if (isset($response->transaction) && $response->transaction->status === 'gateway_rejected') {
$result[] = $response->transaction->gatewayRejectionReason;
}
if (isset($response->transaction) && $response->transaction) {
if ($response->transaction->status === Transaction::GATEWAY_REJECTED) {
$result[] = $response->transaction->gatewayRejectionReason;
}

if (isset($response->transaction) && $response->transaction->status === 'processor_declined') {
$result[] = $response->transaction->processorResponseCode;
if ($response->transaction->status === Transaction::PROCESSOR_DECLINED) {
$result[] = $response->transaction->processorResponseCode;
}
}

return $result;
Expand Down
39 changes: 39 additions & 0 deletions app/code/Magento/Catalog/Model/Product/Hydrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model\Product;

use Magento\Framework\EntityManager\HydratorInterface;

/**
* Class is used to extract data and populate entity with data
*/
class Hydrator implements HydratorInterface
{
/**
* @inheritdoc
*/
public function extract($entity)
{
return $entity->getData();
}

/**
* @inheritdoc
*/
public function hydrate($entity, array $data)
{
$lockedAttributes = $entity->getLockedAttributes();
$entity->unlockAttributes();
$entity->setData(array_merge($entity->getData(), $data));
foreach ($lockedAttributes as $attribute) {
$entity->lockAttribute($attribute);
}

return $entity;
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@
<argument name="hydrators" xsi:type="array">
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Catalog\Model\Product\Hydrator</item>
</argument>
</arguments>
</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ define([
'jquery',
'Magento_Checkout/js/model/new-customer-address',
'Magento_Customer/js/customer-data',
'mage/utils/objects'
], function ($, address, customerData, mageUtils) {
'mage/utils/objects',
'underscore'
], function ($, address, customerData, mageUtils, _) {
'use strict';

var countryData = customerData.get('directory-data');
Expand Down Expand Up @@ -60,13 +61,15 @@ define([
delete addressData['region_id'];

if (addressData['custom_attributes']) {
addressData['custom_attributes'] = Object.entries(addressData['custom_attributes'])
.map(function (customAttribute) {
addressData['custom_attributes'] = _.map(
addressData['custom_attributes'],
function (value, key) {
return {
'attribute_code': customAttribute[0],
'value': customAttribute[1]
'attribute_code': key,
'value': value
};
});
}
);
}

return address(addressData);
Expand Down
30 changes: 30 additions & 0 deletions app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,21 @@
<data key="state">Côtes-d'Armor</data>
<data key="postcode">12345</data>
</entity>
<entity name="updateCustomerChinaAddress" type="address">
<data key="firstname">Xian</data>
<data key="lastname">Shai</data>
<data key="company">Hunan Fenmian</data>
<data key="telephone">+86 851 8410 4337</data>
<array key="street">
<item>Nanyuan Rd, Wudang</item>
<item>Hunan Fenmian</item>
</array>
<data key="country_id">CN</data>
<data key="country">China</data>
<data key="city">Guiyang</data>
<data key="state">Guizhou Sheng</data>
<data key="postcode">550002</data>
</entity>
<entity name="updateCustomerNoXSSInjection" type="address">
<data key="firstname">Jany</data>
<data key="lastname">Doe</data>
Expand Down Expand Up @@ -345,4 +360,19 @@
<data key="default_shipping">Yes</data>
<requiredEntity type="region">RegionAE</requiredEntity>
</entity>
<entity name="updateCustomerBelgiumAddress" type="address">
<data key="firstname">John</data>
<data key="lastname">Doe</data>
<data key="company">Magento</data>
<array key="street">
<item>Chaussee de Wavre</item>
<item>318</item>
</array>
<data key="city">Bihain</data>
<data key="state">Hainaut</data>
<data key="country_id">BE</data>
<data key="country">Belgium</data>
<data key="postcode">6690</data>
<data key="telephone">0477-58-77867</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontUpdateCustomerAddressBelgiumTest">
<annotations>
<stories value="Update Regions list for Belgium country"/>
<title value="Update customer address on storefront with Belgium address"/>
<description value="Update customer address on storefront with Belgium address and verify you can select a region"/>
<testCaseId value="MC-20234"/>
<severity value="AVERAGE"/>
<group value="customer"/>
</annotations>

<before>
<actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/>
<actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser">
<argument name="Customer" value="CustomerEntityOne"/>
</actionGroup>
</before>
<after>
<actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser">
<argument name="email" value="{{CustomerEntityOne.email}}"/>
</actionGroup>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<!--Update customer address Belgium in storefront-->
<actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress">
<argument name="Address" value="updateCustomerBelgiumAddress"/>
</actionGroup>
<!--Verify customer address save success message-->
<see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/>

<!--Verify customer default billing address-->
<actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress">
<argument name="address" value="updateCustomerBelgiumAddress"/>
</actionGroup>

<!--Verify customer default shipping address-->
<actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress">
<argument name="address" value="updateCustomerBelgiumAddress"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontUpdateCustomerAddressChinaTest">
<annotations>
<stories value="Update Regions list for China country"/>
<title value="Update customer address on storefront with china address"/>
<description value="Update customer address on storefront with china address and verify you can select a region"/>
<testCaseId value="MC-20234"/>
<severity value="AVERAGE"/>
<group value="customer"/>
</annotations>

<before>
<actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/>
<actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser">
<argument name="Customer" value="CustomerEntityOne"/>
</actionGroup>
</before>
<after>
<actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser">
<argument name="email" value="{{CustomerEntityOne.email}}"/>
</actionGroup>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<!--Update customer address in storefront-->
<actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress">
<argument name="Address" value="updateCustomerChinaAddress"/>
</actionGroup>
<!--Verify customer address save success message-->
<see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/>

<!--Verify customer default billing address-->
<actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress">
<argument name="address" value="updateCustomerChinaAddress"/>
</actionGroup>

<!--Verify customer default shipping address-->
<actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress">
<argument name="address" value="updateCustomerChinaAddress"/>
</actionGroup>
</test>
</tests>
94 changes: 94 additions & 0 deletions app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelgium.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Directory\Setup\Patch\Data;

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

/**
* Add Regions for Belgium.
*/
class AddDataForBelgium 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->getDataForBelgium()
);
}

/**
* Belgium states data.
*
* @return array
*/
private function getDataForBelgium()
{
return [
['BE', 'VAN', 'Antwerpen'],
['BE', 'WBR', 'Brabant wallon'],
['BE', 'BRU', 'Brussels Hoofdstedelijk Gewest'],
['BE', 'WHT', 'Hainaut'],
['BE', 'VLI', 'Limburg'],
['BE', 'WLG', 'Liege'],
['BE', 'WLX', 'Luxembourg'],
['BE', 'WNA', 'Namur'],
['BE', 'VOV', 'Oost-Vlaanderen'],
['BE', 'VLG', 'Vlaams Gewest'],
['BE', 'VBR', 'Vlaams-Brabant'],
['BE', 'VWV', 'West-Vlaanderen'],
['BE', 'WAL', 'Wallonne, Region']
];
}

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

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

0 comments on commit e2ac8c8

Please sign in to comment.