Skip to content

Commit f51037a

Browse files
MAGETWO-87313: [EngCom Team] Batch 21. Forwardports to 2.3-develop #1323
2 parents 3881f04 + 66edb2c commit f51037a

File tree

21 files changed

+293
-36
lines changed

21 files changed

+293
-36
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDe
534534
public function clearEmptyData(array $rowData)
535535
{
536536
foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
537-
if (!$attrParams['is_static'] && empty($rowData[$attrCode])) {
537+
if (!$attrParams['is_static'] && !isset($rowData[$attrCode])) {
538538
unset($rowData[$attrCode]);
539539
}
540540
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
9+
<acl>
10+
<resources>
11+
<resource id="Magento_Backend::admin">
12+
<resource id="Magento_Backend::system">
13+
<resource id="Magento_Integration::extensions" title="System Extensions" translate="title" sortOrder="30">
14+
<resource id="Magento_Integration::integrations" title="System Integrations" translate="title" sortOrder="40" />
15+
</resource>
16+
</resource>
17+
</resource>
18+
</resources>
19+
</acl>
20+
</config>

app/code/Magento/Review/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ Summary,Summary
132132
"Allow Guests to Write Reviews","Allow Guests to Write Reviews"
133133
Active,Active
134134
Inactive,Inactive
135+
"Please select one of each of the ratings above.","Please select one of each of the ratings above."

app/code/Magento/Review/view/frontend/templates/form.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
id="<?= $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_<?= $block->escapeHtmlAttr($_option->getValue()) ?>"
3636
value="<?= $block->escapeHtmlAttr($_option->getId()) ?>"
3737
class="radio"
38-
data-validate="{required:true, messages:{required:'Please select one of each of the ratings above.'}}"
38+
data-validate="{'rating-required':true}"
3939
aria-labelledby="<?= $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_rating_label <?= $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_<?= $block->escapeHtmlAttr($_option->getValue()) ?>_label" />
4040
<label
4141
class="rating-<?= $block->escapeHtmlAttr($iterator) ?>"
@@ -85,7 +85,8 @@
8585
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
8686
},
8787
"#review-form": {
88-
"Magento_Review/js/error-placement": {}
88+
"Magento_Review/js/error-placement": {},
89+
"Magento_Review/js/validate-review": {}
8990
}
9091
}
9192
</script>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'jquery/ui',
9+
'jquery/validate',
10+
'mage/translate'
11+
], function ($) {
12+
'use strict';
13+
14+
$.validator.addMethod(
15+
'rating-required', function (value) {
16+
return value !== undefined;
17+
}, $.mage.__('Please select one of each of the ratings above.'));
18+
});

app/code/Magento/Robots/Controller/Index/Index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function execute()
4343
/** @var Page $resultPage */
4444
$resultPage = $this->resultPageFactory->create(true);
4545
$resultPage->addHandle('robots_index_index');
46+
$resultPage->setHeader('Content-Type', 'text/plain');
4647
return $resultPage;
4748
}
4849
}

app/code/Magento/Robots/Test/Unit/Controller/Index/IndexTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public function testExecute()
5151
$resultPageMock->expects($this->once())
5252
->method('addHandle')
5353
->with('robots_index_index');
54+
$resultPageMock->expects($this->once())
55+
->method('setHeader')
56+
->with('Content-Type', 'text/plain');
5457

5558
$this->resultPageFactory->expects($this->any())
5659
->method('create')

app/code/Magento/Sales/Model/Service/CreditmemoService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function refund(
195195
*/
196196
protected function validateForRefund(\Magento\Sales\Api\Data\CreditmemoInterface $creditmemo)
197197
{
198-
if ($creditmemo->getId()) {
198+
if ($creditmemo->getId() && $creditmemo->getState() != \Magento\Sales\Model\Order\Creditmemo::STATE_OPEN) {
199199
throw new \Magento\Framework\Exception\LocalizedException(
200200
__('We cannot register an existing credit memo.')
201201
);

app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,78 @@ public function testRefund()
243243
$this->assertSame($creditMemoMock, $this->creditmemoService->refund($creditMemoMock, true));
244244
}
245245

246+
public function testRefundPendingCreditMemo()
247+
{
248+
$creditMemoMock = $this->getMockBuilder(\Magento\Sales\Api\Data\CreditmemoInterface::class)
249+
->setMethods(['getId', 'getOrder', 'getState', 'getInvoice'])
250+
->disableOriginalConstructor()
251+
->getMockForAbstractClass();
252+
$creditMemoMock->expects($this->once())->method('getId')->willReturn(444);
253+
$creditMemoMock->expects($this->once())->method('getState')
254+
->willReturn(\Magento\Sales\Model\Order\Creditmemo::STATE_OPEN);
255+
$orderMock = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
256+
257+
$creditMemoMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($orderMock);
258+
$orderMock->expects($this->once())->method('getBaseTotalRefunded')->willReturn(0);
259+
$orderMock->expects($this->once())->method('getBaseTotalPaid')->willReturn(10);
260+
$creditMemoMock->expects($this->once())->method('getBaseGrandTotal')->willReturn(10);
261+
262+
$this->priceCurrencyMock->expects($this->any())
263+
->method('round')
264+
->willReturnArgument(0);
265+
266+
// Set payment adapter dependency
267+
$refundAdapterMock = $this->getMockBuilder(\Magento\Sales\Model\Order\RefundAdapterInterface::class)
268+
->disableOriginalConstructor()
269+
->getMockForAbstractClass();
270+
$this->objectManagerHelper->setBackwardCompatibleProperty(
271+
$this->creditmemoService,
272+
'refundAdapter',
273+
$refundAdapterMock
274+
);
275+
276+
// Set resource dependency
277+
$resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
278+
->disableOriginalConstructor()
279+
->getMock();
280+
$this->objectManagerHelper->setBackwardCompatibleProperty(
281+
$this->creditmemoService,
282+
'resource',
283+
$resourceMock
284+
);
285+
286+
// Set order repository dependency
287+
$orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class)
288+
->disableOriginalConstructor()
289+
->getMockForAbstractClass();
290+
$this->objectManagerHelper->setBackwardCompatibleProperty(
291+
$this->creditmemoService,
292+
'orderRepository',
293+
$orderRepositoryMock
294+
);
295+
296+
$adapterMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
297+
->disableOriginalConstructor()
298+
->getMockForAbstractClass();
299+
$resourceMock->expects($this->once())->method('getConnection')->with('sales')->willReturn($adapterMock);
300+
$adapterMock->expects($this->once())->method('beginTransaction');
301+
$refundAdapterMock->expects($this->once())
302+
->method('refund')
303+
->with($creditMemoMock, $orderMock, false)
304+
->willReturn($orderMock);
305+
$orderRepositoryMock->expects($this->once())
306+
->method('save')
307+
->with($orderMock);
308+
$creditMemoMock->expects($this->once())
309+
->method('getInvoice')
310+
->willReturn(null);
311+
$adapterMock->expects($this->once())->method('commit');
312+
$this->creditmemoRepositoryMock->expects($this->once())
313+
->method('save');
314+
315+
$this->assertSame($creditMemoMock, $this->creditmemoService->refund($creditMemoMock, true));
316+
}
317+
246318
/**
247319
* @expectedExceptionMessage The most money available to refund is 1.
248320
* @expectedException \Magento\Framework\Exception\LocalizedException

app/code/Magento/Wishlist/view/frontend/layout/wishlist_email_rss.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<body>
10-
<referenceContainer name="root">
11-
<block class="Magento\Wishlist\Block\Rss\EmailLink" name="wishlist.email.rss" cacheable="false"/>
12-
</referenceContainer>
10+
<block class="Magento\Wishlist\Block\Rss\EmailLink" name="wishlist.email.rss" cacheable="false"/>
1311
</body>
1412
</page>

0 commit comments

Comments
 (0)