Skip to content

Commit c189cba

Browse files
committed
ACP2E-2737: Duplicate customers being created with same email address using import
1 parent a669f4b commit c189cba

File tree

1 file changed

+34
-2
lines changed
  • app/code/Magento/CustomerImportExport/Test/Unit/Model/Import

1 file changed

+34
-2
lines changed

app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AddressTest.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ class AddressTest extends TestCase
155155
*/
156156
private $configShare;
157157

158+
/**
159+
* @var Storage
160+
*/
161+
private $customerStorage;
162+
158163
/**
159164
* Init entity adapter model
160165
*/
@@ -205,7 +210,7 @@ protected function _getModelDependencies()
205210
->getMock();
206211
$connection = $this->createMock(\stdClass::class);
207212
$attributeCollection = $this->_createAttrCollectionMock();
208-
$customerStorage = $this->_createCustomerStorageMock();
213+
$this->customerStorage = $this->_createCustomerStorageMock();
209214
$customerEntity = $this->_createCustomerEntityMock();
210215
$addressCollection = new Collection(
211216
$this->createMock(EntityFactory::class)
@@ -229,7 +234,7 @@ protected function _getModelDependencies()
229234
'bunch_size' => 1,
230235
'attribute_collection' => $attributeCollection,
231236
'entity_type_id' => 1,
232-
'customer_storage' => $customerStorage,
237+
'customer_storage' => $this->customerStorage,
233238
'customer_entity' => $customerEntity,
234239
'address_collection' => $addressCollection,
235240
'entity_table' => 'not_used',
@@ -465,6 +470,33 @@ public function testValidateRowForUpdate(array $rowData, array $errors, $isValid
465470
}
466471
}
467472

473+
/**
474+
* @dataProvider validateRowForUpdateDataProvider
475+
*
476+
* @param array $rowData
477+
* @param array $errors
478+
* @param boolean $isValid
479+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
480+
*/
481+
public function testValidateRowForUpdateGlobalCustomer(array $rowData, array $errors, $isValid = false)
482+
{
483+
$this->_model->setParameters(['behavior' => Import::BEHAVIOR_ADD_UPDATE]);
484+
485+
$this->configShare->expects($this->once())
486+
->method('isGlobalScope')
487+
->willReturn(true);
488+
489+
$this->customerStorage->expects($this->once())
490+
->method('getCustomerIdByEmail')
491+
->willReturn(1);
492+
493+
if ($isValid) {
494+
$this->assertTrue($this->_model->validateRow($rowData, 0));
495+
} else {
496+
$this->assertFalse($this->_model->validateRow($rowData, 0));
497+
}
498+
}
499+
468500
/**
469501
* Test Address::validateRow()
470502
* with 2 rows with identical PKs in case when add/update behavior is performed

0 commit comments

Comments
 (0)