Skip to content

Commit f19bdc9

Browse files
Chhandak.BaruaChhandak.Barua
authored andcommitted
ACP2E-1007 Compare list redirect to old store
1 parent f38c2b9 commit f19bdc9

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection;
1818
use Magento\Framework\App\Config\ScopeConfigInterface;
1919
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
20+
use Magento\Store\Model\Website;
2021
use PHPUnit\Framework\MockObject\MockObject;
2122
use PHPUnit\Framework\TestCase;
23+
use Magento\Store\Model\StoreManagerInterface;
2224

2325
class CompareProductsTest extends TestCase
2426
{
@@ -52,6 +54,16 @@ class CompareProductsTest extends TestCase
5254
*/
5355
private $scopeConfigMock;
5456

57+
/**
58+
* @var StoreManagerInterface
59+
*/
60+
private $storeManagerMock;
61+
62+
/**
63+
* @var Website|MockObject
64+
*/
65+
private $websiteMock;
66+
5567
/**
5668
* @var array
5769
*/
@@ -77,6 +89,18 @@ protected function setUp(): void
7789
->disableOriginalConstructor()
7890
->getMockForAbstractClass();
7991

92+
$this->storeManagerMock = $this->getMockBuilder(
93+
StoreManagerInterface::class
94+
)->disableOriginalConstructor()
95+
->getMockForAbstractClass();
96+
97+
$this->websiteMock = $this->getMockBuilder(
98+
Website::class
99+
)->onlyMethods(
100+
['getId',]
101+
)->disableOriginalConstructor()
102+
->getMock();
103+
80104
$this->objectManagerHelper = new ObjectManagerHelper($this);
81105

82106
$this->model = $this->objectManagerHelper->getObject(
@@ -85,7 +109,9 @@ protected function setUp(): void
85109
'helper' => $this->helperMock,
86110
'productUrl' => $this->productUrlMock,
87111
'outputHelper' => $this->outputHelperMock,
88-
'scopeConfig' => $this->scopeConfigMock
112+
'scopeConfig' => $this->scopeConfigMock,
113+
'storeManager' => $this->storeManagerMock
114+
89115
]
90116
);
91117
}
@@ -196,7 +222,8 @@ public function testGetSectionData()
196222
$this->helperMock->expects($this->once())
197223
->method('getListUrl')
198224
->willReturn('http://list.url');
199-
225+
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
226+
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
200227
$this->assertEquals(
201228
[
202229
'count' => $count,
@@ -224,7 +251,8 @@ public function testGetSectionData()
224251
'remove_url' => 'http://remove.url/3',
225252
'productScope' => null
226253
]
227-
]
254+
],
255+
'websiteId' => 1
228256
],
229257
$this->model->getSectionData()
230258
);
@@ -245,12 +273,16 @@ public function testGetSectionDataNoItems()
245273
->method('getListUrl')
246274
->willReturn('http://list.url');
247275

276+
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
277+
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
278+
248279
$this->assertEquals(
249280
[
250281
'count' => $count,
251282
'countCaption' => __('%1 items', $count),
252283
'listUrl' => 'http://list.url',
253-
'items' => []
284+
'items' => [],
285+
'websiteId' => 1
254286
],
255287
$this->model->getSectionData()
256288
);
@@ -264,6 +296,9 @@ public function testGetSectionDataSingleItem()
264296
->method('getItemCount')
265297
->willReturn($count);
266298

299+
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
300+
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
301+
267302
$items = $this->prepareProductsWithCorrespondingMocks(
268303
[
269304
[
@@ -296,7 +331,8 @@ public function testGetSectionDataSingleItem()
296331
'remove_url' => 'http://remove.url/12345',
297332
'productScope' => null
298333
]
299-
]
334+
],
335+
'websiteId' => 1
300336
],
301337
$this->model->getSectionData()
302338
);

0 commit comments

Comments
 (0)