Skip to content

Commit 74904a9

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-pangolin/2.3-develop-pangolin
2 parents d3aea00 + 7acc042 commit 74904a9

File tree

45 files changed

+2275
-291
lines changed

Some content is hidden

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

45 files changed

+2275
-291
lines changed

app/code/Magento/Backend/view/adminhtml/templates/page/report.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88

99
?>
1010
<?php if ($block->getBugreportUrl()): ?>
11-
<a class="link-report" href="<?= /* @escapeNotVerified */ $block->getBugreportUrl() ?>" id="footer_bug_tracking"><?= /* @escapeNotVerified */ __('Report an Issue') ?></a>
11+
<a class="link-report" href="<?= /* @escapeNotVerified */ $block->getBugreportUrl() ?>" id="footer_bug_tracking" target="_blank">
12+
<?= /* @escapeNotVerified */ __('Report an Issue') ?>
13+
</a>
1214
<?php endif; ?>

app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
class Create extends \Magento\Backup\Controller\Adminhtml\Index
1313
{
1414
/**
15-
* Create backup action
15+
* Create backup action.
1616
*
1717
* @return void|\Magento\Backend\App\Action
1818
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
1919
*/
2020
public function execute()
2121
{
22-
if (!$this->getRequest()->isAjax()) {
22+
if (!$this->isRequestAllowed()) {
2323
return $this->_redirect('*/*/index');
2424
}
2525

@@ -106,4 +106,14 @@ public function execute()
106106

107107
$this->getResponse()->representJson($response->toJson());
108108
}
109+
110+
/**
111+
* Check if request is allowed.
112+
*
113+
* @return bool
114+
*/
115+
private function isRequestAllowed()
116+
{
117+
return $this->getRequest()->isAjax() && $this->getRequest()->isPost();
118+
}
109119
}
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backup\Test\Unit\Controller\Adminhtml\Index;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
10+
/**
11+
* Tests \Magento\Backup\Controller\Adminhtml\Index\Create class.
12+
*
13+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14+
*/
15+
class CreateTest extends \PHPUnit\Framework\TestCase
16+
{
17+
/**
18+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
19+
*/
20+
private $objectManager;
21+
22+
/**
23+
* @var \Magento\Backend\App\Action\Context
24+
*/
25+
private $context;
26+
27+
/**
28+
* @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $objectManagerMock;
31+
32+
/**
33+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
private $requestMock;
36+
37+
/**
38+
* @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
private $responseMock;
41+
42+
/**
43+
* @var \Magento\Backup\Model\Backup|\PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
private $backupModelMock;
46+
47+
/**
48+
* @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
private $dataBackendHelperMock;
51+
52+
/**
53+
* @var \Magento\Backup\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
54+
*/
55+
private $dataBackupHelperMock;
56+
57+
/**
58+
* @var \Magento\Framework\App\Response\Http\FileFactory|\PHPUnit_Framework_MockObject_MockObject
59+
*/
60+
private $fileFactoryMock;
61+
62+
/**
63+
* @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject
64+
*/
65+
private $sessionMock;
66+
67+
/**
68+
* @var \Magento\Framework\App\MaintenanceMode|\PHPUnit_Framework_MockObject_MockObject
69+
*/
70+
private $maintenanceModeMock;
71+
72+
/**
73+
* @var \Magento\Framework\Backup\Factory|\PHPUnit_Framework_MockObject_MockObject
74+
*/
75+
private $backupFactoryMock;
76+
77+
/**
78+
* @var \Magento\Backup\Controller\Adminhtml\Index\Create
79+
*/
80+
private $createController;
81+
82+
public function setUp()
83+
{
84+
$this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
85+
->getMock();
86+
$this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
87+
->disableOriginalConstructor()
88+
->setMethods(['isAjax', 'isPost', 'getParam'])
89+
->getMock();
90+
$this->responseMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http::class)
91+
->disableOriginalConstructor()
92+
->setMethods(['representJson', 'setRedirect'])
93+
->getMock();
94+
$this->sessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class)
95+
->disableOriginalConstructor()
96+
->getMock();
97+
$this->backupFactoryMock = $this->getMockBuilder(\Magento\Framework\Backup\Factory::class)
98+
->disableOriginalConstructor()
99+
->setMethods(['create'])
100+
->getMock();
101+
$this->backupModelMock = $this->getMockBuilder(\Magento\Backup\Model\Backup::class)
102+
->disableOriginalConstructor()
103+
->setMethods(['setBackupExtension', 'setTime', 'setBackupsDir', 'setName', 'create'])
104+
->getMock();
105+
$this->dataBackendHelperMock = $this->getMockBuilder(\Magento\Backend\Helper\Data::class)
106+
->disableOriginalConstructor()
107+
->setMethods(['getUrl'])
108+
->getMock();
109+
$this->dataBackupHelperMock = $this->getMockBuilder(\Magento\Backup\Helper\Data::class)
110+
->disableOriginalConstructor()
111+
->setMethods(['getExtensionByType', 'getBackupsDir'])
112+
->getMock();
113+
$this->maintenanceModeMock = $this->getMockBuilder(\Magento\Framework\App\MaintenanceMode::class)
114+
->disableOriginalConstructor()
115+
->setMethods(['set'])
116+
->getMock();
117+
$this->fileFactoryMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class)
118+
->disableOriginalConstructor()
119+
->getMock();
120+
$this->objectManager = new ObjectManager($this);
121+
$this->context = $this->objectManager->getObject(
122+
\Magento\Backend\App\Action\Context::class,
123+
[
124+
'objectManager' => $this->objectManagerMock,
125+
'request' => $this->requestMock,
126+
'response' => $this->responseMock,
127+
'session' => $this->sessionMock,
128+
'helper' => $this->dataBackendHelperMock,
129+
'maintenanceMode' => $this->maintenanceModeMock,
130+
]
131+
);
132+
$this->createController = $this->objectManager->getObject(
133+
\Magento\Backup\Controller\Adminhtml\Index\Create::class,
134+
[
135+
'context' => $this->context,
136+
'backupFactory' => $this->backupFactoryMock,
137+
'fileFactory' => $this->fileFactoryMock,
138+
]
139+
);
140+
}
141+
142+
/**
143+
* @covers \Magento\Backup\Controller\Adminhtml\Index\Create::execute
144+
* @return void
145+
*/
146+
public function testExecuteNotPost()
147+
{
148+
$redirectUrl = '*/*/index';
149+
$redirectUrlBackup = 'backup/index/index';
150+
151+
$this->requestMock->expects($this->any())
152+
->method('isAjax')
153+
->willReturn(true);
154+
$this->requestMock->expects($this->any())
155+
->method('isPost')
156+
->willReturn(false);
157+
$this->dataBackendHelperMock->expects($this->any())
158+
->method('getUrl')
159+
->with($redirectUrl, [])
160+
->willReturn($redirectUrlBackup);
161+
$this->responseMock->expects($this->any())
162+
->method('setRedirect')
163+
->with($redirectUrlBackup)
164+
->willReturnSelf();
165+
166+
$this->assertSame($this->responseMock, $this->createController->execute());
167+
}
168+
169+
/**
170+
* @covers \Magento\Backup\Controller\Adminhtml\Index\Create::execute
171+
* @return void
172+
*/
173+
public function testExecutePermission()
174+
{
175+
$redirectUrl = '*/*/index';
176+
$redirectUrlBackup = 'backup/index/index';
177+
$backupType = 'db';
178+
$backupName = 'backup1';
179+
$response = '{"redirect_url":"backup\/index\/index"}';
180+
181+
$this->requestMock->expects($this->any())
182+
->method('isAjax')
183+
->willReturn(true);
184+
$this->requestMock->expects($this->any())
185+
->method('isPost')
186+
->willReturn(true);
187+
$this->requestMock->expects($this->any())
188+
->method('getParam')
189+
->willReturnMap([
190+
['type', null, $backupType],
191+
['backup_name', null, $backupName],
192+
]);
193+
$this->dataBackendHelperMock->expects($this->any())
194+
->method('getUrl')
195+
->with($redirectUrl, [])
196+
->willReturn($redirectUrlBackup);
197+
$this->responseMock->expects($this->any())
198+
->method('representJson')
199+
->with($response)
200+
->willReturnSelf();
201+
$this->maintenanceModeMock->expects($this->any())
202+
->method('set')
203+
->with(true)
204+
->willReturn(false);
205+
$this->backupFactoryMock->expects($this->any())
206+
->method('create')
207+
->with($backupType)
208+
->willReturn($this->backupModelMock);
209+
$this->backupModelMock->expects($this->any())
210+
->method('setBackupExtension')
211+
->with($backupType)
212+
->willReturnSelf();
213+
$this->backupModelMock->expects($this->any())
214+
->method('setBackupsDir')
215+
->willReturnSelf();
216+
$this->backupModelMock->expects($this->any())
217+
->method('setTime')
218+
->willReturnSelf();
219+
$this->backupModelMock->expects($this->any())
220+
->method('setName')
221+
->with($backupName)
222+
->willReturnSelf();
223+
$this->backupModelMock->expects($this->once())
224+
->method('create')
225+
->willReturnSelf();
226+
$this->objectManagerMock->expects($this->any())
227+
->method('get')
228+
->with(\Magento\Backup\Helper\Data::class)
229+
->willReturn($this->dataBackupHelperMock);
230+
$this->dataBackupHelperMock->expects($this->any())
231+
->method('getExtensionByType')
232+
->with($backupType)
233+
->willReturn($backupType);
234+
$this->dataBackupHelperMock->expects($this->any())
235+
->method('getBackupsDir')
236+
->willReturn('dir');
237+
238+
$this->assertNull($this->createController->execute());
239+
}
240+
}

app/code/Magento/Checkout/CustomerData/DefaultItem.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Checkout\CustomerData;
88

9+
use Magento\Framework\App\ObjectManager;
10+
911
/**
1012
* Default item
1113
*/
@@ -36,26 +38,36 @@ class DefaultItem extends AbstractItem
3638
*/
3739
protected $checkoutHelper;
3840

41+
/**
42+
* Escaper
43+
*
44+
* @var \Magento\Framework\Escaper
45+
*/
46+
private $escaper;
47+
3948
/**
4049
* @param \Magento\Catalog\Helper\Image $imageHelper
4150
* @param \Magento\Msrp\Helper\Data $msrpHelper
4251
* @param \Magento\Framework\UrlInterface $urlBuilder
4352
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
4453
* @param \Magento\Checkout\Helper\Data $checkoutHelper
54+
* @param \Magento\Framework\Escaper|null $escaper
4555
* @codeCoverageIgnore
4656
*/
4757
public function __construct(
4858
\Magento\Catalog\Helper\Image $imageHelper,
4959
\Magento\Msrp\Helper\Data $msrpHelper,
5060
\Magento\Framework\UrlInterface $urlBuilder,
5161
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
52-
\Magento\Checkout\Helper\Data $checkoutHelper
62+
\Magento\Checkout\Helper\Data $checkoutHelper,
63+
\Magento\Framework\Escaper $escaper = null
5364
) {
5465
$this->configurationPool = $configurationPool;
5566
$this->imageHelper = $imageHelper;
5667
$this->msrpHelper = $msrpHelper;
5768
$this->urlBuilder = $urlBuilder;
5869
$this->checkoutHelper = $checkoutHelper;
70+
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(\Magento\Framework\Escaper::class);
5971
}
6072

6173
/**
@@ -64,14 +76,16 @@ public function __construct(
6476
protected function doGetItemData()
6577
{
6678
$imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail');
79+
$productName = $this->escaper->escapeHtml($this->item->getProduct()->getName());
80+
6781
return [
6882
'options' => $this->getOptionList(),
6983
'qty' => $this->item->getQty() * 1,
7084
'item_id' => $this->item->getId(),
7185
'configure_url' => $this->getConfigureUrl(),
7286
'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
7387
'product_id' => $this->item->getProduct()->getId(),
74-
'product_name' => $this->item->getProduct()->getName(),
88+
'product_name' => $productName,
7589
'product_sku' => $this->item->getProduct()->getSku(),
7690
'product_url' => $this->getProductUrl(),
7791
'product_has_url' => $this->hasProductUrl(),

app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div class="product-item-details">
2525
<strong class="product-item-name">
2626
<!-- ko if: product_has_url -->
27-
<a data-bind="attr: {href: product_url}, text: product_name"></a>
27+
<a data-bind="attr: {href: product_url}, html: product_name"></a>
2828
<!-- /ko -->
2929
<!-- ko ifnot: product_has_url -->
3030
<!-- ko text: product_name --><!-- /ko -->

app/code/Magento/ConfigurableProduct/CustomerData/ConfigurableItem.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,24 @@ class ConfigurableItem extends DefaultItem
2626
* @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
2727
* @param \Magento\Checkout\Helper\Data $checkoutHelper
2828
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
29+
* @param \Magento\Framework\Escaper|null $escaper
2930
*/
3031
public function __construct(
3132
\Magento\Catalog\Helper\Image $imageHelper,
3233
\Magento\Msrp\Helper\Data $msrpHelper,
3334
\Magento\Framework\UrlInterface $urlBuilder,
3435
\Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool,
3536
\Magento\Checkout\Helper\Data $checkoutHelper,
36-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
37+
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
38+
\Magento\Framework\Escaper $escaper = null
3739
) {
3840
parent::__construct(
3941
$imageHelper,
4042
$msrpHelper,
4143
$urlBuilder,
4244
$configurationPool,
43-
$checkoutHelper
45+
$checkoutHelper,
46+
$escaper
4447
);
4548
$this->_scopeConfig = $scopeConfig;
4649
}

app/code/Magento/Customer/Block/Address/Edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function _prepareLayout()
129129

130130
if ($postedData = $this->_customerSession->getAddressFormData(true)) {
131131
$postedData['region'] = [
132-
'region_id' => $postedData['region_id'],
132+
'region_id' => isset($postedData['region_id']) ? $postedData['region_id'] : null,
133133
'region' => $postedData['region'],
134134
];
135135
$this->dataObjectHelper->populateWithArray(

0 commit comments

Comments
 (0)