Skip to content

Commit 4e7c14a

Browse files
tranthienbinh1989nishant04412
authored andcommitted
AC-14712 improve category view
1 parent ceda589 commit 4e7c14a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/code/Magento/Catalog/Test/Unit/Helper/CategoryTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\Helper\Context;
1515
use Magento\Framework\App\RequestInterface;
1616
use Magento\Framework\Data\CollectionFactory;
17+
use Magento\Framework\Escaper;
1718
use Magento\Store\Model\StoreManagerInterface;
1819
use PHPUnit\Framework\MockObject\MockObject;
1920
use 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

Comments
 (0)