Skip to content

Commit 21cd1cb

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-PR-port-21443
2 parents 2b41017 + 114bcec commit 21cd1cb

File tree

60 files changed

+1375
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1375
-178
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontBraintreeSelectPaymentMethodActionGroup">
11+
<click selector="{{StorefrontBraintreePaymentConfigurationSection.creditCardBraintreePaymentMethod}}" stepKey="selectBraintreePaymentMethod"/>
12+
</actionGroup>
13+
14+
<actionGroup name="StorefrontBraintreeFillCardDataActionGroup">
15+
<arguments>
16+
<argument name="cardData" defaultValue="BraintreeCard"/>
17+
</arguments>
18+
<scrollTo selector="{{StorefrontBraintreePaymentConfigurationSection.creditCardBraintreePaymentMethod}}" stepKey="scrollToCreditCardSection"/>
19+
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.cardFrame}}" stepKey="switchToIframe"/>
20+
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.cardNumber}}" stepKey="waitCardNumberElement"/>
21+
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.cardNumber}}" userInput="{{cardData.card_number}}" stepKey="setCardNumber"/>
22+
<switchToIFrame stepKey="switchBack"/>
23+
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.monthFrame}}" stepKey="switchToIframe1"/>
24+
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.month}}" stepKey="waitMonthElement"/>
25+
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.month}}" userInput="{{cardData.exp_month}}" stepKey="setMonth"/>
26+
<switchToIFrame stepKey="switchBack1"/>
27+
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.yearFrame}}" stepKey="switchToIframe2"/>
28+
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.year}}" stepKey="waitYearElement"/>
29+
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.year}}" userInput="{{cardData.exp_year}}" stepKey="setYear"/>
30+
<switchToIFrame stepKey="switchBack2"/>
31+
<switchToIFrame selector="{{StorefrontBraintreePaymentConfigurationSection.codeFrame}}" stepKey="switchToIframe3"/>
32+
<waitForElementVisible selector="{{StorefrontBraintreePaymentConfigurationSection.verificationNumber}}" stepKey="waitVerificationNumber"/>
33+
<fillField selector="{{StorefrontBraintreePaymentConfigurationSection.verificationNumber}}" userInput="{{cardData.cvv}}" stepKey="setVerificationNumber"/>
34+
<switchToIFrame stepKey="SwitchBackToWindow"/>
35+
<waitForPageLoad stepKey="waitForPageLoad"/>
36+
</actionGroup>
37+
</actionGroups>

app/code/Magento/Braintree/Test/Mftf/Data/BraintreeData.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
1111
<entity name="SampleBraintreeConfig" type="braintree_config_state">
1212
<requiredEntity type="title">SampleTitle</requiredEntity>
1313
<requiredEntity type="payment_action">SamplePaymentAction</requiredEntity>
@@ -113,5 +113,4 @@
113113
<data key="exp_year">20</data>
114114
<data key="cvv">113</data>
115115
</entity>
116-
117116
</entities>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="CheckoutPage" url="/checkout" area="storefront" module="Magento_Checkout">
12+
<section name="StorefrontBraintreePaymentConfigurationSection"/>
13+
</page>
14+
</pages>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="StorefrontBraintreePaymentConfigurationSection">
12+
<element name="creditCardBraintreePaymentMethod" type="radio" selector="#braintree" timeout="30"/>
13+
<element name="cardFrame" type="iframe" selector="braintree-hosted-field-number"/>
14+
<element name="monthFrame" type="iframe" selector="braintree-hosted-field-expirationMonth"/>
15+
<element name="yearFrame" type="iframe" selector="braintree-hosted-field-expirationYear"/>
16+
<element name="codeFrame" type="iframe" selector="braintree-hosted-field-cvv"/>
17+
<element name="cardNumber" type="input" selector="#credit-card-number"/>
18+
<element name="month" type="input" selector="#expiration-month"/>
19+
<element name="year" type="input" selector="#expiration-year"/>
20+
<element name="verificationNumber" type="input" selector="#cvv"/>
21+
</section>
22+
</sections>

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Bundle\Api\ProductOptionRepositoryInterface as OptionRepository;
99
use Magento\Bundle\Api\ProductLinkManagementInterface;
10+
use Magento\Catalog\Api\Data\ProductInterface;
1011
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\EntityManager\MetadataPool;
1213
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
@@ -49,12 +50,11 @@ public function __construct(
4950
}
5051

5152
/**
53+
* Perform action on Bundle product relation/extension attribute.
54+
*
5255
* @param object $entity
5356
* @param array $arguments
54-
* @return \Magento\Catalog\Api\Data\ProductInterface|object
55-
* @throws \Magento\Framework\Exception\NoSuchEntityException
56-
* @throws \Magento\Framework\Exception\InputException
57-
* @throws \Magento\Framework\Exception\CouldNotSaveException
57+
* @return ProductInterface|object
5858
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5959
*/
6060
public function execute($entity, $arguments = [])
@@ -78,7 +78,7 @@ public function execute($entity, $arguments = [])
7878
$options = $bundleProductOptions ?: [];
7979

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

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

9494
/**
95+
* Remove option product links.
96+
*
9597
* @param string $entitySku
9698
* @param \Magento\Bundle\Api\Data\OptionInterface $option
97-
* @throws \Magento\Framework\Exception\NoSuchEntityException
98-
* @throws \Magento\Framework\Exception\InputException
9999
* @return void
100100
*/
101101
protected function removeOptionLinks($entitySku, $option)
@@ -152,21 +152,21 @@ private function getOptionIds(array $options)
152152
}
153153

154154
/**
155-
* Removes old options that no longer exists
155+
* Removes old options that no longer exists.
156156
*
157-
* @param string $entitySku
157+
* @param ProductInterface $entity
158158
* @param array $existingOptionsIds
159159
* @param array $optionIds
160-
* @throws \Magento\Framework\Exception\NoSuchEntityException
161-
* @throws \Magento\Framework\Exception\InputException
162-
* @throws \Magento\Framework\Exception\CouldNotSaveException
163160
* @return void
164161
*/
165-
private function processRemovedOptions($entitySku, array $existingOptionsIds, array $optionIds)
162+
private function processRemovedOptions(ProductInterface $entity, array $existingOptionsIds, array $optionIds)
166163
{
164+
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
165+
$parentId = $entity->getData($metadata->getLinkField());
167166
foreach (array_diff($existingOptionsIds, $optionIds) as $optionId) {
168-
$option = $this->optionRepository->get($entitySku, $optionId);
169-
$this->removeOptionLinks($entitySku, $option);
167+
$option = $this->optionRepository->get($entity->getSku(), $optionId);
168+
$option->setParentId($parentId);
169+
$this->removeOptionLinks($entity->getSku(), $option);
170170
$this->optionRepository->delete($option);
171171
}
172172
}

0 commit comments

Comments
 (0)