@@ -149,16 +149,19 @@ public function testAddChild()
149
149
->disableOriginalConstructor ()
150
150
->setMethods (['getId ' , 'getData ' ])
151
151
->getMock ();
152
-
153
152
$ extensionAttributesMock = $ this ->getMockBuilder (\Magento \Catalog \Api \Data \ProductExtension::class)
154
153
->disableOriginalConstructor ()
155
- ->setMethods ([
156
- 'getConfigurableProductOptions ' , 'setConfigurableProductOptions ' , 'setConfigurableProductLinks '
157
- ])
154
+ ->setMethods (
155
+ [
156
+ 'getConfigurableProductOptions ' ,
157
+ 'setConfigurableProductOptions ' ,
158
+ 'setConfigurableProductLinks '
159
+ ]
160
+ )
158
161
->getMock ();
159
162
$ optionMock = $ this ->getMockBuilder (\Magento \ConfigurableProduct \Api \Data \Option::class)
160
163
->disableOriginalConstructor ()
161
- ->setMethods (['getProductAttribute ' , 'getAttributeId ' ])
164
+ ->setMethods (['getProductAttribute ' , 'getPosition ' , ' getAttributeId ' ])
162
165
->getMock ();
163
166
$ productAttributeMock = $ this ->getMockBuilder (\Magento \Eav \Model \Entity \Attribute \AbstractAttribute::class)
164
167
->disableOriginalConstructor ()
@@ -189,7 +192,6 @@ public function testAddChild()
189
192
->disableOriginalConstructor ()
190
193
->setMethods (['getValue ' , 'getLabel ' ])
191
194
->getMock ();
192
-
193
195
$ attributeCollectionMock = $ this ->getMockBuilder (
194
196
\Magento \ConfigurableProduct \Model \ResourceModel \Product \Type \Configurable \Attribute \Collection::class
195
197
)
@@ -216,20 +218,18 @@ public function testAddChild()
216
218
$ productAttributeMock ->expects ($ this ->any ())->method ('getAttributeCode ' )->willReturn ('color ' );
217
219
$ simple ->expects ($ this ->any ())->method ('getData ' )->willReturn ('color ' );
218
220
$ optionMock ->expects ($ this ->any ())->method ('getAttributeId ' )->willReturn ('1 ' );
221
+ $ optionMock ->expects ($ this ->any ())->method ('getPosition ' )->willReturn ('0 ' );
219
222
220
223
$ optionsFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturn ([$ optionMock ]);
221
224
$ attributeFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturn ($ attributeMock );
222
225
$ attributeMock ->expects ($ this ->any ())->method ('getCollection ' )->willReturn ($ attributeCollectionMock );
223
226
$ attributeCollectionMock ->expects ($ this ->any ())->method ('addFieldToFilter ' )->willReturnSelf ();
224
227
$ attributeCollectionMock ->expects ($ this ->any ())->method ('getItems ' )->willReturn ([$ attributeMock ]);
225
-
228
+ $ attributeMock -> expects ( $ this -> any ())-> method ( ' getId ' )-> willReturn ( 1 );
226
229
$ attributeMock ->expects ($ this ->any ())->method ('getOptions ' )->willReturn ([$ attributeOptionMock ]);
227
-
228
230
$ extensionAttributesMock ->expects ($ this ->any ())->method ('setConfigurableProductOptions ' );
229
231
$ extensionAttributesMock ->expects ($ this ->any ())->method ('setConfigurableProductLinks ' );
230
-
231
232
$ this ->productRepository ->expects ($ this ->once ())->method ('save ' );
232
-
233
233
$ this ->assertTrue (true , $ this ->object ->addChild ($ productSku , $ childSku ));
234
234
}
235
235
0 commit comments