1414use Magento \Framework \App \Config \ScopeConfigInterface ;
1515use Magento \Framework \Event ;
1616use Magento \Framework \Event \Observer ;
17- use Magento \Framework \ObjectManagerInterface ;
18- use Magento \Store \Api \StoreWebsiteRelationInterface ;
17+ use Magento \Store \Model \StoreResolver \GetStoresListByWebsiteIds ;
1918use Magento \UrlRewrite \Model \UrlPersistInterface ;
2019use PHPUnit \Framework \MockObject \MockObject ;
2120use PHPUnit \Framework \TestCase ;
@@ -46,21 +45,11 @@ class ProductProcessUrlRewriteSavingObserverTest extends TestCase
4645 */
4746 protected $ product ;
4847
49- /**
50- * @var ObjectManagerInterface
51- */
52- protected $ objectManager ;
53-
5448 /**
5549 * @var ProductProcessUrlRewriteSavingObserver
5650 */
5751 protected $ model ;
5852
59- /**
60- * @var StoreWebsiteRelationInterface|MockObject
61- */
62- private $ storeRelation ;
63-
6453 /**
6554 * @var AppendUrlRewritesToProducts|MockObject
6655 */
@@ -100,10 +89,6 @@ protected function setUp(): void
10089 $ this ->event ->expects ($ this ->any ())->method ('getProduct ' )->willReturn ($ this ->product );
10190 $ this ->observer = $ this ->createPartialMock (Observer::class, ['getEvent ' ]);
10291 $ this ->observer ->expects ($ this ->any ())->method ('getEvent ' )->willReturn ($ this ->event );
103- $ this ->storeRelation = $ this ->getMockBuilder (StoreWebsiteRelationInterface::class)
104- ->onlyMethods (['getStoreByWebsiteId ' ])
105- ->disableOriginalConstructor ()
106- ->getMock ();
10792
10893 $ this ->scopeConfig = $ this ->getMockBuilder (ScopeConfigInterface::class)
10994 ->onlyMethods (['isSetFlag ' ])
@@ -115,11 +100,16 @@ protected function setUp(): void
115100 ->disableOriginalConstructor ()
116101 ->getMock ();
117102
103+ $ getStoresList = $ this ->getMockBuilder (GetStoresListByWebsiteIds::class)
104+ ->onlyMethods (['execute ' ])
105+ ->disableOriginalConstructor ()
106+ ->getMock ();
107+
118108 $ this ->model = new ProductProcessUrlRewriteSavingObserver (
119109 $ this ->urlPersist ,
120- $ this ->storeRelation ,
121110 $ this ->appendRewrites ,
122- $ this ->scopeConfig
111+ $ this ->scopeConfig ,
112+ $ getStoresList
123113 );
124114 }
125115
@@ -228,10 +218,6 @@ public function testExecuteUrlKey(
228218 ->method ('getIsChangedCategories ' )
229219 ->willReturn ($ isChangedCategories );
230220
231- $ this ->storeRelation ->expects ($ this ->any ())
232- ->method ('getStoreByWebsiteId ' )
233- ->willReturn ([3 ]);
234-
235221 $ this ->product ->expects ($ this ->any ())->method ('getWebsiteIds ' )->will (
236222 $ this ->returnValue ($ websitesWithProduct )
237223 );
0 commit comments