Skip to content

Commit 697d4b7

Browse files
authored
Merge pull request #5715 from magento-tsg-csl3/2.4.1-develop-pr25
[TSG-CSL3] For 2.4.1 (pr25)
2 parents d5e419c + a11f111 commit 697d4b7

File tree

62 files changed

+2780
-482
lines changed

Some content is hidden

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

62 files changed

+2780
-482
lines changed

app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Show extends Action implements HttpGetActionInterface
2727
/**
2828
* @inheritdoc
2929
*/
30-
const ADMIN_RESOURCE = 'Magento_Analytics::analytics_settings';
30+
const ADMIN_RESOURCE = 'Magento_Analytics::advanced_reporting';
3131

3232
/**
3333
* @param Context $context

app/code/Magento/Braintree/Model/Paypal/Helper/ShippingMethodUpdater.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Quote\Model\Quote;
1111

1212
/**
13-
* Class ShippingMethodUpdater
13+
* Class for updating shipping method in the quote.
1414
*/
1515
class ShippingMethodUpdater extends AbstractHelper
1616
{
@@ -58,6 +58,12 @@ public function execute($shippingMethod, Quote $quote)
5858
$this->disabledQuoteAddressValidation($quote);
5959

6060
$shippingAddress->setShippingMethod($shippingMethod);
61+
$quoteExtensionAttributes = $quote->getExtensionAttributes();
62+
if ($quoteExtensionAttributes && $quoteExtensionAttributes->getShippingAssignments()) {
63+
$quoteExtensionAttributes->getShippingAssignments()[0]
64+
->getShipping()
65+
->setMethod($shippingMethod);
66+
}
6167
$shippingAddress->setCollectShippingRates(true);
6268

6369
$quote->collectTotals();

app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/ShippingMethodUpdaterTest.php

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use PHPUnit\Framework\TestCase;
1717

1818
/**
19-
* @see \Magento\Braintree\Model\Paypal\Helper\ShippingMethodUpdater
19+
* Test shipping method updater
2020
*/
2121
class ShippingMethodUpdaterTest extends TestCase
2222
{
@@ -39,11 +39,19 @@ class ShippingMethodUpdaterTest extends TestCase
3939
*/
4040
private $shippingAddressMock;
4141

42+
/**
43+
* @var Address|MockObject
44+
*/
45+
private $billingAddressMock;
46+
4247
/**
4348
* @var ShippingMethodUpdater
4449
*/
4550
private $shippingMethodUpdater;
4651

52+
/**
53+
* @inheritdoc
54+
*/
4755
protected function setUp(): void
4856
{
4957
$this->configMock = $this->getMockBuilder(Config::class)
@@ -69,16 +77,24 @@ protected function setUp(): void
6977
);
7078
}
7179

72-
public function testExecuteException()
80+
/**
81+
* Test execute exception
82+
*
83+
* @return void
84+
*/
85+
public function testExecuteException(): void
7386
{
7487
$this->expectException(\InvalidArgumentException::class);
75-
$this->expectExceptionMessage('The "shippingMethod" field does not exists.');
88+
$this->expectExceptionMessage("The \"shippingMethod\" field does not exists.");
7689
$quoteMock = $this->getQuoteMock();
7790

7891
$this->shippingMethodUpdater->execute('', $quoteMock);
7992
}
8093

81-
public function testExecute()
94+
/**
95+
* Test execute
96+
*/
97+
public function testExecute(): void
8298
{
8399
$quoteMock = $this->getQuoteMock();
84100

@@ -114,9 +130,13 @@ public function testExecute()
114130
}
115131

116132
/**
133+
* Disable quote address validation
134+
*
117135
* @param MockObject $quoteMock
136+
*
137+
* @return void
118138
*/
119-
private function disabledQuoteAddressValidationStep(MockObject $quoteMock)
139+
private function disabledQuoteAddressValidationStep(MockObject $quoteMock): void
120140
{
121141
$billingAddressMock = $this->getBillingAddressMock($quoteMock);
122142

@@ -139,35 +159,42 @@ private function disabledQuoteAddressValidationStep(MockObject $quoteMock)
139159
}
140160

141161
/**
162+
* Get billing address mock object
163+
*
142164
* @param MockObject $quoteMock
143165
* @return Address|MockObject
144166
*/
145-
private function getBillingAddressMock(MockObject $quoteMock)
167+
private function getBillingAddressMock(MockObject $quoteMock): MockObject
146168
{
147-
$billingAddressMock = $this->getMockBuilder(Address::class)
148-
->setMethods(['setShouldIgnoreValidation', 'getEmail', 'setSameAsBilling'])
149-
->disableOriginalConstructor()
150-
->getMock();
169+
if (!isset($this->billingAddressMock)) {
170+
$this->billingAddressMock = $this->getMockBuilder(Address::class)
171+
->setMethods(['setShouldIgnoreValidation', 'getEmail', 'setSameAsBilling'])
172+
->disableOriginalConstructor()
173+
->getMock();
174+
}
151175

152176
$quoteMock->expects(self::any())
153177
->method('getBillingAddress')
154-
->willReturn($billingAddressMock);
178+
->willReturn($this->billingAddressMock);
155179

156-
return $billingAddressMock;
180+
return $this->billingAddressMock;
157181
}
158182

159183
/**
184+
* Get quote mock object
185+
*
160186
* @return Quote|MockObject
161187
*/
162-
private function getQuoteMock()
188+
private function getQuoteMock(): MockObject
163189
{
164190
return $this->getMockBuilder(Quote::class)
165191
->setMethods(
166192
[
167193
'collectTotals',
168194
'getBillingAddress',
169195
'getShippingAddress',
170-
'getIsVirtual'
196+
'getIsVirtual',
197+
'getExtensionAttributes'
171198
]
172199
)->disableOriginalConstructor()
173200
->getMock();

app/code/Magento/Braintree/view/adminhtml/web/js/braintree.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ define([
304304
}
305305

306306
if (!self.validateCardType()) {
307+
$('body').trigger('processStop');
308+
self.error($t('Some payment input fields are invalid.'));
309+
307310
return false;
308311
}
309312

app/code/Magento/Braintree/view/adminhtml/web/js/vault.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ define([
131131
this.createPublicHashSelector();
132132

133133
this.$selector.find('[name="payment[public_hash]"]').val(this.publicHash);
134-
this.$container.find('#' + this.getNonceSelectorName()).val(nonce);
134+
$('#' + this.getNonceSelectorName()).val(nonce);
135135
},
136136

137137
/**
@@ -140,7 +140,7 @@ define([
140140
createPublicHashSelector: function () {
141141
var $input;
142142

143-
if (this.$container.find('#' + this.getNonceSelectorName()).size() === 0) {
143+
if ($('#' + this.getNonceSelectorName()).length === 0) {
144144
$input = $('<input>').attr(
145145
{
146146
type: 'hidden',
@@ -149,7 +149,7 @@ define([
149149
}
150150
);
151151

152-
$input.appendTo(this.$container);
152+
$input.appendTo($('#edit_form'));
153153
$input.prop('disabled', false);
154154
}
155155
},

app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(
5151
* @param string $value
5252
* @param int $length
5353
* @param string $etc
54-
* @param string &$remainder
54+
* @param string $remainder
5555
* @param bool $breakWords
5656
* @return string
5757
*/
@@ -83,6 +83,7 @@ public function getChildren($item)
8383
}
8484

8585
if ($items) {
86+
$itemsArray[$item->getOrderItem()->getId()][$item->getOrderItemId()] = $item;
8687
foreach ($items as $value) {
8788
$parentItem = $value->getOrderItem()->getParentItem();
8889
if ($parentItem) {

app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use PHPUnit\Framework\MockObject\MockObject;
1818
use PHPUnit\Framework\TestCase;
1919

20+
/**
21+
* Test Renderer order item
22+
*/
2023
class RendererTest extends TestCase
2124
{
2225
/** @var Item|MockObject */
@@ -98,25 +101,27 @@ public function testGetChildren($parentItem)
98101
$parentItem = $this->createPartialMock(Item::class, ['getId', '__wakeup']);
99102
$parentItem->expects($this->any())->method('getId')->willReturn(1);
100103
}
101-
$this->orderItem->expects($this->any())->method('getOrderItem')->willReturnSelf();
102-
$this->orderItem->expects($this->any())->method('getParentItem')->willReturn($parentItem);
103-
$this->orderItem->expects($this->any())->method('getOrderItemId')->willReturn(2);
104-
$this->orderItem->expects($this->any())->method('getId')->willReturn(1);
104+
$this->orderItem->method('getOrderItem')->willReturnSelf();
105+
$this->orderItem->method('getParentItem')->willReturn($parentItem);
106+
$this->orderItem->method('getOrderItemId')->willReturn(2);
107+
$this->orderItem->method('getId')->willReturn(1);
105108

106109
$salesModel = $this->createPartialMock(
107110
Invoice::class,
108111
['getAllItems', '__wakeup']
109112
);
110-
$salesModel->expects($this->once())->method('getAllItems')->willReturn([$this->orderItem]);
113+
$salesModel->method('getAllItems')->willReturn([$this->orderItem]);
111114

112115
$item = $this->createPartialMock(
113116
\Magento\Sales\Model\Order\Invoice\Item::class,
114-
['getInvoice', 'getOrderItem', '__wakeup']
117+
['getInvoice', 'getOrderItem', 'getOrderItemId', '__wakeup']
115118
);
116-
$item->expects($this->once())->method('getInvoice')->willReturn($salesModel);
117-
$item->expects($this->any())->method('getOrderItem')->willReturn($this->orderItem);
119+
$item->method('getInvoice')->willReturn($salesModel);
120+
$item->method('getOrderItem')->willReturn($this->orderItem);
121+
$item->method('getOrderItemId')->willReturn($this->orderItem->getOrderItemId());
118122

119-
$this->assertSame([2 => $this->orderItem], $this->model->getChildren($item));
123+
$orderItem = $this->model->getChildren($item);
124+
$this->assertSame([2 => $this->orderItem], $orderItem);
120125
}
121126

122127
/**

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
$defaultMinSaleQty = $block->getDefaultConfigValue('min_sale_qty');
3434
if (!is_numeric($defaultMinSaleQty)) {
3535
$defaultMinSaleQty = json_decode($defaultMinSaleQty, true);
36-
$defaultMinSaleQty = (float) $defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1;
36+
$defaultMinSaleQty = (float) ($defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1);
3737
}
3838
?>
3939
<div class="fieldset-wrapper form-inline advanced-inventory-edit">
@@ -52,17 +52,19 @@ if (!is_numeric($defaultMinSaleQty)) {
5252
<div class="control">
5353
<div class="fields-group-2">
5454
<div class="field">
55-
<select id="inventory_manage_stock" name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[manage_stock]"
55+
<select id="inventory_manage_stock"
56+
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[manage_stock]"
5657
class="select" disabled="disabled">
5758
<option value="1"><?= $block->escapeHtml(__('Yes')) ?></option>
5859
<option value="0"
59-
<?php if ($block->getFieldValue('manage_stock') == 0) :?>
60+
<?php if ($block->getFieldValue('manage_stock') == 0):?>
6061
selected="selected"
6162
<?php endif; ?>><?= $block->escapeHtml(__('No')) ?></option>
6263
</select>
6364
</div>
6465
<div class="field choice">
65-
<input name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[use_config_manage_stock]" type="checkbox"
66+
<input name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[use_config_manage_stock]"
67+
type="checkbox"
6668
id="inventory_use_config_manage_stock" data-role="toggle-editability" value="1"
6769
checked="checked" disabled="disabled"/>
6870
<label for="inventory_use_config_manage_stock"
@@ -211,13 +213,15 @@ if (!is_numeric($defaultMinSaleQty)) {
211213
disabled="disabled">
212214
<option value="0"><?= $block->escapeHtml(__('No')) ?></option>
213215
<option value="1"
214-
<?php if ($block->getDefaultConfigValue('is_qty_decimal') == 1) :?>
216+
<?php if ($block->getDefaultConfigValue('is_qty_decimal') == 1):?>
215217
selected="selected"
216218
<?php endif; ?>><?= $block->escapeHtml(__('Yes')) ?></option>
217219
</select>
218220
</div>
219221
<div class="field choice">
220-
<input type="checkbox" id="inventory_is_qty_decimal_checkbox" data-role="toggle-editability-all"/>
222+
<input type="checkbox"
223+
id="inventory_is_qty_decimal_checkbox"
224+
data-role="toggle-editability-all"/>
221225
<label for="inventory_is_qty_decimal_checkbox"
222226
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
223227
</div>
@@ -238,10 +242,12 @@ if (!is_numeric($defaultMinSaleQty)) {
238242
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[backorders]"
239243
class="select"
240244
disabled="disabled">
241-
<?php foreach ($block->getBackordersOption() as $option) :?>
242-
<?php $_selected = ($option['value'] == $block->getDefaultConfigValue('backorders')) ? ' selected="selected"' : '' ?>
243-
<option
244-
value="<?= $block->escapeHtmlAttr($option['value']) ?>"<?= /* @noEscape */ $_selected ?>><?= $block->escapeHtml($option['label']) ?></option>
245+
<?php foreach ($block->getBackordersOption() as $option):?>
246+
<?php $_selected = ($option['value'] == $block->getDefaultConfigValue('backorders'))
247+
? ' selected="selected"' : '' ?>
248+
<option value="<?= $block->escapeHtmlAttr($option['value']) ?>"
249+
<?= /* @noEscape */ $_selected ?>><?= $block->escapeHtml($option['label']) ?>
250+
</option>
245251
<?php endforeach; ?>
246252
</select>
247253
</div>
@@ -291,7 +297,9 @@ if (!is_numeric($defaultMinSaleQty)) {
291297
class="label"><span><?= $block->escapeHtml(__('Use Config Settings')) ?></span></label>
292298
</div>
293299
<div class="field choice">
294-
<input type="checkbox" id="inventory_notify_stock_qty_checkbox" data-role="toggle-editability-all"/>
300+
<input type="checkbox"
301+
id="inventory_notify_stock_qty_checkbox"
302+
data-role="toggle-editability-all"/>
295303
<label for="inventory_notify_stock_qty_checkbox"
296304
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
297305
</div>
@@ -314,7 +322,7 @@ if (!is_numeric($defaultMinSaleQty)) {
314322
disabled="disabled">
315323
<option value="1"><?= $block->escapeHtml(__('Yes')) ?></option>
316324
<option value="0"
317-
<?php if ($block->getDefaultConfigValue('enable_qty_increments') == 0) :?>
325+
<?php if ($block->getDefaultConfigValue('enable_qty_increments') == 0):?>
318326
selected="selected"
319327
<?php endif; ?>><?= $block->escapeHtml(__('No')) ?></option>
320328
</select>
@@ -330,7 +338,9 @@ if (!is_numeric($defaultMinSaleQty)) {
330338
class="label"><span><?= $block->escapeHtml(__('Use Config Settings')) ?></span></label>
331339
</div>
332340
<div class="field choice">
333-
<input type="checkbox" id="inventory_enable_qty_increments_checkbox" data-role="toggle-editability-all"/>
341+
<input type="checkbox"
342+
id="inventory_enable_qty_increments_checkbox"
343+
data-role="toggle-editability-all"/>
334344
<label for="inventory_enable_qty_increments_checkbox"
335345
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
336346
</div>
@@ -364,7 +374,9 @@ if (!is_numeric($defaultMinSaleQty)) {
364374
class="label"><span><?= $block->escapeHtml(__('Use Config Settings')) ?></span></label>
365375
</div>
366376
<div class="field choice">
367-
<input type="checkbox" id="inventory_qty_increments_checkbox" data-role="toggle-editability-all"/>
377+
<input type="checkbox"
378+
id="inventory_qty_increments_checkbox"
379+
data-role="toggle-editability-all"/>
368380
<label for="inventory_qty_increments_checkbox"
369381
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
370382
</div>
@@ -385,11 +397,15 @@ if (!is_numeric($defaultMinSaleQty)) {
385397
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[is_in_stock]" class="select"
386398
disabled="disabled">
387399
<option value="1"><?= $block->escapeHtml(__('In Stock')) ?></option>
388-
<option value="0"<?php if ($block->getDefaultConfigValue('is_in_stock') == 0) :?> selected<?php endif; ?>><?= $block->escapeHtml(__('Out of Stock')) ?></option>
400+
<option value="0"<?php if ($block->getDefaultConfigValue('is_in_stock') == 0):?>
401+
selected<?php endif; ?>><?= $block->escapeHtml(__('Out of Stock')) ?>
402+
</option>
389403
</select>
390404
</div>
391405
<div class="field choice">
392-
<input type="checkbox" id="inventory_stock_availability_checkbox" data-role="toggle-editability-all"/>
406+
<input type="checkbox"
407+
id="inventory_stock_availability_checkbox"
408+
data-role="toggle-editability-all"/>
393409
<label for="inventory_stock_availability_checkbox"
394410
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
395411
</div>

0 commit comments

Comments
 (0)