17
17
use Magento \Catalog \Model \ResourceModel \Product \Compare \Item \Collection ;
18
18
use Magento \Framework \App \Config \ScopeConfigInterface ;
19
19
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
20
+ use Magento \Framework \UrlInterface ;
21
+ use Magento \Store \Model \StoreManagerInterface ;
20
22
use Magento \Store \Model \Website ;
21
23
use PHPUnit \Framework \MockObject \MockObject ;
22
24
use PHPUnit \Framework \TestCase ;
23
- use Magento \Store \Model \StoreManagerInterface ;
24
25
25
26
class CompareProductsTest extends TestCase
26
27
{
@@ -64,6 +65,11 @@ class CompareProductsTest extends TestCase
64
65
*/
65
66
private $ websiteMock ;
66
67
68
+ /**
69
+ * @var UrlInterface|MockObject
70
+ */
71
+ private $ urlBuilder ;
72
+
67
73
/**
68
74
* @var array
69
75
*/
@@ -88,6 +94,9 @@ protected function setUp(): void
88
94
$ this ->scopeConfigMock = $ this ->getMockBuilder (ScopeConfigInterface::class)
89
95
->disableOriginalConstructor ()
90
96
->getMockForAbstractClass ();
97
+ $ this ->urlBuilder = $ this ->getMockBuilder (UrlInterface::class)
98
+ ->disableOriginalConstructor ()
99
+ ->getMock ();
91
100
92
101
$ this ->storeManagerMock = $ this ->getMockBuilder (
93
102
StoreManagerInterface::class
@@ -97,7 +106,7 @@ protected function setUp(): void
97
106
$ this ->websiteMock = $ this ->getMockBuilder (
98
107
Website::class
99
108
)->onlyMethods (
100
- ['getId ' , ]
109
+ ['getId ' ]
101
110
)->disableOriginalConstructor ()
102
111
->getMock ();
103
112
@@ -110,8 +119,8 @@ protected function setUp(): void
110
119
'productUrl ' => $ this ->productUrlMock ,
111
120
'outputHelper ' => $ this ->outputHelperMock ,
112
121
'scopeConfig ' => $ this ->scopeConfigMock ,
113
- 'storeManager ' => $ this ->storeManagerMock
114
-
122
+ 'storeManager ' => $ this ->storeManagerMock ,
123
+ ' urlBuilder ' => $ this -> urlBuilder
115
124
]
116
125
);
117
126
}
@@ -219,9 +228,10 @@ public function testGetSectionData()
219
228
->method ('getItemCollection ' )
220
229
->willReturn ($ itemCollectionMock );
221
230
222
- $ this ->helperMock ->expects ($ this ->once ())
223
- ->method ('getListUrl ' )
231
+ $ this ->urlBuilder ->expects ($ this ->once ())
232
+ ->method ('getUrl ' )
224
233
->willReturn ('http://list.url ' );
234
+
225
235
$ this ->storeManagerMock ->expects ($ this ->any ())->method ('getWebsite ' )->willReturn ($ this ->websiteMock );
226
236
$ this ->websiteMock ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
227
237
$ this ->assertEquals (
@@ -269,8 +279,8 @@ public function testGetSectionDataNoItems()
269
279
$ this ->helperMock ->expects ($ this ->never ())
270
280
->method ('getItemCollection ' );
271
281
272
- $ this ->helperMock ->expects ($ this ->once ())
273
- ->method ('getListUrl ' )
282
+ $ this ->urlBuilder ->expects ($ this ->once ())
283
+ ->method ('getUrl ' )
274
284
->willReturn ('http://list.url ' );
275
285
276
286
$ this ->storeManagerMock ->expects ($ this ->any ())->method ('getWebsite ' )->willReturn ($ this ->websiteMock );
@@ -314,8 +324,8 @@ public function testGetSectionDataSingleItem()
314
324
->method ('getItemCollection ' )
315
325
->willReturn ($ itemCollectionMock );
316
326
317
- $ this ->helperMock ->expects ($ this ->once ())
318
- ->method ('getListUrl ' )
327
+ $ this ->urlBuilder ->expects ($ this ->once ())
328
+ ->method ('getUrl ' )
319
329
->willReturn ('http://list.url ' );
320
330
321
331
$ this ->assertEquals (
0 commit comments