@@ -88,9 +88,6 @@ protected function setUp(): void
88
88
->disableOriginalConstructor ()
89
89
->setMethods (['isObjectNew ' , 'dataHasChangedFor ' , 'getStoreIds ' ])
90
90
->getMockForAbstractClass ();
91
- $ this ->abstractModelMock ->expects ($ this ->any ())
92
- ->method ('getStoreIds ' )
93
- ->willReturn ([]);
94
91
$ this ->subjectMock = $ this ->getMockBuilder (Group::class)
95
92
->disableOriginalConstructor ()
96
93
->getMock ();
@@ -138,6 +135,9 @@ public function testAfterSave()
138
135
$ this ->abstractModelMock ->expects ($ this ->once ())
139
136
->method ('isObjectNew ' )
140
137
->willReturn (false );
138
+ $ this ->abstractModelMock ->expects ($ this ->any ())
139
+ ->method ('getStoreIds ' )
140
+ ->willReturn (['1 ' ]);
141
141
$ this ->abstractModelMock ->expects ($ this ->once ())
142
142
->method ('dataHasChangedFor ' )
143
143
->with ('website_id ' )
@@ -179,4 +179,34 @@ public function testAfterSave()
179
179
$ this ->plugin ->afterSave ($ this ->subjectMock , $ this ->subjectMock , $ this ->abstractModelMock )
180
180
);
181
181
}
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
+ }
182
212
}
0 commit comments