Skip to content

Commit

Permalink
Merge pull request #4940 from magento-engcom/2.3-develop-expedited-prs
Browse files Browse the repository at this point in the history
[Magento Community Engineering] Community Contributions - 2.3-develop expedited
  • Loading branch information
VladimirZaets authored Oct 30, 2019
2 parents 65763df + eddfd51 commit 23bd4d6
Show file tree
Hide file tree
Showing 26 changed files with 769 additions and 30 deletions.
5 changes: 3 additions & 2 deletions app/code/Magento/Braintree/Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public function __construct(
public function getConfig()
{
$storeId = $this->session->getStoreId();
$isActive = $this->config->isActive($storeId);
return [
'payment' => [
self::CODE => [
'isActive' => $this->config->isActive($storeId),
'clientToken' => $this->getClientToken(),
'isActive' => $isActive,
'clientToken' => $isActive ? $this->getClientToken() : null,
'ccTypesMapper' => $this->config->getCcTypesMapper(),
'sdkUrl' => $this->config->getSdkUrl(),
'hostedFieldsSdkUrl' => $this->config->getHostedFieldsSdkUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,45 @@ protected function setUp()
}

/**
* Run test getConfig method
* Ensure that get config returns correct data if payment is active or not
*
* @param array $config
* @param array $expected
* @dataProvider getConfigDataProvider
*/
public function testGetConfig($config, $expected)
{
$this->braintreeAdapter->expects(static::once())
->method('generate')
->willReturn(self::CLIENT_TOKEN);
if ($config['isActive']) {
$this->braintreeAdapter->expects($this->once())
->method('generate')
->willReturn(self::CLIENT_TOKEN);
} else {
$config = array_replace_recursive(
$this->getConfigDataProvider()[0]['config'],
$config
);
$expected = array_replace_recursive(
$this->getConfigDataProvider()[0]['expected'],
$expected
);
$this->braintreeAdapter->expects($this->never())
->method('generate');
}

foreach ($config as $method => $value) {
$this->config->expects(static::once())
$this->config->expects($this->once())
->method($method)
->willReturn($value);
}

static::assertEquals($expected, $this->configProvider->getConfig());
$this->assertEquals($expected, $this->configProvider->getConfig());
}

/**
* @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken
* @covers \Magento\Braintree\Model\Ui\ConfigProvider::getClientToken
* @dataProvider getClientTokenDataProvider
* @param $merchantAccountId
* @param $params
*/
public function testGetClientToken($merchantAccountId, $params)
{
Expand All @@ -124,7 +139,7 @@ public function getConfigDataProvider()
[
'config' => [
'isActive' => true,
'getCcTypesMapper' => ['visa' => 'VI', 'american-express'=> 'AE'],
'getCcTypesMapper' => ['visa' => 'VI', 'american-express' => 'AE'],
'getSdkUrl' => self::SDK_URL,
'getHostedFieldsSdkUrl' => 'https://sdk.com/test.js',
'getCountrySpecificCardTypeConfig' => [
Expand All @@ -148,7 +163,7 @@ public function getConfigDataProvider()
'ccTypesMapper' => ['visa' => 'VI', 'american-express' => 'AE'],
'sdkUrl' => self::SDK_URL,
'hostedFieldsSdkUrl' => 'https://sdk.com/test.js',
'countrySpecificCardTypes' =>[
'countrySpecificCardTypes' => [
'GB' => ['VI', 'AE'],
'US' => ['DI', 'JCB']
],
Expand All @@ -166,6 +181,19 @@ public function getConfigDataProvider()
]
]
]
],
[
'config' => [
'isActive' => false,
],
'expected' => [
'payment' => [
ConfigProvider::CODE => [
'isActive' => false,
'clientToken' => null,
]
]
]
]
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$resultUrlKey = $this->categoryUrlPathGenerator->getUrlKey($category);
$this->updateUrlKey($category, $resultUrlKey);
} elseif ($useDefaultAttribute) {
if (!$category->isObjectNew()) {
if (!$category->isObjectNew() && $category->getStoreId() === Store::DEFAULT_STORE_ID) {
$resultUrlKey = $category->formatUrlKey($category->getOrigData('name'));
$this->updateUrlKey($category, $resultUrlKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public function testShouldThrowExceptionIfUrlKeyIsEmpty($useDefaultUrlKey, $isOb
$this->expectExceptionMessage('Invalid URL key');
$categoryData = ['use_default' => ['url_key' => $useDefaultUrlKey], 'url_key' => '', 'url_path' => ''];
$this->category->setData($categoryData);
$this->category
->method('getStoreId')
->willReturn(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
$this->category->isObjectNew($isObjectNew);
$this->assertEquals($isObjectNew, $this->category->isObjectNew());
$this->assertEquals($categoryData['url_key'], $this->category->getUrlKey());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<!-- Check Default Value for Disable Automatic Group Changes Based on VAT ID in Customer Form -->
<actionGroup name="AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup">
<annotations>
<description>Check Default Value for Disable Automatic Group Changes Based on VAT ID in Create Customer form.</description>
</annotations>
<arguments>
<argument name="isChecked" type="string"/>
</arguments>

<grabValueFrom selector="{{AdminCustomerAccountInformationSection.disableAutomaticGroupChange}}" stepKey="grabDisableAutomaticGroupChange"/>
<assertEquals stepKey="assertDisableAutomaticGroupChangeNo" message="pass">
<expectedResult type="string">{{isChecked}}</expectedResult>
<actualResult type="variable">grabDisableAutomaticGroupChange</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminNavigateNewCustomerActionGroup">
<annotations>
<description>Goes to the New Customer page.</description>
</annotations>

<amOnPage url="{{AdminNewCustomerPage.url}}" stepKey="navigateToCustomers"/>
<waitForPageLoad stepKey="waitForLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<element name="firstName" type="input" selector="input[name='customer[firstname]']"/>
<element name="lastName" type="input" selector="input[name='customer[lastname]']"/>
<element name="email" type="input" selector="input[name='customer[email]']"/>
<element name="disableAutomaticGroupChange" type="input" selector="input[name='customer[disable_auto_group_change]']"/>
<element name="group" type="select" selector="[name='customer[group_id]']"/>
<element name="groupIdValue" type="text" selector="//*[@name='customer[group_id]']/option"/>
<element name="groupValue" type="button" selector="//span[text()='{{groupValue}}']" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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="AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest">
<annotations>
<features value="Customer"/>
<stories value="Default Value for Disable Automatic Group Changes Based on VAT ID"/>
<title value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is No"/>
<description value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is No"/>
<severity value="MAJOR"/>
<group value="customer"/>
<group value="create"/>
</annotations>
<before>
<magentoCLI command="config:set customer/create_account/viv_disable_auto_group_assign_default 0" stepKey="setConfigDefaultIsNo"/>
<magentoCLI command="cache:flush" stepKey="flushCache"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
</before>
<after>
<actionGroup ref="logout" stepKey="adminLogout"/>
</after>

<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomer"/>

<actionGroup ref="AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup" stepKey="seeDefaultValueInForm">
<argument name="isChecked" value="0"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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="AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest">
<annotations>
<features value="Customer"/>
<stories value="Default Value for Disable Automatic Group Changes Based on VAT ID"/>
<title value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is Yes"/>
<description value="Check settings Default Value for Disable Automatic Group Changes Based on VAT ID is Yes"/>
<severity value="MAJOR"/>
<group value="customer"/>
<group value="create"/>
</annotations>
<before>
<magentoCLI command="config:set customer/create_account/viv_disable_auto_group_assign_default 1" stepKey="setConfigDefaultIsYes"/>
<magentoCLI command="cache:flush" stepKey="flushCache"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
</before>
<after>
<magentoCLI command="config:set customer/create_account/viv_disable_auto_group_assign_default 0" stepKey="setConfigDefaultIsNo"/>
<magentoCLI command="cache:flush" stepKey="flushCache"/>
<actionGroup ref="logout" stepKey="adminLogout"/>
</after>

<actionGroup ref="AdminNavigateNewCustomerActionGroup" stepKey="navigateToNewCustomer"/>

<actionGroup ref="AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup" stepKey="seeDefaultValueInForm">
<argument name="isChecked" value="1"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,13 @@
<actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress">
<argument name="address" value="updateCustomerBelgiumAddress"/>
</actionGroup>

<!-- Verify country Belgium can be saved without state as state not required -->
<actionGroup ref="StoreFrontClickEditDefaultShippingAddressActionGroup" stepKey="clickOnDefaultShippingAddress"/>
<selectOption selector="{{StorefrontCustomerAddressFormSection.country}}" userInput="Belgium" stepKey="selectCountry"/>
<selectOption selector="{{StorefrontCustomerAddressFormSection.state}}" userInput="Please select a region, state or province." stepKey="selectState"/>
<actionGroup ref="AdminSaveCustomerAddressActionGroup" stepKey="saveAddress"/>
<see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="Belgium" stepKey="seeAssertCustomerDefaultShippingAddressCountry"/>

</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Customer\Ui\Component\Form\Field;

use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponentInterface;
use Magento\Customer\Helper\Address as AddressHelper;

/**
* Process setting to set Default Value for Disable Automatic Group Changes Based on VAT ID
*
* Class \Magento\Customer\Ui\Component\Form\Field\DisableAutoGroupChange
*/
class DisableAutoGroupChange extends \Magento\Ui\Component\Form\Field
{
/**
* Yes value for Default Value for Disable Automatic Group Changes Based on VAT ID
*/
const DISABLE_AUTO_GROUP_CHANGE_YES = '1';

/**
* Address Helper
*
* @var AddressHelper
*/
private $addressHelper;

/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param AddressHelper $addressHelper
* @param UiComponentInterface[] $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
AddressHelper $addressHelper,
array $components = [],
array $data = []
) {
$this->addressHelper = $addressHelper;
parent::__construct($context, $uiComponentFactory, $components, $data);
}

/**
* Prepare component configuration
*
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function prepare()
{
parent::prepare();

if ($this->addressHelper->isDisableAutoGroupAssignDefaultValue()) {
$currentConfig = $this->getData('config');
$currentConfig['default'] = self::DISABLE_AUTO_GROUP_CHANGE_YES;
$this->setData('config', $currentConfig);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<dataType>number</dataType>
</settings>
</field>
<field name="disable_auto_group_change" formElement="checkbox">
<field name="disable_auto_group_change" formElement="checkbox" class="Magento\Customer\Ui\Component\Form\Field\DisableAutoGroupChange">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="fieldGroup" xsi:type="string">group_id</item>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Directory/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<item name="DE" xsi:type="string">DE</item>
<item name="AT" xsi:type="string">AT</item>
<item name="FI" xsi:type="string">FI</item>
<item name="BE" xsi:type="string">BE</item>
</argument>
</arguments>
</type>
Expand Down
15 changes: 9 additions & 6 deletions app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,16 @@ protected function addRatingFieldset()
]
);

foreach ($this->systemStore->getStoreCollection() as $store) {
$this->getFieldset('rating_form')->addField(
'rating_code_' . $store->getId(),
'text',
['label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']']
);
if (!$this->_storeManager->isSingleStoreMode()) {
foreach ($this->systemStore->getStoreCollection() as $store) {
$this->getFieldset('rating_form')->addField(
'rating_code_' . $store->getId(),
'text',
['label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']']
);
}
}

$this->setRatingData();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminAssertStoreViewRatingTitleWhenSingleStoreModeIsNoActionGroup">
<annotations>
<description>If Single Store Mode is disabled, default store view title label should be displayed.</description>
</annotations>
<seeElement selector="{{AdminEditAndNewRatingSection.defaultStoreViewTitleLabel}}" stepKey="seeLabel"/>
<seeElement selector="{{AdminEditAndNewRatingSection.defaultStoreViewTitleInput}}" stepKey="seeInput"/>
</actionGroup>
</actionGroups>
Loading

0 comments on commit 23bd4d6

Please sign in to comment.