Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 1abb398

Browse files
author
Alexander Akimov
authored
Merge pull request #3687 from magento-tsg/2.3-qwerty-pr42
[TSG] Upporting for 2.3 (pr42) (2.3-qwerty)
2 parents 62124e3 + 2817635 commit 1abb398

File tree

9 files changed

+148
-50
lines changed

9 files changed

+148
-50
lines changed

app/code/Magento/Backend/Block/Widget/Form/Container.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Container extends \Magento\Backend\Block\Widget\Container
5656
protected $_template = 'Magento_Backend::widget/form/container.phtml';
5757

5858
/**
59+
* Initialize form.
60+
*
5961
* @return void
6062
*/
6163
protected function _construct()
@@ -83,7 +85,7 @@ protected function _construct()
8385
-1
8486
);
8587

86-
$objId = $this->getRequest()->getParam($this->_objectId);
88+
$objId = (int)$this->getRequest()->getParam($this->_objectId);
8789

8890
if (!empty($objId)) {
8991
$this->addButton(
@@ -151,11 +153,13 @@ public function getBackUrl()
151153
}
152154

153155
/**
156+
* Get URL for delete button.
157+
*
154158
* @return string
155159
*/
156160
public function getDeleteUrl()
157161
{
158-
return $this->getUrl('*/*/delete', [$this->_objectId => $this->getRequest()->getParam($this->_objectId)]);
162+
return $this->getUrl('*/*/delete', [$this->_objectId => (int)$this->getRequest()->getParam($this->_objectId)]);
159163
}
160164

161165
/**
@@ -183,6 +187,8 @@ public function getFormActionUrl()
183187
}
184188

185189
/**
190+
* Get form HTML.
191+
*
186192
* @return string
187193
*/
188194
public function getFormHtml()
@@ -192,6 +198,8 @@ public function getFormHtml()
192198
}
193199

194200
/**
201+
* Get form init scripts.
202+
*
195203
* @return string
196204
*/
197205
public function getFormInitScripts()
@@ -203,6 +211,8 @@ public function getFormInitScripts()
203211
}
204212

205213
/**
214+
* Get form scripts.
215+
*
206216
* @return string
207217
*/
208218
public function getFormScripts()
@@ -214,6 +224,8 @@ public function getFormScripts()
214224
}
215225

216226
/**
227+
* Get header width.
228+
*
217229
* @return string
218230
*/
219231
public function getHeaderWidth()
@@ -222,6 +234,8 @@ public function getHeaderWidth()
222234
}
223235

224236
/**
237+
* Get header css class.
238+
*
225239
* @return string
226240
*/
227241
public function getHeaderCssClass()
@@ -230,6 +244,8 @@ public function getHeaderCssClass()
230244
}
231245

232246
/**
247+
* Get header HTML.
248+
*
233249
* @return string
234250
*/
235251
public function getHeaderHtml()

app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Catalog\Model\Config\CatalogClone\Media;
77

8+
use Magento\Framework\Escaper;
9+
use Magento\Framework\App\ObjectManager;
10+
811
/**
912
* Clone model for media images related config fields
1013
*
@@ -26,6 +29,11 @@ class Image extends \Magento\Framework\App\Config\Value
2629
*/
2730
protected $_attributeCollectionFactory;
2831

32+
/**
33+
* @var Escaper
34+
*/
35+
private $escaper;
36+
2937
/**
3038
* @param \Magento\Framework\Model\Context $context
3139
* @param \Magento\Framework\Registry $registry
@@ -36,6 +44,9 @@ class Image extends \Magento\Framework\App\Config\Value
3644
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
3745
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
3846
* @param array $data
47+
* @param Escaper|null $escaper
48+
*
49+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
3950
*/
4051
public function __construct(
4152
\Magento\Framework\Model\Context $context,
@@ -46,8 +57,10 @@ public function __construct(
4657
\Magento\Eav\Model\Config $eavConfig,
4758
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
4859
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
49-
array $data = []
60+
array $data = [],
61+
Escaper $escaper = null
5062
) {
63+
$this->escaper = $escaper ?? ObjectManager::getInstance()->get(Escaper::class);
5164
$this->_attributeCollectionFactory = $attributeCollectionFactory;
5265
$this->_eavConfig = $eavConfig;
5366
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
@@ -71,10 +84,9 @@ public function getPrefixes()
7184
$prefixes = [];
7285

7386
foreach ($collection as $attribute) {
74-
/* @var $attribute \Magento\Eav\Model\Entity\Attribute */
7587
$prefixes[] = [
7688
'field' => $attribute->getAttributeCode() . '_',
77-
'label' => $attribute->getFrontend()->getLabel(),
89+
'label' => $this->escaper->escapeHtml($attribute->getFrontend()->getLabel()),
7890
];
7991
}
8092

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductImageAssignmentForMultipleStoresTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106

107107
<!-- Go to Product Page and see Default Store View-->
108108
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.custom_attributes[url_key]$$)}}" stepKey="goToDefaultStorefrontProductPage"/>
109+
<waitForElementVisible selector="{{StorefrontProductMediaSection.productImageActive(TestImageNew.filename)}}" time="30" stepKey="waitImageToBeLoaded"/>
109110
<seeElement selector="{{StorefrontProductMediaSection.productImageActive(TestImageNew.filename)}}" stepKey="seeActiveImageDefault"/>
110111

111112
<!-- English Switch Store View and see English Store View -->
@@ -117,6 +118,7 @@
117118
<seeElement selector="{{StorefrontCategoryProductSection.ProductImageBySrc(ProductImage.fileName)}}" stepKey="seeThumb"/>
118119
<click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct.name$$)}}" stepKey="openProductPage"/>
119120
<waitForPageLoad time="30" stepKey="waitForProductPage"/>
121+
<waitForElementVisible selector="{{StorefrontProductMediaSection.productImageActive(ProductImage.filename)}}" time="30" stepKey="waitImageToBeLoaded2"/>
120122
<seeElement selector="{{StorefrontProductMediaSection.productImageActive(ProductImage.filename)}}" stepKey="seeActiveImageEnglish"/>
121123

122124
<!-- Switch France Store View and see France Store View -->
@@ -128,6 +130,7 @@
128130
<seeElement selector="{{StorefrontCategoryProductSection.ProductImageBySrc(Magento3.fileName)}}" stepKey="seeThumb1"/>
129131
<click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct.name$$)}}" stepKey="openProductPage1"/>
130132
<waitForPageLoad time="30" stepKey="waitForProductPage1"/>
133+
<waitForElementVisible selector="{{StorefrontProductMediaSection.productImageActive(Magento3.filename)}}" time="30" stepKey="waitImageToBeLoaded3"/>
131134
<seeElement selector="{{StorefrontProductMediaSection.productImageActive(Magento3.filename)}}" stepKey="seeActiveImageFrance"/>
132135
</test>
133136
</tests>

app/code/Magento/Catalog/Test/Unit/Model/Config/CatalogClone/Media/ImageTest.php

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
1010
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1111

12+
/**
13+
* Tests \Magento\Catalog\Model\Config\CatalogClone\Media\Image.
14+
*
15+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16+
*/
1217
class ImageTest extends \PHPUnit\Framework\TestCase
1318
{
1419
/**
@@ -36,6 +41,14 @@ class ImageTest extends \PHPUnit\Framework\TestCase
3641
*/
3742
private $attribute;
3843

44+
/**
45+
* @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
46+
*/
47+
private $escaperMock;
48+
49+
/**
50+
* @inheritdoc
51+
*/
3952
protected function setUp()
4053
{
4154
$this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
@@ -62,54 +75,79 @@ protected function setUp()
6275
->disableOriginalConstructor()
6376
->getMock();
6477

78+
$this->escaperMock = $this->getMockBuilder(
79+
\Magento\Framework\Escaper::class
80+
)
81+
->disableOriginalConstructor()
82+
->setMethods(['escapeHtml'])
83+
->getMock();
84+
6585
$helper = new ObjectManager($this);
6686
$this->model = $helper->getObject(
6787
\Magento\Catalog\Model\Config\CatalogClone\Media\Image::class,
6888
[
6989
'eavConfig' => $this->eavConfig,
70-
'attributeCollectionFactory' => $this->attributeCollectionFactory
90+
'attributeCollectionFactory' => $this->attributeCollectionFactory,
91+
'escaper' => $this->escaperMock,
7192
]
7293
);
7394
}
7495

75-
public function testGetPrefixes()
96+
/**
97+
* @param string $actualLabel
98+
* @param string $expectedLabel
99+
* @return void
100+
*
101+
* @dataProvider getPrefixesDataProvider
102+
*/
103+
public function testGetPrefixes(string $actualLabel, string $expectedLabel): void
76104
{
77105
$entityTypeId = 3;
78106
/** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $entityType */
79107
$entityType = $this->getMockBuilder(\Magento\Eav\Model\Entity\Type::class)
80108
->disableOriginalConstructor()
81109
->getMock();
82-
$entityType->expects($this->once())->method('getId')->will($this->returnValue($entityTypeId));
110+
$entityType->expects($this->once())->method('getId')->willReturn($entityTypeId);
83111

84112
/** @var AbstractFrontend|\PHPUnit_Framework_MockObject_MockObject $frontend */
85113
$frontend = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class)
86114
->setMethods(['getLabel'])
87115
->disableOriginalConstructor()
88116
->getMockForAbstractClass();
89-
$frontend->expects($this->once())->method('getLabel')->will($this->returnValue('testLabel'));
117+
$frontend->expects($this->once())->method('getLabel')->willReturn($actualLabel);
90118

91-
$this->attributeCollection->expects($this->once())->method('setEntityTypeFilter')->with(
92-
$this->equalTo($entityTypeId)
93-
);
94-
$this->attributeCollection->expects($this->once())->method('setFrontendInputTypeFilter')->with(
95-
$this->equalTo('media_image')
96-
);
119+
$this->attributeCollection->expects($this->once())->method('setEntityTypeFilter')->with($entityTypeId);
120+
$this->attributeCollection->expects($this->once())->method('setFrontendInputTypeFilter')->with('media_image');
97121

98-
$this->attribute->expects($this->once())->method('getAttributeCode')->will(
99-
$this->returnValue('attributeCode')
100-
);
101-
$this->attribute->expects($this->once())->method('getFrontend')->will(
102-
$this->returnValue($frontend)
103-
);
122+
$this->attribute->expects($this->once())->method('getAttributeCode')->willReturn('attributeCode');
123+
$this->attribute->expects($this->once())->method('getFrontend')->willReturn($frontend);
104124

105-
$this->attributeCollection->expects($this->any())->method('getIterator')->will(
106-
$this->returnValue(new \ArrayIterator([$this->attribute]))
107-
);
125+
$this->attributeCollection->expects($this->any())->method('getIterator')
126+
->willReturn(new \ArrayIterator([$this->attribute]));
127+
128+
$this->eavConfig->expects($this->any())->method('getEntityType')->with(Product::ENTITY)
129+
->willReturn($entityType);
108130

109-
$this->eavConfig->expects($this->any())->method('getEntityType')->with(
110-
$this->equalTo(Product::ENTITY)
111-
)->will($this->returnValue($entityType));
131+
$this->escaperMock->expects($this->once())->method('escapeHtml')->with($actualLabel)
132+
->willReturn($expectedLabel);
112133

113-
$this->assertEquals([['field' => 'attributeCode_', 'label' => 'testLabel']], $this->model->getPrefixes());
134+
$this->assertEquals([['field' => 'attributeCode_', 'label' => $expectedLabel]], $this->model->getPrefixes());
135+
}
136+
137+
/**
138+
* @return array
139+
*/
140+
public function getPrefixesDataProvider(): array
141+
{
142+
return [
143+
[
144+
'actual_label' => 'testLabel',
145+
'expected_label' => 'testLabel',
146+
],
147+
[
148+
'actual_label' => '<media-image-attributelabel',
149+
'expected_label' => '&lt;media-image-attributelabel',
150+
],
151+
];
114152
}
115153
}

app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,18 @@ public function __construct(
6767
}
6868

6969
/**
70-
* {@inheritdoc}
70+
* @inheritdoc
7171
*/
7272
public function getConfig()
7373
{
7474
$agreements = [];
7575
$agreements['checkoutAgreements'] = $this->getAgreementsConfig();
76+
7677
return $agreements;
7778
}
7879

7980
/**
80-
* Returns agreements config
81+
* Returns agreements config.
8182
*
8283
* @return array
8384
*/
@@ -99,7 +100,7 @@ protected function getAgreementsConfig()
99100
'content' => $agreement->getIsHtml()
100101
? $agreement->getContent()
101102
: nl2br($this->escaper->escapeHtml($agreement->getContent())),
102-
'checkboxText' => $agreement->getCheckboxText(),
103+
'checkboxText' => $this->escaper->escapeHtml($agreement->getCheckboxText()),
103104
'mode' => $agreement->getMode(),
104105
'agreementId' => $agreement->getAgreementId()
105106
];

0 commit comments

Comments
 (0)