Skip to content

Commit 3502dcf

Browse files
committed
Merge remote-tracking branch 'origin/MC-23986' into 2.4-develop-pr9
2 parents f4a7067 + 4c952ed commit 3502dcf

File tree

20 files changed

+340
-145
lines changed

20 files changed

+340
-145
lines changed

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<checkOption selector="{{CheckoutPaymentSection.bankTransfer}}" stepKey="selectBankTransfer"/>
7878
<waitForElementVisible selector="{{CheckoutPaymentSection.billingAddressNotSameBankTransferCheckbox}}" stepKey="waitForElementToBeVisible"/>
7979
<uncheckOption selector="{{CheckoutPaymentSection.billingAddressNotSameBankTransferCheckbox}}" stepKey="uncheckSameBillingAndShippingAddress"/>
80+
<waitForElementVisible selector="{{CheckoutShippingSection.editActiveAddressButton}}" stepKey="waitForEditButtonToBeVisible"/>
8081
<conditionalClick selector="{{CheckoutShippingSection.editActiveAddressButton}}" dependentSelector="{{CheckoutShippingSection.editActiveAddressButton}}" visible="true" stepKey="clickEditButton"/>
8182
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
8283

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontNotApplicableShippingMethodInReviewAndPaymentStepTest.xml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
<magentoCLI command="config:set {{AdminFreeshippingActiveConfigData.path}} {{AdminFreeshippingActiveConfigData.enabled}}" stepKey="enableFreeShippingMethod" />
2828
<magentoCLI command="config:set {{AdminFreeshippingMinimumOrderAmountConfigData.path}} {{AdminFreeshippingMinimumOrderAmountConfigData.hundred}}" stepKey="setFreeShippingMethodMinimumOrderAmountToBe100" />
2929

30-
<!--Set Fedex configs data-->
31-
<magentoCLI command="config:set {{AdminFedexEnableForCheckoutConfigData.path}} {{AdminFedexEnableForCheckoutConfigData.value}}" stepKey="enableCheckout"/>
32-
<magentoCLI command="config:set {{AdminFedexEnableSandboxModeConfigData.path}} {{AdminFedexEnableSandboxModeConfigData.value}}" stepKey="enableSandbox"/>
33-
<magentoCLI command="config:set {{AdminFedexEnableDebugConfigData.path}} {{AdminFedexEnableDebugConfigData.value}}" stepKey="enableDebug"/>
34-
<magentoCLI command="config:set {{AdminFedexEnableShowMethodConfigData.path}} {{AdminFedexEnableShowMethodConfigData.value}}" stepKey="enableShowMethod"/>
35-
3630
<!--Set StoreInformation configs data-->
3731
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} '{{AdminGeneralSetStoreNameConfigData.value}}'" stepKey="setStoreInformationName"/>
3832
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.telephone}}" stepKey="setStoreInformationPhone"/>
@@ -75,10 +69,6 @@
7569
<magentoCLI command="config:set {{AdminFreeshippingMinimumOrderAmountConfigData.path}} {{AdminFreeshippingMinimumOrderAmountConfigData.default}}" stepKey="setFreeShippingMethodMinimumOrderAmountAsDefault" />
7670
<magentoCLI command="config:set {{AdminFreeshippingActiveConfigData.path}} {{AdminFreeshippingActiveConfigData.disabled}}" stepKey="disableFreeShippingMethod" />
7771
<!--Reset configs-->
78-
<magentoCLI command="config:set {{AdminFedexDisableForCheckoutConfigData.path}} {{AdminFedexDisableForCheckoutConfigData.value}}" stepKey="disableCheckout"/>
79-
<magentoCLI command="config:set {{AdminFedexDisableSandboxModeConfigData.path}} {{AdminFedexDisableSandboxModeConfigData.value}}" stepKey="disableSandbox"/>
80-
<magentoCLI command="config:set {{AdminFedexDisableDebugConfigData.path}} {{AdminFedexDisableDebugConfigData.value}}" stepKey="disableDebug"/>
81-
<magentoCLI command="config:set {{AdminFedexDisableShowMethodConfigData.path}} {{AdminFedexDisableShowMethodConfigData.value}}" stepKey="disableShowMethod"/>
8272
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} ''" stepKey="setStoreInformationName"/>
8373
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} ''" stepKey="setStoreInformationPhone"/>
8474
<magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} ''" stepKey="setStoreInformationCity"/>
@@ -187,7 +177,7 @@
187177
<!-- Assert Shipping total is not yet calculated -->
188178
<actionGroup ref="AssertStorefrontNotCalculatedValueInShippingTotalInOrderSummaryActionGroup" stepKey="assertNotYetCalculated2"/>
189179

190-
<!-- Assert order cannot be placed and error message will shown. -->
180+
<!-- Assert order cannot be placed and error message will shown. -->
191181
<actionGroup ref="AssertStorefrontOrderCannotBePlacedActionGroup" stepKey="assertOrderCannotBePlaced2">
192182
<argument name="error" value="The shipping method is missing. Select the shipping method and try again."/>
193183
</actionGroup>

app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @api
88
*/
99
define([
10-
'../model/quote'
10+
'Magento_Checkout/js/model/quote'
1111
], function (quote) {
1212
'use strict';
1313

app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/GuestValidation.php

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter;
1212

1313
/**
14-
* Class GuestValidation
14+
* Guest checkout agreements validation.
1515
*
1616
* Plugin that checks if checkout agreement enabled and validates all agreements.
1717
* Current plugin is duplicate from Magento\CheckoutAgreements\Model\Checkout\Plugin\Validation due to different
@@ -58,6 +58,8 @@ public function __construct(
5858
}
5959

6060
/**
61+
* Validates agreements before save payment information and order placing.
62+
*
6163
* @param \Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject
6264
* @param string $cartId
6365
* @param string $email
@@ -80,28 +82,8 @@ public function beforeSavePaymentInformationAndPlaceOrder(
8082
}
8183

8284
/**
83-
* @param \Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject
84-
* @param string $cartId
85-
* @param string $email
86-
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
87-
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress
88-
* @throws \Magento\Framework\Exception\CouldNotSaveException
89-
* @return void
90-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
91-
*/
92-
public function beforeSavePaymentInformation(
93-
\Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject,
94-
$cartId,
95-
$email,
96-
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
97-
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
98-
) {
99-
if ($this->isAgreementEnabled()) {
100-
$this->validateAgreements($paymentMethod);
101-
}
102-
}
103-
104-
/**
85+
* Validates agreements.
86+
*
10587
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
10688
* @throws \Magento\Framework\Exception\CouldNotSaveException
10789
* @return void
@@ -123,7 +105,8 @@ private function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $pa
123105
}
124106

125107
/**
126-
* Verify if agreement validation needed
108+
* Verify if agreement validation needed.
109+
*
127110
* @return bool
128111
*/
129112
private function isAgreementEnabled()

app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class Validation
1919
/**
2020
* @var \Magento\Framework\App\Config\ScopeConfigInterface
2121
*/
22-
protected $scopeConfiguration;
22+
private $scopeConfiguration;
2323

2424
/**
2525
* @var \Magento\Checkout\Api\AgreementsValidatorInterface
2626
*/
27-
protected $agreementsValidator;
27+
private $agreementsValidator;
2828

2929
/**
3030
* @var \Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface
@@ -65,7 +65,7 @@ public function __construct(
6565
}
6666

6767
/**
68-
* Check validation before saving the payment information and place order
68+
* Validates agreements before save payment information and order placing.
6969
*
7070
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
7171
* @param int $cartId
@@ -134,11 +134,11 @@ protected function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $
134134
}
135135

136136
/**
137-
* Verify if agreement validation needed
137+
* Verify if agreement validation needed.
138138
*
139139
* @return bool
140140
*/
141-
protected function isAgreementEnabled()
141+
private function isAgreementEnabled()
142142
{
143143
$isAgreementsEnabled = $this->scopeConfiguration->isSetFlag(
144144
AgreementsProvider::PATH_ENABLED,

app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/GuestValidationTest.php

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Store\Model\ScopeInterface;
1111

1212
/**
13-
* Class GuestValidationTest
1413
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1514
*/
1615
class GuestValidationTest extends \PHPUnit\Framework\TestCase
@@ -109,7 +108,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrder()
109108
$this->paymentMock->expects(static::atLeastOnce())
110109
->method('getExtensionAttributes')
111110
->willReturn($this->extensionAttributesMock);
112-
$this->model->beforeSavePaymentInformation(
111+
$this->model->beforeSavePaymentInformationAndPlaceOrder(
113112
$this->subjectMock,
114113
$cartId,
115114
$email,
@@ -144,7 +143,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
144143
$this->paymentMock->expects(static::atLeastOnce())
145144
->method('getExtensionAttributes')
146145
->willReturn($this->extensionAttributesMock);
147-
$this->model->beforeSavePaymentInformation(
146+
$this->model->beforeSavePaymentInformationAndPlaceOrder(
148147
$this->subjectMock,
149148
$cartId,
150149
$email,
@@ -156,36 +155,4 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
156155
"The order wasn't placed. First, agree to the terms and conditions, then try placing your order again."
157156
);
158157
}
159-
160-
public function testBeforeSavePaymentInformation()
161-
{
162-
$cartId = 100;
163-
$email = '[email protected]';
164-
$agreements = [1, 2, 3];
165-
$this->scopeConfigMock
166-
->expects($this->once())
167-
->method('isSetFlag')
168-
->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE)
169-
->willReturn(true);
170-
$searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class);
171-
$this->agreementsFilterMock->expects($this->once())
172-
->method('buildSearchCriteria')
173-
->willReturn($searchCriteriaMock);
174-
$this->checkoutAgreementsListMock->expects($this->once())
175-
->method('getList')
176-
->with($searchCriteriaMock)
177-
->willReturn([1]);
178-
$this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements);
179-
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true);
180-
$this->paymentMock->expects(static::atLeastOnce())
181-
->method('getExtensionAttributes')
182-
->willReturn($this->extensionAttributesMock);
183-
$this->model->beforeSavePaymentInformation(
184-
$this->subjectMock,
185-
$cartId,
186-
$email,
187-
$this->paymentMock,
188-
$this->addressMock
189-
);
190-
}
191158
}

app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ public function testBeforeSavePaymentInformationAndPlaceOrder()
130130
$this->paymentMock->expects(static::atLeastOnce())
131131
->method('getExtensionAttributes')
132132
->willReturn($this->extensionAttributesMock);
133-
$this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock);
133+
$this->model->beforeSavePaymentInformation(
134+
$this->subjectMock,
135+
$cartId,
136+
$this->paymentMock,
137+
$this->addressMock
138+
);
134139
}
135140

136141
/**
@@ -167,7 +172,12 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali
167172
$this->paymentMock->expects(static::atLeastOnce())
168173
->method('getExtensionAttributes')
169174
->willReturn($this->extensionAttributesMock);
170-
$this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock);
175+
$this->model->beforeSavePaymentInformation(
176+
$this->subjectMock,
177+
$cartId,
178+
$this->paymentMock,
179+
$this->addressMock
180+
);
171181

172182
$this->expectExceptionMessage(
173183
"The order wasn't placed. First, agree to the terms and conditions, then try placing your order again."

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab;
79

810
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Data\Form\Element\Fieldset;
12+
use Magento\SalesRule\Model\Rule;
913

14+
/**
15+
* Block for rendering Conditions tab on Sales Rules creation page.
16+
*
17+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18+
*/
1019
class Conditions extends \Magento\Backend\Block\Widget\Form\Generic implements
1120
\Magento\Ui\Component\Layout\Tabs\TabInterface
1221
{
@@ -33,8 +42,6 @@ class Conditions extends \Magento\Backend\Block\Widget\Form\Generic implements
3342
private $ruleFactory;
3443

3544
/**
36-
* Constructor
37-
*
3845
* @param \Magento\Backend\Block\Template\Context $context
3946
* @param \Magento\Framework\Registry $registry
4047
* @param \Magento\Framework\Data\FormFactory $formFactory
@@ -60,7 +67,8 @@ public function __construct(
6067
}
6168

6269
/**
63-
* {@inheritdoc}
70+
* @inheritdoc
71+
*
6472
* @codeCoverageIgnore
6573
*/
6674
public function getTabClass()
@@ -69,47 +77,47 @@ public function getTabClass()
6977
}
7078

7179
/**
72-
* {@inheritdoc}
80+
* @inheritdoc
7381
*/
7482
public function getTabUrl()
7583
{
7684
return null;
7785
}
7886

7987
/**
80-
* {@inheritdoc}
88+
* @inheritdoc
8189
*/
8290
public function isAjaxLoaded()
8391
{
8492
return false;
8593
}
8694

8795
/**
88-
* {@inheritdoc}
96+
* @inheritdoc
8997
*/
9098
public function getTabLabel()
9199
{
92100
return __('Conditions');
93101
}
94102

95103
/**
96-
* {@inheritdoc}
104+
* @inheritdoc
97105
*/
98106
public function getTabTitle()
99107
{
100108
return __('Conditions');
101109
}
102110

103111
/**
104-
* {@inheritdoc}
112+
* @inheritdoc
105113
*/
106114
public function canShowTab()
107115
{
108116
return true;
109117
}
110118

111119
/**
112-
* {@inheritdoc}
120+
* @inheritdoc
113121
*/
114122
public function isHidden()
115123
{
@@ -133,7 +141,7 @@ protected function _prepareForm()
133141
/**
134142
* Handles addition of conditions tab to supplied form.
135143
*
136-
* @param \Magento\SalesRule\Model\Rule $model
144+
* @param Rule $model
137145
* @param string $fieldsetId
138146
* @param string $formName
139147
* @return \Magento\Framework\Data\Form

app/code/Magento/SalesRule/Model/Quote/Discount.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function __construct(
8585
* @param \Magento\Quote\Model\Quote\Address\Total $total
8686
* @return $this
8787
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
88+
* @SuppressWarnings(PHPMD.NPathComplexity)
8889
*/
8990
public function collect(
9091
\Magento\Quote\Model\Quote $quote,
@@ -95,6 +96,11 @@ public function collect(
9596

9697
$store = $this->storeManager->getStore($quote->getStoreId());
9798
$address = $shippingAssignment->getShipping()->getAddress();
99+
100+
if ($quote->currentPaymentWasSet()) {
101+
$address->setPaymentMethod($quote->getPayment()->getMethod());
102+
}
103+
98104
$this->calculator->reset($address);
99105

100106
$items = $shippingAssignment->getItems();

app/code/Magento/SalesRule/Model/Rule/Condition/Address.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function loadAttributeOptions()
6565
'base_subtotal' => __('Subtotal'),
6666
'total_qty' => __('Total Items Quantity'),
6767
'weight' => __('Total Weight'),
68+
'payment_method' => __('Payment Method'),
6869
'shipping_method' => __('Shipping Method'),
6970
'postcode' => __('Shipping Postcode'),
7071
'region' => __('Shipping Region'),

app/code/Magento/SalesRule/Test/Mftf/ActionGroup/StorefrontApplyDiscountCodeActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<click selector="{{DiscountSection.DiscountTab}}" stepKey="clickToAddDiscount"/>
1616
<fillField selector="{{DiscountSection.DiscountInput}}" userInput="{{discountCode}}" stepKey="fillFieldDiscountCode"/>
1717
<click selector="{{DiscountSection.ApplyCodeBtn}}" stepKey="clickToApplyDiscount"/>
18-
<waitForPageLoad stepKey="waitForDiscountToBeAdded"/>
18+
<waitForElement selector="{{DiscountSection.DiscountVerificationMsg}}" time="30" stepKey="waitForDiscountToBeAdded"/>
1919
<see selector="{{DiscountSection.DiscountVerificationMsg}}" userInput="Your coupon was successfully applied" stepKey="assertDiscountApplyMessage"/>
2020
</actionGroup>
2121
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
var config = {
7+
config: {
8+
mixins: {
9+
'Magento_Checkout/js/action/select-payment-method': {
10+
'Magento_SalesRule/js/action/select-payment-method-mixin': true
11+
}
12+
}
13+
}
14+
};

0 commit comments

Comments
 (0)