@@ -298,9 +298,6 @@ protected function _createCustomerEntityMock()
298
298
public function getWebsites ($ withDefault = false )
299
299
{
300
300
$ websites = [];
301
- if (!$ withDefault ) {
302
- unset($ websites [0 ]);
303
- }
304
301
foreach ($ this ->_websites as $ id => $ code ) {
305
302
if (!$ withDefault && $ id == \Magento \Store \Model \Store::DEFAULT_STORE_ID ) {
306
303
continue ;
@@ -330,97 +327,6 @@ public function iterate(\Magento\Framework\Data\Collection $collection, $pageSiz
330
327
}
331
328
}
332
329
333
- /**
334
- * Create mock for custom behavior test
335
- *
336
- * @return Address|\PHPUnit_Framework_MockObject_MockObject
337
- */
338
- protected function _getModelMockForTestImportDataWithCustomBehaviour ()
339
- {
340
- // input data
341
- $ customBehaviorRows = [
342
- [
343
- AbstractEntity::COLUMN_ACTION => 'update ' ,
344
- Address::COLUMN_ADDRESS_ID => $ this ->_customBehaviour ['update_id ' ],
345
- ],
346
- [
347
- AbstractEntity::COLUMN_ACTION => AbstractEntity::COLUMN_ACTION_VALUE_DELETE ,
348
- Address::COLUMN_ADDRESS_ID => $ this ->_customBehaviour ['delete_id ' ]
349
- ],
350
- ];
351
- $ updateResult = [
352
- 'entity_row_new ' => [],
353
- 'entity_row_update ' => $ this ->_customBehaviour ['update_id ' ],
354
- 'attributes ' => [],
355
- 'defaults ' => [],
356
- ];
357
- // entity adapter mock
358
- $ modelMock = $ this ->createPartialMock (
359
- \Magento \CustomerImportExport \Model \Import \Address::class,
360
- [
361
- 'validateRow ' ,
362
- '_prepareDataForUpdate ' ,
363
- '_saveAddressEntities ' ,
364
- '_saveAddressAttributes ' ,
365
- '_saveCustomerDefaults ' ,
366
- '_deleteAddressEntities ' ,
367
- '_mergeEntityAttributes ' ,
368
- 'getErrorAggregator ' ,
369
- 'getCustomerStorage ' ,
370
- 'prepareCustomerData ' ,
371
- ]
372
- );
373
- //Adding behaviours
374
- $ availableBehaviors = new \ReflectionProperty ($ modelMock , '_availableBehaviors ' );
375
- $ availableBehaviors ->setAccessible (true );
376
- $ availableBehaviors ->setValue ($ modelMock , $ this ->_availableBehaviors );
377
- // mock to imitate data source model
378
- $ dataSourceMock = $ this ->createPartialMock (
379
- \Magento \ImportExport \Model \ResourceModel \Import \Data::class,
380
- ['getNextBunch ' , '__wakeup ' , 'getIterator ' ]
381
- );
382
- $ dataSourceMock ->expects ($ this ->at (0 ))->method ('getNextBunch ' )->will ($ this ->returnValue ($ customBehaviorRows ));
383
- $ dataSourceMock ->expects ($ this ->at (1 ))->method ('getNextBunch ' )->will ($ this ->returnValue (null ));
384
- $ dataSourceMock ->expects ($ this ->any ())
385
- ->method ('getIterator ' )
386
- ->willReturn ($ this ->getMockForAbstractClass (\Iterator::class));
387
-
388
- $ dataSourceModel = new \ReflectionProperty (
389
- \Magento \CustomerImportExport \Model \Import \Address::class,
390
- '_dataSourceModel '
391
- );
392
- $ dataSourceModel ->setAccessible (true );
393
- $ dataSourceModel ->setValue ($ modelMock , $ dataSourceMock );
394
- // mock expects for entity adapter
395
- $ modelMock ->expects ($ this ->any ())->method ('validateRow ' )->will ($ this ->returnValue (true ));
396
- $ modelMock ->expects ($ this ->any ())
397
- ->method ('getErrorAggregator ' )
398
- ->will ($ this ->returnValue ($ this ->errorAggregator ));
399
- $ modelMock ->expects ($ this ->any ())->method ('_prepareDataForUpdate ' )->will ($ this ->returnValue ($ updateResult ));
400
- $ modelMock ->expects (
401
- $ this ->any ()
402
- )->method (
403
- '_saveAddressEntities '
404
- )->will (
405
- $ this ->returnCallback ([$ this , 'validateSaveAddressEntities ' ])
406
- );
407
- $ modelMock ->expects ($ this ->any ())->method ('_saveAddressAttributes ' )->will ($ this ->returnValue ($ modelMock ));
408
- $ modelMock ->expects ($ this ->any ())->method ('_saveCustomerDefaults ' )->will ($ this ->returnValue ($ modelMock ));
409
- $ modelMock ->expects (
410
- $ this ->any ()
411
- )->method (
412
- '_deleteAddressEntities '
413
- )->will (
414
- $ this ->returnCallback ([$ this , 'validateDeleteAddressEntities ' ])
415
- );
416
- $ modelMock ->expects ($ this ->any ())->method ('_mergeEntityAttributes ' )->will ($ this ->returnValue ([]));
417
- $ modelMock ->expects ($ this ->any ())
418
- ->method ('getCustomerStorage ' )
419
- ->willReturn ($ this ->_createCustomerStorageMock ());
420
-
421
- return $ modelMock ;
422
- }
423
-
424
330
/**
425
331
* Create mock for customer address model class
426
332
*
@@ -449,7 +355,9 @@ protected function _getModelMock()
449
355
new \Magento \Framework \Stdlib \DateTime (),
450
356
$ this ->createMock (\Magento \Customer \Model \Address \Validator \Postcode::class),
451
357
$ this ->_getModelDependencies (),
452
- $ this ->countryWithWebsites
358
+ $ this ->countryWithWebsites ,
359
+ $ this ->createMock (\Magento \CustomerImportExport \Model \ResourceModel \Import \Address \Storage::class),
360
+ $ this ->createMock (\Magento \Customer \Model \Indexer \Processor::class)
453
361
);
454
362
455
363
$ property = new \ReflectionProperty ($ modelMock , '_availableBehaviors ' );
@@ -606,20 +514,6 @@ public function testGetDefaultAddressAttributeMapping()
606
514
);
607
515
}
608
516
609
- /**
610
- * Test if correct methods are invoked according to different custom behaviours
611
- *
612
- * @covers \Magento\CustomerImportExport\Model\Import\Address::_importData
613
- */
614
- public function testImportDataWithCustomBehaviour ()
615
- {
616
- $ this ->_model = $ this ->_getModelMockForTestImportDataWithCustomBehaviour ();
617
- $ this ->_model ->setParameters (['behavior ' => \Magento \ImportExport \Model \Import::BEHAVIOR_CUSTOM ]);
618
-
619
- // validation in validateSaveAddressEntities and validateDeleteAddressEntities
620
- $ this ->_model ->importData ();
621
- }
622
-
623
517
/**
624
518
* Validation method for _saveAddressEntities (callback for _saveAddressEntities)
625
519
*
0 commit comments