Skip to content

Commit 268dce1

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1546 from magento-engcom/2.2-develop-prs
Public Pull Requests: #11200 #11147 #11154 #11160 #11138 #11127 #11048 #11049 #11069 #11084
2 parents 11a29d7 + 30003ae commit 268dce1

File tree

16 files changed

+86
-29
lines changed

16 files changed

+86
-29
lines changed

app/code/Magento/Catalog/Block/Category/Plugin/PriceBoxTags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ private function getTaxRateIds(PriceBox $subject)
102102

103103
if (!empty($billingAddress) || !empty($shippingAddress)) {
104104
$rateRequest = $this->getTaxCalculation()->getRateRequest(
105-
$billingAddress,
106105
$shippingAddress,
106+
$billingAddress,
107107
$customerTaxClassId,
108108
$this->scopeResolver->getScope()->getId(),
109109
$this->customerSession->getCustomerId()

app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ protected function processDeletedImages($product, array &$images)
3333
if (!empty($image['removed'])) {
3434
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
3535
$recordsToDelete[] = $image['value_id'];
36-
// only delete physical files if they are not used by any other products
37-
if (!$this->resourceModel->countImageUses($image['file']) > 1) {
36+
$catalogPath = $this->mediaConfig->getBaseMediaPath();
37+
$isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']);
38+
// only delete physical files if they are not used by any other products and if this file exists
39+
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
3840
$filesToDelete[] = ltrim($image['file'], '/');
3941
}
4042
}

app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public function testAfterGetCacheKey()
119119
$this->session->expects($this->once())->method('getCustomerId')->willReturn($customerId);
120120
$rateRequest = $this->getMockBuilder(\Magento\Framework\DataObject::class)->getMock();
121121
$this->taxCalculation->expects($this->once())->method('getRateRequest')->with(
122-
new \Magento\Framework\DataObject($billingAddress),
123122
new \Magento\Framework\DataObject($shippingAddress),
123+
new \Magento\Framework\DataObject($billingAddress),
124124
$customerTaxClassId,
125125
$scopeId,
126126
$customerId

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ protected function createCategory($name, $parentId)
118118
$category->setIsActive(true);
119119
$category->setIncludeInMenu(true);
120120
$category->setAttributeSetId($category->getDefaultAttributeSetId());
121-
$category->save();
122-
$this->categoriesCache[$category->getId()] = $category;
121+
try {
122+
$category->save();
123+
$this->categoriesCache[$category->getId()] = $category;
124+
} catch (\Exception $e) {
125+
$this->addFailedCategory($category, $e);
126+
}
123127

124128
return $category->getId();
125129
}

app/code/Magento/Cms/Helper/Wysiwyg/Images.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,14 @@ public function getImageHtmlDeclaration($filename, $renderAsTag = false)
177177
$html = $fileurl; // $mediaPath;
178178
} else {
179179
$directive = $this->urlEncoder->encode($directive);
180-
$html = $this->_backendData->getUrl('cms/wysiwyg/directive', ['___directive' => $directive]);
180+
181+
$html = $this->_backendData->getUrl(
182+
'cms/wysiwyg/directive',
183+
[
184+
'___directive' => $directive,
185+
'_escape_params' => false,
186+
]
187+
);
181188
}
182189
}
183190
return $html;

app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function testGetImageHtmlDeclaration($baseUrl, $fileName, $isUsingStaticU
450450

451451
$this->backendDataMock->expects($this->any())
452452
->method('getUrl')
453-
->with('cms/wysiwyg/directive', ['___directive' => $directive])
453+
->with('cms/wysiwyg/directive', ['___directive' => $directive, '_escape_params' => false])
454454
->willReturn($directive);
455455

456456
$this->assertEquals($expectedHtml, $this->imagesHelper->getImageHtmlDeclaration($fileName));

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/Sales/Model/Order/Shipment/ItemCreation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function getOrderItemId()
4343
public function setOrderItemId($orderItemId)
4444
{
4545
$this->orderItemId = $orderItemId;
46+
return $this;
4647
}
4748

4849
/**
@@ -59,6 +60,7 @@ public function getQty()
5960
public function setQty($qty)
6061
{
6162
$this->qty = $qty;
63+
return $this;
6264
}
6365

6466
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public function __construct(
8787
public function cancel($id)
8888
{
8989
$order = $this->orderRepository->get($id);
90-
if ((bool)$order->cancel()) {
90+
if ($order->canCancel()) {
91+
$order->cancel();
9192
$this->orderRepository->save($order);
9293
return true;
9394
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,30 @@ public function testCancel()
163163
$this->orderMock->expects($this->once())
164164
->method('cancel')
165165
->willReturn($this->orderMock);
166+
$this->orderMock->expects($this->once())
167+
->method('canCancel')
168+
->willReturn(true);
166169
$this->assertTrue($this->orderService->cancel(123));
167170
}
168171

172+
/**
173+
* test for Order::cancel() fail case
174+
*/
175+
public function testCancelFailed()
176+
{
177+
$this->orderRepositoryMock->expects($this->once())
178+
->method('get')
179+
->with(123)
180+
->willReturn($this->orderMock);
181+
$this->orderMock->expects($this->never())
182+
->method('cancel')
183+
->willReturn($this->orderMock);
184+
$this->orderMock->expects($this->once())
185+
->method('canCancel')
186+
->willReturn(false);
187+
$this->assertFalse($this->orderService->cancel(123));
188+
}
189+
169190
public function testGetCommentsList()
170191
{
171192
$this->filterBuilderMock->expects($this->once())

app/code/Magento/Store/Model/Address/Renderer.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
*/
1616
class Renderer
1717
{
18+
const DEFAULT_TEMPLATE = "{{var name}}\n" .
19+
"{{var street_line1}}\n" .
20+
"{{depend street_line2}}{{var street_line2}}\n{{/depend}}" .
21+
"{{depend city}}{{var city}},{{/depend}} {{var region}} {{depend postcode}}{{var postcode}},{{/depend}}\n" .
22+
"{{var country}}";
23+
1824
/**
1925
* @var EventManager
2026
*/
@@ -25,18 +31,26 @@ class Renderer
2531
*/
2632
protected $filterManager;
2733

34+
/**
35+
* @var string
36+
*/
37+
private $template;
38+
2839
/**
2940
* Constructor
3041
*
3142
* @param EventManager $eventManager
3243
* @param FilterManager $filterManager
44+
* @param string $template
3345
*/
3446
public function __construct(
3547
EventManager $eventManager,
36-
FilterManager $filterManager
48+
FilterManager $filterManager,
49+
$template = self::DEFAULT_TEMPLATE
3750
) {
3851
$this->eventManager = $eventManager;
3952
$this->filterManager = $filterManager;
53+
$this->template = $template;
4054
}
4155

4256
/**
@@ -50,9 +64,7 @@ public function format(DataObject $storeInfo, $type = 'html')
5064
{
5165
$this->eventManager->dispatch('store_address_format', ['type' => $type, 'store_info' => $storeInfo]);
5266
$address = $this->filterManager->template(
53-
"{{var name}}\n{{var street_line1}}\n{{depend street_line2}}{{var street_line2}}\n{{/depend}}" .
54-
"{{depend city}}{{var city}},{{/depend}} {{var region}} {{depend postcode}}{{var postcode}},{{/depend}}\n" .
55-
"{{var country}}",
67+
$this->template,
5668
['variables' => $storeInfo->getData()]
5769
);
5870

app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ define([
244244
],
245245
'stripped-min-length': [
246246
function (value, param) {
247-
return $(value).text().length >= param;
247+
return value.length >= param;
248248
},
249249
$.mage.__('Please enter at least {0} characters')
250250
],

lib/internal/Magento/Framework/App/Response/Http/FileFactory.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,7 @@ public function create(
9999
if (!empty($content['rm'])) {
100100
$dir->delete($file);
101101
}
102-
$this->callExit();
103102
}
104103
return $this->_response;
105104
}
106-
107-
/**
108-
* Call exit
109-
*
110-
* @return void
111-
* @SuppressWarnings(PHPMD.ExitExpression)
112-
*/
113-
protected function callExit()
114-
{
115-
exit(0);
116-
}
117105
}

lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private function getModel()
235235
private function getModelMock()
236236
{
237237
$modelMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class)
238-
->setMethods(['callExit'])
238+
->setMethods(null)
239239
->setConstructorArgs(
240240
[
241241
'response' => $this->responseMock,

0 commit comments

Comments
 (0)