5
5
*/
6
6
namespace Magento \Tax \Test \Unit \Block \Grid \Renderer ;
7
7
8
+ use Magento \Backend \Block \Context ;
8
9
use Magento \Framework \DataObject ;
10
+ use Magento \Framework \Escaper ;
9
11
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
10
12
use Magento \Tax \Block \Grid \Renderer \Codes ;
11
13
@@ -24,7 +26,26 @@ class CodesTest extends \PHPUnit\Framework\TestCase
24
26
protected function setUp ()
25
27
{
26
28
$ objectManager = new ObjectManager ($ this );
27
- $ this ->codes = $ objectManager ->getObject (Codes::class);
29
+ $ escaper = $ this ->getMockBuilder (Escaper::class)
30
+ ->disableOriginalConstructor ()
31
+ ->getMock ();
32
+ $ escaper ->expects ($ this ->any ())
33
+ ->method ('escapeHtml ' )
34
+ ->willReturnCallback (
35
+ function ($ str ) {
36
+ return 'ESCAPED: ' .$ str ;
37
+ }
38
+ );
39
+ $ context = $ this ->getMockBuilder (Context::class)
40
+ ->disableOriginalConstructor ()
41
+ ->getMock ();
42
+ $ context ->expects ($ this ->any ())
43
+ ->method ('getEscaper ' )
44
+ ->willReturn ($ escaper );
45
+ $ this ->codes = $ objectManager ->getObject (
46
+ Codes::class,
47
+ ['context ' => $ context ]
48
+ );
28
49
}
29
50
30
51
/**
@@ -50,10 +71,10 @@ public function testRenderCodes($ratesCodes, $expected)
50
71
public function ratesCodesDataProvider ()
51
72
{
52
73
return [
53
- [['some_code ' ], 'some_code ' ],
54
- [['some_code ' , 'some_code2 ' ], 'some_code, some_code2 ' ],
74
+ [['some_code ' ], 'ESCAPED: some_code ' ],
75
+ [['some_code ' , 'some_code2 ' ], 'ESCAPED: some_code, some_code2 ' ],
55
76
[[], '' ],
56
- [null , '' ]
77
+ [null , '' ],
57
78
];
58
79
}
59
80
}
0 commit comments