@@ -38,6 +38,11 @@ class GroupRepositoryTest extends \PHPUnit\Framework\TestCase
3838 */
3939 protected $ group ;
4040
41+ /**
42+ * @var \Magento\Customer\Api\Data\GroupInterface|\PHPUnit_Framework_MockObject_MockObject
43+ */
44+ protected $ factoryCreatedGroup ;
45+
4146 /**
4247 * @var \Magento\Customer\Model\ResourceModel\Group|\PHPUnit_Framework_MockObject_MockObject
4348 */
@@ -153,6 +158,12 @@ private function setupGroupObjects()
153158 'group ' ,
154159 false
155160 );
161+ $ this ->factoryCreatedGroup = $ this ->getMockForAbstractClass (
162+ \Magento \Customer \Api \Data \GroupInterface::class,
163+ [],
164+ 'group ' ,
165+ false
166+ );
156167
157168 $ this ->groupResourceModel = $ this ->createMock (\Magento \Customer \Model \ResourceModel \Group::class);
158169 }
@@ -162,16 +173,22 @@ public function testSave()
162173 $ groupId = 0 ;
163174
164175 $ taxClass = $ this ->getMockForAbstractClass (\Magento \Tax \Api \Data \TaxClassInterface::class, [], '' , false );
176+ $ extensionAttributes = $ this ->getMockForAbstractClass (
177+ \Magento \Customer \Api \Data \GroupExtensionInterface::class
178+ );
165179
166- $ this ->group ->expects ($ this ->once ())
180+ $ this ->group ->expects ($ this ->atLeastOnce ())
167181 ->method ('getCode ' )
168182 ->willReturn ('Code ' );
169183 $ this ->group ->expects ($ this ->atLeastOnce ())
170184 ->method ('getId ' )
171185 ->willReturn ($ groupId );
172- $ this ->group ->expects ($ this ->once ())
186+ $ this ->group ->expects ($ this ->atLeastOnce ())
173187 ->method ('getTaxClassId ' )
174188 ->willReturn (17 );
189+ $ this ->group ->expects ($ this ->atLeastOnce ())
190+ ->method ('getExtensionAttributes ' )
191+ ->willReturn ($ extensionAttributes );
175192
176193 $ this ->groupModel ->expects ($ this ->atLeastOnce ())
177194 ->method ('getId ' )
@@ -185,22 +202,33 @@ public function testSave()
185202 $ this ->groupModel ->expects ($ this ->atLeastOnce ())
186203 ->method ('getTaxClassName ' )
187204 ->willReturn ('Tax class name ' );
188- $ this ->group ->expects ($ this ->once ())
205+
206+ $ this ->factoryCreatedGroup ->expects ($ this ->once ())
189207 ->method ('setId ' )
190208 ->with ($ groupId )
191209 ->willReturnSelf ();
192- $ this ->group ->expects ($ this ->once ())
210+ $ this ->factoryCreatedGroup ->expects ($ this ->once ())
193211 ->method ('setCode ' )
194212 ->with ('Code ' )
195213 ->willReturnSelf ();
196- $ this ->group ->expects ($ this ->once ())
214+ $ this ->factoryCreatedGroup ->expects ($ this ->once ())
197215 ->method ('setTaxClassId ' )
198216 ->with (234 )
199217 ->willReturnSelf ();
200- $ this ->group ->expects ($ this ->once ())
218+ $ this ->factoryCreatedGroup ->expects ($ this ->once ())
201219 ->method ('setTaxClassName ' )
202220 ->with ('Tax class name ' )
203221 ->willReturnSelf ();
222+ $ this ->factoryCreatedGroup ->expects ($ this ->once ())
223+ ->method ('setExtensionAttributes ' )
224+ ->with ($ extensionAttributes )
225+ ->willReturnSelf ();
226+ $ this ->factoryCreatedGroup ->expects ($ this ->atLeastOnce ())
227+ ->method ('getCode ' )
228+ ->willReturn ('Code ' );
229+ $ this ->factoryCreatedGroup ->expects ($ this ->atLeastOnce ())
230+ ->method ('getTaxClassId ' )
231+ ->willReturn (17 );
204232
205233 $ this ->taxClassRepository ->expects ($ this ->once ())
206234 ->method ('get ' )
@@ -229,9 +257,12 @@ public function testSave()
229257 ->with ($ groupId );
230258 $ this ->groupDataFactory ->expects ($ this ->once ())
231259 ->method ('create ' )
232- ->willReturn ($ this ->group );
260+ ->willReturn ($ this ->factoryCreatedGroup );
261+
262+ $ updatedGroup = $ this ->model ->save ($ this ->group );
233263
234- $ this ->assertSame ($ this ->group , $ this ->model ->save ($ this ->group ));
264+ $ this ->assertSame ($ this ->group ->getCode (), $ updatedGroup ->getCode ());
265+ $ this ->assertSame ($ this ->group ->getTaxClassId (), $ updatedGroup ->getTaxClassId ());
235266 }
236267
237268 /**
0 commit comments