1414use Magento \Framework \App \Helper \Context ;
1515use Magento \Framework \App \RequestInterface ;
1616use Magento \Framework \Data \CollectionFactory ;
17+ use Magento \Framework \Escaper ;
1718use Magento \Store \Model \StoreManagerInterface ;
1819use PHPUnit \Framework \MockObject \MockObject ;
1920use PHPUnit \Framework \TestCase ;
@@ -63,6 +64,11 @@ class CategoryTest extends TestCase
6364 */
6465 private $ requestMock ;
6566
67+ /**
68+ * @var Escaper|MockObject
69+ */
70+ private $ escaper ;
71+
6672 protected function setUp (): void
6773 {
6874 $ this ->mockContext ();
@@ -78,12 +84,16 @@ protected function setUp(): void
7884 $ this ->categoryRepository = $ this ->getMockBuilder (CategoryRepositoryInterface::class)
7985 ->disableOriginalConstructor ()
8086 ->getMock ();
87+ $ this ->escaper = $ this ->getMockBuilder (Escaper::class)
88+ ->disableOriginalConstructor ()
89+ ->getMock ();
8190 $ this ->categoryHelper = new Category (
8291 $ this ->context ,
8392 $ this ->categoryFactory ,
8493 $ this ->storeManager ,
8594 $ this ->collectionFactory ,
86- $ this ->categoryRepository
95+ $ this ->categoryRepository ,
96+ $ this ->escaper
8797 );
8898 }
8999
@@ -101,6 +111,9 @@ public function testGetCanonicalUrl(mixed $params, string $categoryUrl, string $
101111 $ this ->requestMock ->expects ($ this ->any ())
102112 ->method ('getParams ' )
103113 ->willReturn ($ params );
114+ $ this ->escaper ->expects ($ this ->any ())
115+ ->method ('escapeUrl ' )
116+ ->willReturn ($ expectedCategoryUrl );
104117 $ actualCategoryUrl = $ this ->categoryHelper ->getCanonicalUrl ($ categoryUrl );
105118 $ this ->assertEquals ($ actualCategoryUrl , $ expectedCategoryUrl );
106119 }
0 commit comments