14
14
use Magento \Theme \Block \Html \Header ;
15
15
use PHPUnit \Framework \MockObject \MockObject ;
16
16
use PHPUnit \Framework \TestCase ;
17
+ use Magento \Framework \Escaper ;
17
18
18
19
class HeaderTest extends TestCase
19
20
{
@@ -27,6 +28,11 @@ class HeaderTest extends TestCase
27
28
*/
28
29
protected $ scopeConfig ;
29
30
31
+ /**
32
+ * @var Escaper|MockObject
33
+ */
34
+ private $ escaper ;
35
+
30
36
protected function setUp (): void
31
37
{
32
38
$ context = $ this ->getMockBuilder (Context::class)
@@ -38,10 +44,13 @@ protected function setUp(): void
38
44
->disableOriginalConstructor ()
39
45
->getMock ();
40
46
$ context ->expects ($ this ->once ())->method ('getScopeConfig ' )->willReturn ($ this ->scopeConfig );
41
-
47
+ $ this -> escaper = $ this -> createPartialMock (Escaper::class, [ ' escapeQuote ' ]);
42
48
$ this ->unit = (new ObjectManager ($ this ))->getObject (
43
49
Header::class,
44
- ['context ' => $ context ]
50
+ [
51
+ 'context ' => $ context ,
52
+ 'escaper ' => $ this ->escaper
53
+ ]
45
54
);
46
55
}
47
56
@@ -51,6 +60,11 @@ public function testGetWelcomeDefault()
51
60
->with ('design/header/welcome ' , ScopeInterface::SCOPE_STORE )
52
61
->willReturn ('Welcome Message ' );
53
62
63
+ $ this ->escaper ->expects ($ this ->once ())
64
+ ->method ('escapeQuote ' )
65
+ ->with ('Welcome Message ' , true )
66
+ ->willReturn ('Welcome Message ' );
67
+
54
68
$ this ->assertEquals ('Welcome Message ' , $ this ->unit ->getWelcome ());
55
69
}
56
70
}
0 commit comments