14
14
use Magento \Framework \App \Helper \Context ;
15
15
use Magento \Framework \App \RequestInterface ;
16
16
use Magento \Framework \Data \CollectionFactory ;
17
+ use Magento \Framework \Escaper ;
17
18
use Magento \Store \Model \StoreManagerInterface ;
18
19
use PHPUnit \Framework \MockObject \MockObject ;
19
20
use PHPUnit \Framework \TestCase ;
@@ -63,6 +64,11 @@ class CategoryTest extends TestCase
63
64
*/
64
65
private $ requestMock ;
65
66
67
+ /**
68
+ * @var Escaper|MockObject
69
+ */
70
+ private $ escaper ;
71
+
66
72
protected function setUp (): void
67
73
{
68
74
$ this ->mockContext ();
@@ -78,12 +84,16 @@ protected function setUp(): void
78
84
$ this ->categoryRepository = $ this ->getMockBuilder (CategoryRepositoryInterface::class)
79
85
->disableOriginalConstructor ()
80
86
->getMock ();
87
+ $ this ->escaper = $ this ->getMockBuilder (Escaper::class)
88
+ ->disableOriginalConstructor ()
89
+ ->getMock ();
81
90
$ this ->categoryHelper = new Category (
82
91
$ this ->context ,
83
92
$ this ->categoryFactory ,
84
93
$ this ->storeManager ,
85
94
$ this ->collectionFactory ,
86
- $ this ->categoryRepository
95
+ $ this ->categoryRepository ,
96
+ $ this ->escaper
87
97
);
88
98
}
89
99
@@ -101,6 +111,9 @@ public function testGetCanonicalUrl(mixed $params, string $categoryUrl, string $
101
111
$ this ->requestMock ->expects ($ this ->any ())
102
112
->method ('getParams ' )
103
113
->willReturn ($ params );
114
+ $ this ->escaper ->expects ($ this ->any ())
115
+ ->method ('escapeUrl ' )
116
+ ->willReturn ($ expectedCategoryUrl );
104
117
$ actualCategoryUrl = $ this ->categoryHelper ->getCanonicalUrl ($ categoryUrl );
105
118
$ this ->assertEquals ($ actualCategoryUrl , $ expectedCategoryUrl );
106
119
}
0 commit comments