Skip to content

Commit 42f1414

Browse files
35481:Modified the implementation and automation test case
1 parent 6468283 commit 42f1414

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/code/Magento/Theme/Test/Unit/Block/Html/HeaderTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Theme\Block\Html\Header;
1515
use PHPUnit\Framework\MockObject\MockObject;
1616
use PHPUnit\Framework\TestCase;
17+
use Magento\Framework\Escaper;
1718

1819
class HeaderTest extends TestCase
1920
{
@@ -27,6 +28,11 @@ class HeaderTest extends TestCase
2728
*/
2829
protected $scopeConfig;
2930

31+
/**
32+
* @var Escaper|MockObject
33+
*/
34+
private $escaper;
35+
3036
protected function setUp(): void
3137
{
3238
$context = $this->getMockBuilder(Context::class)
@@ -38,10 +44,13 @@ protected function setUp(): void
3844
->disableOriginalConstructor()
3945
->getMock();
4046
$context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig);
41-
47+
$this->escaper = $this->createPartialMock(Escaper::class, ['escapeQuote']);
4248
$this->unit = (new ObjectManager($this))->getObject(
4349
Header::class,
44-
['context' => $context]
50+
[
51+
'context' => $context,
52+
'escaper' => $this->escaper
53+
]
4554
);
4655
}
4756

@@ -51,6 +60,11 @@ public function testGetWelcomeDefault()
5160
->with('design/header/welcome', ScopeInterface::SCOPE_STORE)
5261
->willReturn('Welcome Message');
5362

63+
$this->escaper->expects($this->once())
64+
->method('escapeQuote')
65+
->with('Welcome Message', true)
66+
->willReturn('Welcome Message');
67+
5468
$this->assertEquals('Welcome Message', $this->unit->getWelcome());
5569
}
5670
}

0 commit comments

Comments
 (0)