14
14
use Magento \Framework \App \Config \ScopeConfigInterface ;
15
15
use Magento \Framework \Event ;
16
16
use Magento \Framework \Event \Observer ;
17
- use Magento \Framework \ObjectManagerInterface ;
18
- use Magento \Store \Api \StoreWebsiteRelationInterface ;
17
+ use Magento \Store \Model \StoreResolver \GetStoresListByWebsiteIds ;
19
18
use Magento \UrlRewrite \Model \UrlPersistInterface ;
20
19
use PHPUnit \Framework \MockObject \MockObject ;
21
20
use PHPUnit \Framework \TestCase ;
@@ -46,21 +45,11 @@ class ProductProcessUrlRewriteSavingObserverTest extends TestCase
46
45
*/
47
46
protected $ product ;
48
47
49
- /**
50
- * @var ObjectManagerInterface
51
- */
52
- protected $ objectManager ;
53
-
54
48
/**
55
49
* @var ProductProcessUrlRewriteSavingObserver
56
50
*/
57
51
protected $ model ;
58
52
59
- /**
60
- * @var StoreWebsiteRelationInterface|MockObject
61
- */
62
- private $ storeRelation ;
63
-
64
53
/**
65
54
* @var AppendUrlRewritesToProducts|MockObject
66
55
*/
@@ -100,10 +89,6 @@ protected function setUp(): void
100
89
$ this ->event ->expects ($ this ->any ())->method ('getProduct ' )->willReturn ($ this ->product );
101
90
$ this ->observer = $ this ->createPartialMock (Observer::class, ['getEvent ' ]);
102
91
$ this ->observer ->expects ($ this ->any ())->method ('getEvent ' )->willReturn ($ this ->event );
103
- $ this ->storeRelation = $ this ->getMockBuilder (StoreWebsiteRelationInterface::class)
104
- ->onlyMethods (['getStoreByWebsiteId ' ])
105
- ->disableOriginalConstructor ()
106
- ->getMock ();
107
92
108
93
$ this ->scopeConfig = $ this ->getMockBuilder (ScopeConfigInterface::class)
109
94
->onlyMethods (['isSetFlag ' ])
@@ -115,11 +100,16 @@ protected function setUp(): void
115
100
->disableOriginalConstructor ()
116
101
->getMock ();
117
102
103
+ $ getStoresList = $ this ->getMockBuilder (GetStoresListByWebsiteIds::class)
104
+ ->onlyMethods (['execute ' ])
105
+ ->disableOriginalConstructor ()
106
+ ->getMock ();
107
+
118
108
$ this ->model = new ProductProcessUrlRewriteSavingObserver (
119
109
$ this ->urlPersist ,
120
- $ this ->storeRelation ,
121
110
$ this ->appendRewrites ,
122
- $ this ->scopeConfig
111
+ $ this ->scopeConfig ,
112
+ $ getStoresList
123
113
);
124
114
}
125
115
@@ -228,10 +218,6 @@ public function testExecuteUrlKey(
228
218
->method ('getIsChangedCategories ' )
229
219
->willReturn ($ isChangedCategories );
230
220
231
- $ this ->storeRelation ->expects ($ this ->any ())
232
- ->method ('getStoreByWebsiteId ' )
233
- ->willReturn ([3 ]);
234
-
235
221
$ this ->product ->expects ($ this ->any ())->method ('getWebsiteIds ' )->will (
236
222
$ this ->returnValue ($ websitesWithProduct )
237
223
);
0 commit comments