6 declare(strict_types=1);
29 private $catalogHelper;
39 private $objectManager;
44 protected function setUp() : void
46 $this->catalogHelper = $this->getMockBuilder(CatalogHelper::class)
47 ->setMethods([
'getProduct'])
48 ->disableOriginalConstructor()
51 $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
52 ->setMethods([
'getValue',
'isSetFlag'])
53 ->disableOriginalConstructor()
54 ->getMockForAbstractClass();
56 $escaper = $this->getObjectManager()->getObject(\
Magento\Framework\Escaper::class);
58 $this->viewModel = $this->getObjectManager()->getObject(
61 'catalogData' => $this->catalogHelper,
62 'scopeConfig' => $this->scopeConfig,
73 $this->scopeConfig->expects($this->once())
76 ->willReturn(
'.html');
78 $this->assertEquals(
'.html', $this->viewModel->getCategoryUrlSuffix());
86 $this->scopeConfig->expects($this->once())
91 $this->assertFalse($this->viewModel->isCategoryUsedInProductUrl());
103 $this->catalogHelper->expects($this->atLeastOnce())
104 ->method(
'getProduct')
107 $this->assertEquals($expectedName, $this->viewModel->getProductName());
116 [$this->getObjectManager()->getObject(Product::class, [
'data' => [
'name' =>
'Test']]),
'Test'],
130 $this->catalogHelper->expects($this->atLeastOnce())
131 ->method(
'getProduct')
134 $this->scopeConfig->expects($this->any())
135 ->method(
'isSetFlag')
139 $this->scopeConfig->expects($this->any())
142 ->willReturn(
'."html');
144 $this->assertEquals($expectedJson, $this->viewModel->getJsonConfiguration());
154 $this->getObjectManager()->getObject(Product::class, [
'data' => [
'name' =>
'Test ™']]),
155 '{"breadcrumbs":{"categoryUrlSuffix":"."html","userCategoryPathInUrl":0,"product":"Test \u2122"}}',
158 $this->getObjectManager()->getObject(Product::class, [
'data' => [
'name' =>
'Test "']]),
159 '{"breadcrumbs":{"categoryUrlSuffix":"."html","userCategoryPathInUrl":0,"product":"Test ""}}',
162 $this->getObjectManager()->getObject(Product::class, [
'data' => [
'name' =>
'Test <b>x</b>']]),
163 '{"breadcrumbs":{"categoryUrlSuffix":"."html","userCategoryPathInUrl":0,"product":' 164 .
'"Test <b>x<\/b>"}}',
167 $this->getObjectManager()->getObject(Product::class, [
'data' => [
'name' =>
'Test \'abc\'']]),
169 .
'{"categoryUrlSuffix":"."html","userCategoryPathInUrl":0,"product":"Test 'abc'"}}' 179 if (
null === $this->objectManager) {
183 return $this->objectManager;
testGetProductName($product, string $expectedName)
testGetJsonConfiguration($product, string $expectedJson)
testGetCategoryUrlSuffix()
testIsCategoryUsedInProductUrl()
productJsonEncodeDataProvider()