Skip to content

Commit 5d4b906

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MAGETWO-91751' into EPAM-PR-18
2 parents a074a54 + 8f8fc8d commit 5d4b906

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

app/code/Magento/Widget/Model/Widget.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public function __construct(
8484
}
8585

8686
/**
87+
* Get math random
88+
*
8789
* @return \Magento\Framework\Math\Random
8890
*
8991
* @deprecated 100.1.0
@@ -315,7 +317,7 @@ public function getWidgetDeclaration($type, $params = [], $asIs = true)
315317
}
316318
}
317319
if (isset($value)) {
318-
$directive .= sprintf(' %s="%s"', $name, $this->escaper->escapeQuote($value));
320+
$directive .= sprintf(' %s="%s"', $name, $this->escaper->escapeHtmlAttr($value, false));
319321
}
320322
}
321323

@@ -339,6 +341,8 @@ public function getWidgetDeclaration($type, $params = [], $asIs = true)
339341
}
340342

341343
/**
344+
* Get widget page varname
345+
*
342346
* @param array $params
343347
* @return string
344348
* @throws \Magento\Framework\Exception\LocalizedException

app/code/Magento/Widget/Test/Unit/Model/WidgetTest.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class WidgetTest extends \PHPUnit\Framework\TestCase
3232
*/
3333
private $conditionsHelper;
3434

35+
/**
36+
* @inheritdoc
37+
*/
3538
protected function setUp()
3639
{
3740
$this->dataStorageMock = $this->getMockBuilder(\Magento\Widget\Model\Config\Data::class)
@@ -55,6 +58,9 @@ protected function setUp()
5558
);
5659
}
5760

61+
/**
62+
* Unit test for getWidget
63+
*/
5864
public function testGetWidgets()
5965
{
6066
$expected = ['val1', 'val2'];
@@ -65,6 +71,9 @@ public function testGetWidgets()
6571
$this->assertEquals($expected, $result);
6672
}
6773

74+
/**
75+
* Unit test for getWidgetsWithFilter
76+
*/
6877
public function testGetWidgetsWithFilter()
6978
{
7079
$configFile = __DIR__ . '/_files/mappedConfigArrayAll.php';
@@ -78,6 +87,9 @@ public function testGetWidgetsWithFilter()
7887
$this->assertEquals($expected, $result);
7988
}
8089

90+
/**
91+
* Unit test for getWidgetsWithUnknownFilter
92+
*/
8193
public function testGetWidgetsWithUnknownFilter()
8294
{
8395
$configFile = __DIR__ . '/_files/mappedConfigArrayAll.php';
@@ -90,6 +102,9 @@ public function testGetWidgetsWithUnknownFilter()
90102
$this->assertEquals($expected, $result);
91103
}
92104

105+
/**
106+
* Unit test for getWidgetByClassType
107+
*/
93108
public function testGetWidgetByClassType()
94109
{
95110
$widgetOne = ['@' => ['type' => 'type1']];
@@ -101,6 +116,9 @@ public function testGetWidgetByClassType()
101116
$this->assertNull($this->widget->getWidgetByClassType('type2'));
102117
}
103118

119+
/**
120+
* Unit test for getConfigAsObject
121+
*/
104122
public function testGetConfigAsObject()
105123
{
106124
$configFile = __DIR__ . '/_files/mappedConfigArrayAll.php';
@@ -135,6 +153,9 @@ public function testGetConfigAsObject()
135153
$this->assertSame($supportedContainersExpected, $resultObject->getSupportedContainers());
136154
}
137155

156+
/**
157+
* Unit test for getConfigAsObjectWidgetNoFound
158+
*/
138159
public function testGetConfigAsObjectWidgetNoFound()
139160
{
140161
$this->dataStorageMock->expects($this->once())
@@ -146,6 +167,9 @@ public function testGetConfigAsObjectWidgetNoFound()
146167
$this->assertSame([], $resultObject->getData());
147168
}
148169

170+
/**
171+
* Unit test for getWidgetDeclaration
172+
*/
149173
public function testGetWidgetDeclaration()
150174
{
151175
$mathRandomMock = $this->createPartialMock(\Magento\Framework\Math\Random::class, ['getRandomString']);
@@ -175,7 +199,7 @@ public function testGetWidgetDeclaration()
175199
$this->conditionsHelper->expects($this->once())->method('encode')->with($conditions)
176200
->willReturn('encoded-conditions-string');
177201
$this->escaperMock->expects($this->atLeastOnce())
178-
->method('escapeQuote')
202+
->method('escapeHtmlAttr')
179203
->willReturnMap([
180204
['my "widget"', false, 'my "widget"'],
181205
['1', false, '1'],
@@ -203,6 +227,9 @@ public function testGetWidgetDeclaration()
203227
$this->assertContains('type_name=""}}', $result);
204228
}
205229

230+
/**
231+
* Unit test for getWidgetDeclarationWithZeroValueParam
232+
*/
206233
public function testGetWidgetDeclarationWithZeroValueParam()
207234
{
208235
$mathRandomMock = $this->createPartialMock(\Magento\Framework\Math\Random::class, ['getRandomString']);

0 commit comments

Comments
 (0)