Skip to content

Commit 6696a1c

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into PR-L3-20210405
2 parents bf3b1c6 + f25fc03 commit 6696a1c

23 files changed

+4023
-3613
lines changed

app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,13 @@ define([
452452
}
453453
},
454454

455+
/**
456+
* Helper to find select element of currently confirmed item
457+
*/
458+
getCurrentConfirmedSelectElement: function () {
459+
return $(this.confirmedCurrentId).getElementsByTagName('select');
460+
},
461+
455462
/**
456463
* Helper to find qty of active form
457464
*/

app/code/Magento/CatalogRule/Model/Rule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ protected function _invalidateCache()
589589
*/
590590
public function afterSave()
591591
{
592-
if (!$this->getIsActive()) {
592+
if (!$this->getIsActive() && !$this->getOrigData(self::IS_ACTIVE)) {
593593
return parent::afterSave();
594594
}
595595

@@ -601,6 +601,7 @@ public function afterSave()
601601
} else {
602602
$this->_ruleProductProcessor->getIndexer()->invalidate();
603603
}
604+
604605
return parent::afterSave();
605606
}
606607

app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
12+
use Magento\CatalogRule\Api\Data\RuleInterface;
1213
use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor;
1314
use Magento\CatalogRule\Model\Rule;
1415
use Magento\CatalogRule\Model\Rule\Condition\CombineFactory;
@@ -31,46 +32,60 @@
3132
*/
3233
class RuleTest extends TestCase
3334
{
34-
/** @var Rule */
35-
protected $rule;
35+
/**
36+
* @var Rule
37+
*/
38+
private $rule;
3639

37-
/** @var ObjectManager */
40+
/**
41+
* @var ObjectManager
42+
*/
3843
private $objectManager;
3944

40-
/** @var StoreManagerInterface|MockObject */
41-
protected $storeManager;
45+
/**
46+
* @var StoreManagerInterface|MockObject
47+
*/
48+
private $storeManager;
4249

43-
/** @var MockObject */
44-
protected $combineFactory;
50+
/**
51+
* @var CombineFactory|MockObject
52+
*/
53+
private $combineFactory;
4554

46-
/** @var Store|MockObject */
47-
protected $storeModel;
55+
/**
56+
* @var Store|MockObject
57+
*/
58+
private $storeModel;
4859

49-
/** @var Website|MockObject */
50-
protected $websiteModel;
60+
/**
61+
* @var Website|MockObject
62+
*/
63+
private $websiteModel;
5164

52-
/** @var Combine|MockObject */
53-
protected $condition;
65+
/**
66+
* @var Combine|MockObject
67+
*/
68+
private $condition;
5469

5570
/**
5671
* @var RuleProductProcessor|MockObject
5772
*/
58-
protected $_ruleProductProcessor;
73+
private $_ruleProductProcessor;
5974

6075
/**
6176
* @var CollectionFactory|MockObject
6277
*/
63-
protected $_productCollectionFactory;
78+
private $_productCollectionFactory;
6479

6580
/**
6681
* @var Iterator|MockObject
6782
*/
68-
protected $_resourceIterator;
83+
private $_resourceIterator;
6984

7085
/**
7186
* @var Product|MockObject
7287
*/
73-
protected $productModel;
88+
private $productModel;
7489

7590
/**
7691
* Set up before test
@@ -85,15 +100,15 @@ protected function setUp(): void
85100
$this->combineFactory = $this->createPartialMock(
86101
CombineFactory::class,
87102
[
88-
'create'
103+
'create',
89104
]
90105
);
91106
$this->productModel = $this->createPartialMock(
92107
Product::class,
93108
[
94109
'__wakeup',
95110
'getId',
96-
'setData'
111+
'setData',
97112
]
98113
);
99114
$this->condition = $this->getMockBuilder(Combine::class)
@@ -106,7 +121,7 @@ protected function setUp(): void
106121
[
107122
'__wakeup',
108123
'getId',
109-
'getDefaultStore'
124+
'getDefaultStore',
110125
]
111126
);
112127
$this->_ruleProductProcessor = $this->createMock(
@@ -192,7 +207,7 @@ public function testCallbackValidateProduct($validate)
192207
'has_options' => '0',
193208
'required_options' => '0',
194209
'created_at' => '2014-06-25 13:14:30',
195-
'updated_at' => '2014-06-25 14:37:15'
210+
'updated_at' => '2014-06-25 14:37:15',
196211
];
197212
$this->storeManager->expects($this->any())->method('getWebsites')->with(false)
198213
->willReturn([$this->websiteModel, $this->websiteModel]);
@@ -263,14 +278,14 @@ public function validateDataDataProvider()
263278
'simple_action' => 'by_fixed',
264279
'discount_amount' => '123',
265280
],
266-
true
281+
true,
267282
],
268283
[
269284
[
270285
'simple_action' => 'by_percent',
271286
'discount_amount' => '9,99',
272287
],
273-
true
288+
true,
274289
],
275290
[
276291
[
@@ -279,7 +294,7 @@ public function validateDataDataProvider()
279294
],
280295
[
281296
'Percentage discount should be between 0 and 100.',
282-
]
297+
],
283298
],
284299
[
285300
[
@@ -288,7 +303,7 @@ public function validateDataDataProvider()
288303
],
289304
[
290305
'Percentage discount should be between 0 and 100.',
291-
]
306+
],
292307
],
293308
[
294309
[
@@ -297,7 +312,7 @@ public function validateDataDataProvider()
297312
],
298313
[
299314
'Discount value should be 0 or greater.',
300-
]
315+
],
301316
],
302317
[
303318
[
@@ -306,7 +321,7 @@ public function validateDataDataProvider()
306321
],
307322
[
308323
'Unknown action.',
309-
]
324+
],
310325
],
311326
];
312327
}
@@ -325,33 +340,48 @@ public function testAfterDelete()
325340
}
326341

327342
/**
328-
* Test after update action for inactive rule
343+
* Test after update action for active and deactivated rule.
329344
*
345+
* @dataProvider afterUpdateDataProvider
346+
* @param int $active
330347
* @return void
331348
*/
332-
public function testAfterUpdateInactive()
349+
public function testAfterUpdate(int $active)
333350
{
334351
$this->rule->isObjectNew(false);
335-
$this->rule->setIsActive(0);
336-
$this->_ruleProductProcessor->expects($this->never())->method('getIndexer');
352+
$this->rule->setIsActive($active);
353+
$this->rule->setOrigData(RuleInterface::IS_ACTIVE, 1);
354+
$indexer = $this->getMockForAbstractClass(IndexerInterface::class);
355+
$indexer->expects($this->once())->method('invalidate');
356+
$this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->willReturn($indexer);
337357
$this->rule->afterSave();
338358
}
339359

340360
/**
341-
* Test after update action for active rule
361+
* Test after update action for inactive rule.
342362
*
343363
* @return void
344364
*/
345-
public function testAfterUpdateActive()
365+
public function testAfterUpdateInactiveRule()
346366
{
347367
$this->rule->isObjectNew(false);
348-
$this->rule->setIsActive(1);
349-
$indexer = $this->getMockForAbstractClass(IndexerInterface::class);
350-
$indexer->expects($this->once())->method('invalidate');
351-
$this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->willReturn($indexer);
368+
$this->rule->setIsActive(0);
369+
$this->rule->setOrigData(RuleInterface::IS_ACTIVE, 0);
370+
$this->_ruleProductProcessor->expects($this->never())->method('getIndexer');
352371
$this->rule->afterSave();
353372
}
354373

374+
/**
375+
* @return array
376+
*/
377+
public function afterUpdateDataProvider(): array
378+
{
379+
return [
380+
['active' => 0],
381+
['active' => 1],
382+
];
383+
}
384+
355385
/**
356386
* Test isRuleBehaviorChanged action
357387
*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777

7878
<!-- Check order summary in checkout -->
7979
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" stepKey="waitForPaymentSectionLoaded"/>
80+
<waitForElementVisible selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="waitForPlaceOrderButton"/>
8081
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrderButton"/>
8182
<seeElement selector="{{CheckoutSuccessMainSection.success}}" stepKey="orderIsSuccessfullyPlaced"/>
8283
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderNumber"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787

8888
<!-- Check order summary in checkout -->
8989
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" stepKey="waitForPaymentSectionLoaded"/>
90+
<waitForElementVisible selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="waitForPlaceOrderButton"/>
9091
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrderButton"/>
9192
<seeElement selector="{{CheckoutSuccessMainSection.success}}" stepKey="orderIsSuccessfullyPlaced"/>
9293
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderNumber"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
<!-- Check order summary in checkout -->
7373
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" stepKey="waitForPaymentSectionLoaded"/>
74+
<waitForElementVisible selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="waitForPlaceOrderButton"/>
7475
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrderButton"/>
7576
<seeElement selector="{{CheckoutSuccessMainSection.success}}" stepKey="orderIsSuccessfullyPlaced"/>
7677
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderNumber"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontGuestCheckoutWithDifferentShippingAndBillingAddressWithRestrictedCountriesForPaymentTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<stories value="Check payment methods on checkout"/>
15+
<title value="Check payment methods update on checkout payment step"/>
16+
<description value="Check that payment methods will update on checkout payment step after updating customer billing address"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MC-41743"/>
19+
<useCaseId value="MC-37820"/>
20+
<group value="checkout"/>
21+
</annotations>
22+
23+
<before>
24+
<magentoCLI command="config:set {{BankTransferEnableConfigData.path}} {{BankTransferEnableConfigData.value}}" stepKey="enableBankTransfer"/>
25+
<magentoCLI command="config:set payment/checkmo/allowspecific 1" stepKey="allowSpecificValue"/>
26+
<magentoCLI command="config:set payment/checkmo/specificcountry GB" stepKey="allowBankTransferOnlyForGB"/>
27+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
28+
</before>
29+
30+
<after>
31+
<magentoCLI command="config:set {{BankTransferDisabledConfigData.path}} {{BankTransferDisabledConfigData.value}}" stepKey="disableBankTransfer"/>
32+
<magentoCLI command="config:set payment/checkmo/allowspecific 0" stepKey="disallowSpecificValue" />
33+
<magentoCLI command="config:set payment/checkmo/specificcountry ''" stepKey="defaultCountryValue"/>
34+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
35+
</after>
36+
37+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
38+
<argument name="productUrl" value="$createProduct.custom_attributes[url_key]$"/>
39+
</actionGroup>
40+
<actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage">
41+
<argument name="productName" value="$createProduct.name$"/>
42+
</actionGroup>
43+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
44+
<actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="fillShippingSectionAsGuest">
45+
<argument name="customerVar" value="CustomerEntityOne"/>
46+
<argument name="customerAddressVar" value="CustomerAddressSimple"/>
47+
</actionGroup>
48+
<dontSee selector="{{CheckoutPaymentSection.paymentMethodTitle}}" userInput="Check / Money order" stepKey="assertNoCheckMoneyOrderPaymentMethod"/>
49+
<waitForElementVisible selector="{{CheckoutPaymentSection.billingAddressNotSameBankTransferCheckbox}}" stepKey="waitForBillingAddressNotSameAsShippingCheckbox"/>
50+
<uncheckOption selector="{{CheckoutPaymentSection.billingAddressNotSameBankTransferCheckbox}}" stepKey="uncheckSameBillingAndShippingAddress"/>
51+
<conditionalClick selector="{{CheckoutPaymentSection.editAddress}}" dependentSelector="{{CheckoutShippingSection.editAddressButton}}" visible="true" stepKey="clickEditBillingAddressButton"/>
52+
<waitForLoadingMaskToDisappear stepKey="waitForBillingAddressFormLoads"/>
53+
54+
<!-- Fill Billing Address -->
55+
<actionGroup ref="StorefrontFillBillingAddressActionGroup" stepKey="fillBillingAddress"/>
56+
<click selector="{{CheckoutPaymentSection.update}}" stepKey="clickOnUpdateButton"/>
57+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear" />
58+
<see selector="{{CheckoutPaymentSection.paymentMethodTitle}}" userInput="Check / Money order" stepKey="sdadasdasdsdaasd"/>
59+
</test>
60+
</tests>

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function (
171171
checkoutData.setNewCustomerBillingAddress(addressData);
172172
}
173173
}
174+
setBillingAddressAction(globalMessageList);
174175
this.updateAddresses();
175176
},
176177

app/code/Magento/Customer/Model/Metadata/Form/File.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ public function compactValue($value)
320320
}
321321

322322
// Remove outdated file (in the case of file uploader UI component)
323-
if (!empty($this->_value) && !empty($value['delete'])) {
323+
if (!empty($this->_value)
324+
&& (!empty($value['delete'])
325+
|| ($this->_entityTypeCode == 'customer' && empty($value)))
326+
) {
324327
$this->fileProcessor->removeUploadedFile($this->_value);
325328
return $value;
326329
}

app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public function testCompactValueNoDelete()
393393
->with('value')
394394
->willReturnSelf();
395395

396-
$this->assertSame('value', $model->compactValue([]));
396+
$this->assertSame([], $model->compactValue([]));
397397
}
398398

399399
public function testCompactValueDelete()
@@ -625,7 +625,7 @@ public function testCompactValueRemoveUiComponentValue()
625625
->with($value)
626626
->willReturnSelf();
627627

628-
$this->assertEquals($value, $model->compactValue([]));
628+
$this->assertEquals([], $model->compactValue([]));
629629
}
630630

631631
public function testCompactValueNoAction()

0 commit comments

Comments
 (0)