@@ -56,8 +56,8 @@ class AddressTest extends \PHPUnit\Framework\TestCase
56
56
* @var array
57
57
*/
58
58
protected $ _customers = [
59
- [
'id ' =>
1 ,
'email ' =>
'[email protected] ' ,
'website_id ' =>
1 ],
60
- [
'id ' =>
2 ,
'email ' =>
'[email protected] ' ,
'website_id ' =>
2 ],
59
+ [
'entity_id ' =>
1 ,
'email ' =>
'[email protected] ' ,
'website_id ' =>
1 ],
60
+ [
'entity_id ' =>
2 ,
'email ' =>
'[email protected] ' ,
'website_id ' =>
2 ],
61
61
];
62
62
63
63
/**
@@ -233,28 +233,43 @@ protected function _createAttrCollectionMock()
233
233
*/
234
234
protected function _createCustomerStorageMock ()
235
235
{
236
- $ customerStorage = $ this ->createPartialMock (
237
- \Magento \CustomerImportExport \Model \ResourceModel \Import \Customer \Storage::class,
238
- ['load ' ]
239
- );
236
+ $ customerCollection = $ this ->getMockBuilder (\Magento \Customer \Model \ResourceModel \Customer \Collection::class)
237
+ ->disableOriginalConstructor ()
238
+ ->setMethods (['getConnection ' ])
239
+ ->getMock ();
240
+ $ collectionFactory = $ this ->getMockBuilder (\Magento \Customer \Model \ResourceModel \Customer \CollectionFactory::class)
241
+ ->disableOriginalConstructor ()
242
+ ->setMethods (['create ' ])
243
+ ->getMock ();
244
+ $ collectionFactory
245
+ ->expects ($ this ->any ())
246
+ ->method ('create ' )
247
+ ->willReturn ($ customerCollection );
248
+ $ byPagesIteratorFactory = $ this ->getMockBuilder (\Magento \ImportExport \Model \ResourceModel \CollectionByPagesIteratorFactory::class)
249
+ ->disableOriginalConstructor ()
250
+ ->setMethods (['create ' ])
251
+ ->getMock ();
252
+ /** @var \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage|\PHPUnit_Framework_MockObject_MockObject $customerStorage */
253
+ $ customerStorage = $ this ->getMockBuilder (\Magento \CustomerImportExport \Model \ResourceModel \Import \Customer \Storage::class)
254
+ ->setMethods (['load ' ])
255
+ ->setConstructorArgs ([$ collectionFactory , $ byPagesIteratorFactory ])
256
+ ->getMock ();
240
257
$ resourceMock = $ this ->createPartialMock (
241
258
\Magento \Customer \Model \ResourceModel \Customer::class,
242
259
['getIdFieldName ' ]
243
260
);
261
+ $ selectMock = $ this ->createPartialMock (\Magento \Framework \DB \Select::class, ['from ' ]);
262
+ $ selectMock ->expects ($ this ->any ())->method ('from ' )->will ($ this ->returnSelf ());
263
+ /** @var $connectionMock \Magento\Framework\DB\Adapter\AdapterInterface */
264
+ $ connectionMock = $ this ->createPartialMock (
265
+ \Magento \Framework \DB \Adapter \Pdo \Mysql::class,
266
+ ['select ' , 'fetchAll ' ]
267
+ );
268
+ $ connectionMock ->expects ($ this ->any ())->method ('select ' )->will ($ this ->returnValue ($ selectMock ));
269
+ $ customerCollection ->expects ($ this ->any ())->method ('getConnection ' )->will ($ this ->returnValue ($ connectionMock ));
244
270
$ resourceMock ->expects ($ this ->any ())->method ('getIdFieldName ' )->will ($ this ->returnValue ('id ' ));
245
271
foreach ($ this ->_customers as $ customerData ) {
246
- $ data = [
247
- 'resource ' => $ resourceMock ,
248
- 'data ' => $ customerData ,
249
- $ this ->createMock (\Magento \Customer \Model \Config \Share::class),
250
- $ this ->createMock (\Magento \Customer \Model \AddressFactory::class),
251
- $ this ->createMock (\Magento \Customer \Model \ResourceModel \Address \CollectionFactory::class),
252
- $ this ->createMock (\Magento \Customer \Model \GroupFactory::class),
253
- $ this ->createMock (\Magento \Customer \Model \AttributeFactory::class),
254
- ];
255
- /** @var $customer \Magento\Customer\Model\Customer */
256
- $ customer = $ this ->_objectManagerMock ->getObject (\Magento \Customer \Model \Customer::class, $ data );
257
- $ customerStorage ->addCustomer ($ customer );
272
+ $ customerStorage ->addCustomerByArray ($ customerData );
258
273
}
259
274
return $ customerStorage ;
260
275
}
0 commit comments