Skip to content

Commit 7ec779b

Browse files
author
Roman Lytvynenko
committed
Merge branch 'MC-19515' of https://github.com/magento-mpi/magento2ce into Tango-PR-01-15-2020_23
� Conflicts: � app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php � app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php
2 parents 466bdea + c128770 commit 7ec779b

File tree

21 files changed

+349
-255
lines changed

21 files changed

+349
-255
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
userInput="$$createProduct1.name$$" stepKey="seeProductName4"/>
132132
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
133133
userInput="$$createProduct12.name$$" stepKey="seeProductName5"/>
134-
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount"/>
134+
<waitForText userInput="$$createCategory.name$$ (ID: $$createCategory.id$$) (2)" stepKey="seeCorrectProductCount"/>
135135
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
136136
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName"/>
137137
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"
@@ -151,7 +151,7 @@
151151
userInput="$$createProduct2.name$$" stepKey="seeProductName6"/>
152152
<see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}"
153153
userInput="$$createProduct12.name$$" stepKey="seeProductName7"/>
154-
<waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount2"/>
154+
<waitForText userInput="$$createCategory.name$$ (ID: $$createCategory.id$$) (2)" stepKey="seeCorrectProductCount2"/>
155155
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}"
156156
userInput="$$createProduct0.name$$" stepKey="dontSeeProductName2"/>
157157
<dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}"

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

Lines changed: 2 additions & 1 deletion
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

@@ -127,4 +128,4 @@
127128
<!-- Assert order buttons -->
128129
<actionGroup ref="AdminAssertOrderAvailableButtonsActionGroup" stepKey="assertOrderButtons"/>
129130
</test>
130-
</tests>
131+
</tests>

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

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

27-
<!--Set Fedex configs data-->
28-
<magentoCLI command="config:set {{AdminFedexEnableForCheckoutConfigData.path}} {{AdminFedexEnableForCheckoutConfigData.value}}" stepKey="enableCheckout"/>
29-
<magentoCLI command="config:set {{AdminFedexEnableSandboxModeConfigData.path}} {{AdminFedexEnableSandboxModeConfigData.value}}" stepKey="enableSandbox"/>
30-
<magentoCLI command="config:set {{AdminFedexEnableDebugConfigData.path}} {{AdminFedexEnableDebugConfigData.value}}" stepKey="enableDebug"/>
31-
<magentoCLI command="config:set {{AdminFedexEnableShowMethodConfigData.path}} {{AdminFedexEnableShowMethodConfigData.value}}" stepKey="enableShowMethod"/>
32-
3327
<!--Set StoreInformation configs data-->
3428
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} '{{AdminGeneralSetStoreNameConfigData.value}}'" stepKey="setStoreInformationName"/>
3529
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.telephone}}" stepKey="setStoreInformationPhone"/>
@@ -72,10 +66,6 @@
7266
<magentoCLI command="config:set {{AdminFreeshippingMinimumOrderAmountConfigData.path}} {{AdminFreeshippingMinimumOrderAmountConfigData.default}}" stepKey="setFreeShippingMethodMinimumOrderAmountAsDefault" />
7367
<magentoCLI command="config:set {{AdminFreeshippingActiveConfigData.path}} {{AdminFreeshippingActiveConfigData.disabled}}" stepKey="disableFreeShippingMethod" />
7468
<!--Reset configs-->
75-
<magentoCLI command="config:set {{AdminFedexDisableForCheckoutConfigData.path}} {{AdminFedexDisableForCheckoutConfigData.value}}" stepKey="disableCheckout"/>
76-
<magentoCLI command="config:set {{AdminFedexDisableSandboxModeConfigData.path}} {{AdminFedexDisableSandboxModeConfigData.value}}" stepKey="disableSandbox"/>
77-
<magentoCLI command="config:set {{AdminFedexDisableDebugConfigData.path}} {{AdminFedexDisableDebugConfigData.value}}" stepKey="disableDebug"/>
78-
<magentoCLI command="config:set {{AdminFedexDisableShowMethodConfigData.path}} {{AdminFedexDisableShowMethodConfigData.value}}" stepKey="disableShowMethod"/>
7969
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} ''" stepKey="setStoreInformationName"/>
8070
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} ''" stepKey="setStoreInformationPhone"/>
8171
<magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} ''" stepKey="setStoreInformationCity"/>
@@ -184,7 +174,7 @@
184174
<!-- Assert Shipping total is not yet calculated -->
185175
<actionGroup ref="AssertStorefrontNotCalculatedValueInShippingTotalInOrderSummaryActionGroup" stepKey="assertNotYetCalculated2"/>
186176

187-
<!-- Assert order cannot be placed and error message will shown. -->
177+
<!-- Assert order cannot be placed and error message will shown. -->
188178
<actionGroup ref="AssertStorefrontOrderCannotBePlacedActionGroup" stepKey="assertOrderCannotBePlaced2">
189179
<argument name="error" value="The shipping method is missing. Select the shipping method and try again."/>
190180
</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: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@
77
namespace Magento\CheckoutAgreements\Model\Checkout\Plugin;
88

99
use Magento\CheckoutAgreements\Model\AgreementsProvider;
10-
use Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter;
11-
use Magento\Quote\Api\CartRepositoryInterface;
1210
use Magento\Store\Model\ScopeInterface;
11+
use Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter;
1312

1413
/**
15-
* Class Validation validates the agreement based on the payment method
14+
* Checkout agreements validation.
1615
*/
1716
class Validation
1817
{
1918
/**
2019
* @var \Magento\Framework\App\Config\ScopeConfigInterface
2120
*/
22-
protected $scopeConfiguration;
21+
private $scopeConfiguration;
2322

2423
/**
2524
* @var \Magento\Checkout\Api\AgreementsValidatorInterface
2625
*/
27-
protected $agreementsValidator;
26+
private $agreementsValidator;
2827

2928
/**
3029
* @var \Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface
@@ -36,36 +35,26 @@ class Validation
3635
*/
3736
private $activeStoreAgreementsFilter;
3837

39-
/**
40-
* Quote repository.
41-
*
42-
* @var \Magento\Quote\Api\CartRepositoryInterface
43-
*/
44-
private $quoteRepository;
45-
4638
/**
4739
* @param \Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator
4840
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration
4941
* @param \Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface $checkoutAgreementsList
5042
* @param ActiveStoreAgreementsFilter $activeStoreAgreementsFilter
51-
* @param CartRepositoryInterface $quoteRepository
5243
*/
5344
public function __construct(
5445
\Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator,
5546
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration,
5647
\Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface $checkoutAgreementsList,
57-
\Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter $activeStoreAgreementsFilter,
58-
CartRepositoryInterface $quoteRepository
48+
\Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter $activeStoreAgreementsFilter
5949
) {
6050
$this->agreementsValidator = $agreementsValidator;
6151
$this->scopeConfiguration = $scopeConfiguration;
6252
$this->checkoutAgreementsList = $checkoutAgreementsList;
6353
$this->activeStoreAgreementsFilter = $activeStoreAgreementsFilter;
64-
$this->quoteRepository = $quoteRepository;
6554
}
6655

6756
/**
68-
* Check validation before saving the payment information and place order
57+
* Validates agreements before save payment information and order placing.
6958
*
7059
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
7160
* @param int $cartId
@@ -87,37 +76,13 @@ public function beforeSavePaymentInformationAndPlaceOrder(
8776
}
8877

8978
/**
90-
* Check validation before saving the payment information
91-
*
92-
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject
93-
* @param int $cartId
94-
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
95-
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress
96-
* @return void
97-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
98-
* @throws \Magento\Framework\Exception\NoSuchEntityException
99-
* @throws \Magento\Framework\Exception\CouldNotSaveException
100-
*/
101-
public function beforeSavePaymentInformation(
102-
\Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
103-
$cartId,
104-
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
105-
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
106-
) {
107-
$quote = $this->quoteRepository->getActive($cartId);
108-
if ($this->isAgreementEnabled() && !$quote->getIsMultiShipping()) {
109-
$this->validateAgreements($paymentMethod);
110-
}
111-
}
112-
113-
/**
114-
* Validate agreements base on the payment method
79+
* Validates agreements.
11580
*
11681
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
11782
* @throws \Magento\Framework\Exception\CouldNotSaveException
11883
* @return void
11984
*/
120-
protected function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod)
85+
private function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod)
12186
{
12287
$agreements = $paymentMethod->getExtensionAttributes() === null
12388
? []
@@ -134,11 +99,11 @@ protected function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $
13499
}
135100

136101
/**
137-
* Verify if agreement validation needed
102+
* Verify if agreement validation needed.
138103
*
139104
* @return bool
140105
*/
141-
protected function isAgreementEnabled()
106+
private function isAgreementEnabled()
142107
{
143108
$isAgreementsEnabled = $this->scopeConfiguration->isSetFlag(
144109
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@example.com';
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
}

0 commit comments

Comments
 (0)