Skip to content

Commit 258b6bf

Browse files
committed
Merge remote-tracking branch 'origin/MC-22969-only' into borg-2.3.5
2 parents 49a42a4 + de354e1 commit 258b6bf

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

app/code/Magento/Directory/Block/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getCountryHtmlSelect($defValue = null, $name = 'country_id', $id
142142
)->setId(
143143
$id
144144
)->setTitle(
145-
__($title)
145+
$this->escapeHtmlAttr(__($title))
146146
)->setValue(
147147
$defValue
148148
)->setOptions(

app/code/Magento/Directory/Test/Unit/Block/DataTest.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Store\Model\ScopeInterface;
1818
use Magento\Store\Model\Store;
1919
use Magento\Store\Model\StoreManagerInterface;
20+
use Magento\Framework\Escaper;
2021

2122
/**
2223
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -56,9 +57,19 @@ class DataTest extends \PHPUnit\Framework\TestCase
5657
/** @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */
5758
private $serializerMock;
5859

60+
/**
61+
* @var \Magento\Framework\Escaper
62+
*/
63+
private $escaper;
64+
5965
protected function setUp()
6066
{
6167
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
68+
$this->escaper = $this->getMockBuilder(Escaper::class)
69+
->disableOriginalConstructor()
70+
->setMethods(['escapeHtmlAttr'])
71+
->getMock();
72+
6273
$this->prepareContext();
6374

6475
$this->helperDataMock = $this->getMockBuilder(\Magento\Directory\Helper\Data::class)
@@ -123,6 +134,8 @@ protected function prepareContext()
123134
$this->contextMock->expects($this->any())
124135
->method('getLayout')
125136
->willReturn($this->layoutMock);
137+
138+
$this->contextMock->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
126139
}
127140

128141
protected function prepareCountryCollection()
@@ -135,9 +148,11 @@ protected function prepareCountryCollection()
135148
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class
136149
)
137150
->disableOriginalConstructor()
138-
->setMethods([
139-
'create'
140-
])
151+
->setMethods(
152+
[
153+
'create'
154+
]
155+
)
141156
->getMock();
142157

143158
$this->countryCollectionFactoryMock->expects($this->any())
@@ -285,15 +300,17 @@ protected function mockElementHtmlSelect($defaultCountry, $options, $resultHtml)
285300

286301
$elementHtmlSelect = $this->getMockBuilder(\Magento\Framework\View\Element\Html\Select::class)
287302
->disableOriginalConstructor()
288-
->setMethods([
289-
'setName',
290-
'setId',
291-
'setTitle',
292-
'setValue',
293-
'setOptions',
294-
'setExtraParams',
295-
'getHtml',
296-
])
303+
->setMethods(
304+
[
305+
'setName',
306+
'setId',
307+
'setTitle',
308+
'setValue',
309+
'setOptions',
310+
'setExtraParams',
311+
'getHtml'
312+
]
313+
)
297314
->getMock();
298315

299316
$elementHtmlSelect->expects($this->once())
@@ -323,6 +340,10 @@ protected function mockElementHtmlSelect($defaultCountry, $options, $resultHtml)
323340
$elementHtmlSelect->expects($this->once())
324341
->method('getHtml')
325342
->willReturn($resultHtml);
343+
$this->escaper->expects($this->once())
344+
->method('escapeHtmlAttr')
345+
->with(__($title))
346+
->willReturn(__($title));
326347

327348
return $elementHtmlSelect;
328349
}

0 commit comments

Comments
 (0)