@@ -233,41 +233,52 @@ protected function _createAttrCollectionMock()
233
233
*/
234
234
protected function _createCustomerStorageMock ()
235
235
{
236
+ /** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject $selectMock */
237
+ $ selectMock = $ this ->getMockBuilder (\Magento \Framework \DB \Select::class)
238
+ ->disableOriginalConstructor ()
239
+ ->setMethods (['from ' ])
240
+ ->getMock ();
241
+ $ selectMock ->expects ($ this ->any ())->method ('from ' )->will ($ this ->returnSelf ());
242
+
243
+ /** @var $connectionMock \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */
244
+ $ connectionMock = $ this ->getMockBuilder (\Magento \Framework \DB \Adapter \Pdo \Mysql::class)
245
+ ->disableOriginalConstructor ()
246
+ ->setMethods (['select ' , 'fetchAll ' ])
247
+ ->getMock ();
248
+ $ connectionMock ->expects ($ this ->any ())
249
+ ->method ('select ' )
250
+ ->will ($ this ->returnValue ($ selectMock ));
251
+
252
+ /** @var \Magento\Customer\Model\ResourceModel\Customer\Collection|\PHPUnit_Framework_MockObject_MockObject $customerCollection */
236
253
$ customerCollection = $ this ->getMockBuilder (\Magento \Customer \Model \ResourceModel \Customer \Collection::class)
237
254
->disableOriginalConstructor ()
238
255
->setMethods (['getConnection ' ])
239
256
->getMock ();
257
+ $ customerCollection ->expects ($ this ->any ())
258
+ ->method ('getConnection ' )
259
+ ->will ($ this ->returnValue ($ connectionMock ));
260
+
261
+ /** @var \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject $collectionFactory */
240
262
$ collectionFactory = $ this ->getMockBuilder (\Magento \Customer \Model \ResourceModel \Customer \CollectionFactory::class)
241
263
->disableOriginalConstructor ()
242
264
->setMethods (['create ' ])
243
265
->getMock ();
244
- $ collectionFactory
245
- ->expects ($ this ->any ())
266
+ $ collectionFactory ->expects ($ this ->any ())
246
267
->method ('create ' )
247
268
->willReturn ($ customerCollection );
269
+
270
+ /** @var \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory|\PHPUnit_Framework_MockObject_MockObject $byPagesIteratorFactory */
248
271
$ byPagesIteratorFactory = $ this ->getMockBuilder (\Magento \ImportExport \Model \ResourceModel \CollectionByPagesIteratorFactory::class)
249
272
->disableOriginalConstructor ()
250
273
->setMethods (['create ' ])
251
274
->getMock ();
275
+
252
276
/** @var \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage|\PHPUnit_Framework_MockObject_MockObject $customerStorage */
253
277
$ customerStorage = $ this ->getMockBuilder (\Magento \CustomerImportExport \Model \ResourceModel \Import \Customer \Storage::class)
254
278
->setMethods (['load ' ])
255
279
->setConstructorArgs ([$ collectionFactory , $ byPagesIteratorFactory ])
256
280
->getMock ();
257
- $ resourceMock = $ this ->createPartialMock (
258
- \Magento \Customer \Model \ResourceModel \Customer::class,
259
- ['getIdFieldName ' ]
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 ));
270
- $ resourceMock ->expects ($ this ->any ())->method ('getIdFieldName ' )->will ($ this ->returnValue ('id ' ));
281
+
271
282
foreach ($ this ->_customers as $ customerData ) {
272
283
$ customerStorage ->addCustomerByArray ($ customerData );
273
284
}
0 commit comments