Skip to content

Commit e45edb3

Browse files
rogerdzglo63652
authored andcommitted
fix unit test
1 parent b041690 commit e45edb3

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
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\Framework\UrlInterface;
21+
use Magento\Store\Model\StoreManagerInterface;
2022
use Magento\Store\Model\Website;
2123
use PHPUnit\Framework\MockObject\MockObject;
2224
use PHPUnit\Framework\TestCase;
23-
use Magento\Store\Model\StoreManagerInterface;
2425

2526
class CompareProductsTest extends TestCase
2627
{
@@ -64,6 +65,11 @@ class CompareProductsTest extends TestCase
6465
*/
6566
private $websiteMock;
6667

68+
/**
69+
* @var UrlInterface|MockObject
70+
*/
71+
private $urlBuilder;
72+
6773
/**
6874
* @var array
6975
*/
@@ -88,6 +94,9 @@ protected function setUp(): void
8894
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
8995
->disableOriginalConstructor()
9096
->getMockForAbstractClass();
97+
$this->urlBuilder = $this->getMockBuilder(UrlInterface::class)
98+
->disableOriginalConstructor()
99+
->getMock();
91100

92101
$this->storeManagerMock = $this->getMockBuilder(
93102
StoreManagerInterface::class
@@ -97,7 +106,7 @@ protected function setUp(): void
97106
$this->websiteMock = $this->getMockBuilder(
98107
Website::class
99108
)->onlyMethods(
100-
['getId',]
109+
['getId']
101110
)->disableOriginalConstructor()
102111
->getMock();
103112

@@ -110,8 +119,8 @@ protected function setUp(): void
110119
'productUrl' => $this->productUrlMock,
111120
'outputHelper' => $this->outputHelperMock,
112121
'scopeConfig' => $this->scopeConfigMock,
113-
'storeManager' => $this->storeManagerMock
114-
122+
'storeManager' => $this->storeManagerMock,
123+
'urlBuilder' => $this->urlBuilder
115124
]
116125
);
117126
}
@@ -219,9 +228,10 @@ public function testGetSectionData()
219228
->method('getItemCollection')
220229
->willReturn($itemCollectionMock);
221230

222-
$this->helperMock->expects($this->once())
223-
->method('getListUrl')
231+
$this->urlBuilder->expects($this->once())
232+
->method('getUrl')
224233
->willReturn('http://list.url');
234+
225235
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
226236
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
227237
$this->assertEquals(
@@ -269,8 +279,8 @@ public function testGetSectionDataNoItems()
269279
$this->helperMock->expects($this->never())
270280
->method('getItemCollection');
271281

272-
$this->helperMock->expects($this->once())
273-
->method('getListUrl')
282+
$this->urlBuilder->expects($this->once())
283+
->method('getUrl')
274284
->willReturn('http://list.url');
275285

276286
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
@@ -314,8 +324,8 @@ public function testGetSectionDataSingleItem()
314324
->method('getItemCollection')
315325
->willReturn($itemCollectionMock);
316326

317-
$this->helperMock->expects($this->once())
318-
->method('getListUrl')
327+
$this->urlBuilder->expects($this->once())
328+
->method('getUrl')
319329
->willReturn('http://list.url');
320330

321331
$this->assertEquals(

0 commit comments

Comments
 (0)