@@ -88,9 +88,6 @@ protected function setUp(): void
8888 ->disableOriginalConstructor ()
8989 ->setMethods (['isObjectNew ' , 'dataHasChangedFor ' , 'getStoreIds ' ])
9090 ->getMockForAbstractClass ();
91- $ this ->abstractModelMock ->expects ($ this ->any ())
92- ->method ('getStoreIds ' )
93- ->willReturn ([]);
9491 $ this ->subjectMock = $ this ->getMockBuilder (Group::class)
9592 ->disableOriginalConstructor ()
9693 ->getMock ();
@@ -138,6 +135,9 @@ public function testAfterSave()
138135 $ this ->abstractModelMock ->expects ($ this ->once ())
139136 ->method ('isObjectNew ' )
140137 ->willReturn (false );
138+ $ this ->abstractModelMock ->expects ($ this ->any ())
139+ ->method ('getStoreIds ' )
140+ ->willReturn (['1 ' ]);
141141 $ this ->abstractModelMock ->expects ($ this ->once ())
142142 ->method ('dataHasChangedFor ' )
143143 ->with ('website_id ' )
@@ -179,4 +179,34 @@ public function testAfterSave()
179179 $ this ->plugin ->afterSave ($ this ->subjectMock , $ this ->subjectMock , $ this ->abstractModelMock )
180180 );
181181 }
182+
183+ public function testAfterSaveWithNoStoresAssigned ()
184+ {
185+ $ this ->abstractModelMock ->expects ($ this ->once ())
186+ ->method ('isObjectNew ' )
187+ ->willReturn (false );
188+ $ this ->abstractModelMock ->expects ($ this ->any ())
189+ ->method ('getStoreIds ' )
190+ ->willReturn ([]);
191+ $ this ->abstractModelMock ->expects ($ this ->any ())
192+ ->method ('dataHasChangedFor ' )
193+ ->with ('website_id ' )
194+ ->willReturn (true );
195+ $ this ->storeManagerMock ->expects ($ this ->never ())->method ('reinitStores ' );
196+ $ this ->categoryMock ->expects ($ this ->never ())->method ('getCategories ' );
197+ $ this ->categoryFactoryMock ->expects ($ this ->never ())->method ('create ' );
198+ $ this ->productFactoryMock ->expects ($ this ->never ())->method ('create ' );
199+ $ this ->productMock ->expects ($ this ->never ())->method ('getCollection ' );
200+ $ this ->productCollectionMock ->expects ($ this ->never ())->method ('addCategoryIds ' );
201+ $ this ->productCollectionMock ->expects ($ this ->never ()) ->method ('addAttributeToSelect ' );
202+ $ this ->productCollectionMock ->expects ($ this ->never ())->method ('addWebsiteFilter ' );
203+ $ iterator = new \ArrayIterator ([$ this ->productMock ]);
204+ $ this ->productCollectionMock ->expects ($ this ->never ())->method ('getIterator ' );
205+ $ this ->productUrlRewriteGeneratorMock ->expects ($ this ->never ())->method ('generate ' );
206+
207+ $ this ->assertSame (
208+ $ this ->subjectMock ,
209+ $ this ->plugin ->afterSave ($ this ->subjectMock , $ this ->subjectMock , $ this ->abstractModelMock )
210+ );
211+ }
182212}
0 commit comments