Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-…
Browse files Browse the repository at this point in the history
…PR-port-20129
  • Loading branch information
nmalevanec committed Mar 14, 2019
2 parents 8874332 + 30ed829 commit a75958f
Show file tree
Hide file tree
Showing 66 changed files with 1,541 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Magento\Backend\Block\System\Design\Edit\Tab;

/**
* General system tab block.
*/
class General extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
Expand Down Expand Up @@ -90,7 +93,7 @@ protected function _prepareForm()
]
);

$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
$dateFormat = $this->_localeDate->getDateFormatWithLongYear();
$fieldset->addField(
'date_from',
'date',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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="StorefrontBraintreeSelectPaymentMethodActionGroup">
<click selector="{{StorefrontBraintreePaymentConfigurationSection.creditCardBraintreePaymentMethod}}" stepKey="selectBraintreePaymentMethod"/>
</actionGroup>

<actionGroup name="StorefrontBraintreeFillCardDataActionGroup">
<arguments>
<argument name="cardData" defaultValue="BraintreeCard"/>
</arguments>
<scrollTo selector="{{StorefrontBraintreePaymentConfigurationSection.creditCardBraintreePaymentMethod}}" stepKey="scrollToCreditCardSection"/>
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.cardFrame}}" stepKey="switchToIframe"/>
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.cardNumber}}" stepKey="waitCardNumberElement"/>
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.cardNumber}}" userInput="{{cardData.card_number}}" stepKey="setCardNumber"/>
<switchToIFrame stepKey="switchBack"/>
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.monthFrame}}" stepKey="switchToIframe1"/>
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.month}}" stepKey="waitMonthElement"/>
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.month}}" userInput="{{cardData.exp_month}}" stepKey="setMonth"/>
<switchToIFrame stepKey="switchBack1"/>
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.yearFrame}}" stepKey="switchToIframe2"/>
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.year}}" stepKey="waitYearElement"/>
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.year}}" userInput="{{cardData.exp_year}}" stepKey="setYear"/>
<switchToIFrame stepKey="switchBack2"/>
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.codeFrame}}" stepKey="switchToIframe3"/>
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.verificationNumber}}" stepKey="waitVerificationNumber"/>
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.verificationNumber}}" userInput="{{cardData.cvv}}" stepKey="setVerificationNumber"/>
<switchToIFrame stepKey="SwitchBackToWindow"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
</actionGroup>
</actionGroups>
3 changes: 1 addition & 2 deletions app/code/Magento/Braintree/Test/Mftf/Data/BraintreeData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="SampleBraintreeConfig" type="braintree_config_state">
<requiredEntity type="title">SampleTitle</requiredEntity>
<requiredEntity type="payment_action">SamplePaymentAction</requiredEntity>
Expand Down Expand Up @@ -113,5 +113,4 @@
<data key="exp_year">20</data>
<data key="cvv">113</data>
</entity>

</entities>
14 changes: 14 additions & 0 deletions app/code/Magento/Braintree/Test/Mftf/Page/CheckoutPage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="CheckoutPage" url="/checkout" area="storefront" module="Magento_Checkout">
<section name="StorefrontBraintreePaymentConfigurationSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="StorefrontBraintreePaymentConfigurationSection">
<element name="creditCardBraintreePaymentMethod" type="radio" selector="#braintree" timeout="30"/>
<element name="cardFrame" type="iframe" selector="braintree-hosted-field-number"/>
<element name="monthFrame" type="iframe" selector="braintree-hosted-field-expirationMonth"/>
<element name="yearFrame" type="iframe" selector="braintree-hosted-field-expirationYear"/>
<element name="codeFrame" type="iframe" selector="braintree-hosted-field-cvv"/>
<element name="cardNumber" type="input" selector="#credit-card-number"/>
<element name="month" type="input" selector="#expiration-month"/>
<element name="year" type="input" selector="#expiration-year"/>
<element name="verificationNumber" type="input" selector="#cvv"/>
</section>
</sections>
30 changes: 15 additions & 15 deletions app/code/Magento/Bundle/Model/Product/SaveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\Bundle\Api\ProductOptionRepositoryInterface as OptionRepository;
use Magento\Bundle\Api\ProductLinkManagementInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
Expand Down Expand Up @@ -49,12 +50,11 @@ public function __construct(
}

/**
* Perform action on Bundle product relation/extension attribute.
*
* @param object $entity
* @param array $arguments
* @return \Magento\Catalog\Api\Data\ProductInterface|object
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Exception\CouldNotSaveException
* @return ProductInterface|object
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute($entity, $arguments = [])
Expand All @@ -78,7 +78,7 @@ public function execute($entity, $arguments = [])
$options = $bundleProductOptions ?: [];

if (!$entity->getCopyFromView()) {
$this->processRemovedOptions($entity->getSku(), $existingOptionsIds, $optionIds);
$this->processRemovedOptions($entity, $existingOptionsIds, $optionIds);

$newOptionsIds = array_diff($optionIds, $existingOptionsIds);
$this->saveOptions($entity, $options, $newOptionsIds);
Expand All @@ -92,10 +92,10 @@ public function execute($entity, $arguments = [])
}

/**
* Remove option product links.
*
* @param string $entitySku
* @param \Magento\Bundle\Api\Data\OptionInterface $option
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\InputException
* @return void
*/
protected function removeOptionLinks($entitySku, $option)
Expand Down Expand Up @@ -152,21 +152,21 @@ private function getOptionIds(array $options)
}

/**
* Removes old options that no longer exists
* Removes old options that no longer exists.
*
* @param string $entitySku
* @param ProductInterface $entity
* @param array $existingOptionsIds
* @param array $optionIds
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Exception\CouldNotSaveException
* @return void
*/
private function processRemovedOptions($entitySku, array $existingOptionsIds, array $optionIds)
private function processRemovedOptions(ProductInterface $entity, array $existingOptionsIds, array $optionIds)
{
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
$parentId = $entity->getData($metadata->getLinkField());
foreach (array_diff($existingOptionsIds, $optionIds) as $optionId) {
$option = $this->optionRepository->get($entitySku, $optionId);
$this->removeOptionLinks($entitySku, $option);
$option = $this->optionRepository->get($entity->getSku(), $optionId);
$option->setParentId($parentId);
$this->removeOptionLinks($entity->getSku(), $option);
$this->optionRepository->delete($option);
}
}
Expand Down
Loading

0 comments on commit a75958f

Please sign in to comment.