ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,235 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CustomerImportExport\Model\Export;
use Magento\CustomerImportExport\Model\Import\Address as ImportAddress;
/**
* Test for customer address export model
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
*/
class AddressTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Address
*/
protected $_model;
/**
* List of existing websites
*
* @var array
*/
protected $_websites = [];
protected function setUp(): void
{
parent::setUp();
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\CustomerImportExport\Model\Export\Address::class
);
$websites = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Store\Model\StoreManagerInterface::class
)->getWebsites(
true
);
/** @var $website \Magento\Store\Model\Website */
foreach ($websites as $website) {
$this->_websites[$website->getId()] = $website->getCode();
}
}
/**
* Test export method
*/
public function testExport()
{
$websiteCode = Address::COLUMN_WEBSITE;
$emailCode = Address::COLUMN_EMAIL;
$entityIdCode = Address::COLUMN_ADDRESS_ID;
$expectedAttributes = [];
/** @var $collection \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection */
$collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class
);
/** @var $attribute \Magento\Customer\Model\Attribute */
foreach ($collection as $attribute) {
$expectedAttributes[] = $attribute->getAttributeCode();
}
// Get customer default addresses column name to customer attribute mapping array.
$defaultAddressMap = ImportAddress::getDefaultAddressAttributeMapping();
$this->_model->setWriter(
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\ImportExport\Model\Export\Adapter\Csv::class
)
);
$this->_model->setParameters([]);
$data = $this->_csvToArray($this->_model->export(), $entityIdCode);
$this->assertEquals(
count($expectedAttributes),
count(array_intersect($expectedAttributes, $data['header'])),
'Expected attribute codes were not exported'
);
$this->assertNotEmpty($data['data'], 'No data was exported');
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
// Get addresses
/** @var $customers \Magento\Customer\Model\Customer[] */
$customers = $objectManager->get(
\Magento\Framework\Registry::class
)->registry(
'_fixture/Magento_ImportExport_Customers_Array'
);
foreach ($customers as $customer) {
/** @var $address \Magento\Customer\Model\Address */
foreach ($customer->getAddresses() as $address) {
// Check unique key
$data['data'][$address->getId()][$websiteCode] = $this->_websites[$customer->getWebsiteId()];
$data['data'][$address->getId()][$emailCode] = $customer->getEmail();
$data['data'][$address->getId()][$entityIdCode] = $address->getId();
// Check by expected attributes
foreach ($expectedAttributes as $code) {
if (!in_array($code, $this->_model->getDisabledAttributes())) {
$this->assertEquals(
$address->getData($code),
$data['data'][$address->getId()][$code],
'Attribute "' . $code . '" is not equal'
);
}
}
// Check customer default addresses column name to customer attribute mapping array
foreach ($defaultAddressMap as $exportCode => $code) {
$this->assertEquals(
$address->getData($code),
(int)$data['data'][$address->getId()][$exportCode],
'Attribute "' . $code . '" is not equal'
);
}
}
}
}
/**
* Get possible gender values for filter
*
* @return array
*/
public function getGenderFilterValueDataProvider()
{
return ['male' => ['$genderFilterValue' => 1], 'female' => ['$genderFilterValue' => 2]];
}
/**
* Test export method if filter was set
*
* @dataProvider getGenderFilterValueDataProvider
*
* @param int $genderFilterValue
*/
public function testExportWithFilter($genderFilterValue)
{
$entityIdCode = Address::COLUMN_ADDRESS_ID;
$this->_model->setWriter(
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\ImportExport\Model\Export\Adapter\Csv::class
)
);
$filterData = ['export_filter' => ['gender' => $genderFilterValue]];
$this->_model->setParameters($filterData);
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
// Get expected address count
/** @var $customers \Magento\Customer\Model\Customer[] */
$customers = $objectManager->get(
\Magento\Framework\Registry::class
)->registry(
'_fixture/Magento_ImportExport_Customers_Array'
);
$expectedCount = 0;
foreach ($customers as $customer) {
if ($customer->getGender() == $genderFilterValue) {
$expectedCount += count($customer->getAddresses());
}
}
$data = $this->_csvToArray($this->_model->export(), $entityIdCode);
$this->assertCount($expectedCount, $data['data']);
}
/**
* Test entity type code value
*/
public function testGetEntityTypeCode()
{
$this->assertEquals('customer_address', $this->_model->getEntityTypeCode());
}
/**
* Test type of attribute collection
*/
public function testGetAttributeCollection()
{
$this->assertInstanceOf(
\Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class,
$this->_model->getAttributeCollection()
);
}
/**
* Export CSV string to array
*
* @param string $content
* @param mixed $entityId
* @return array
*/
protected function _csvToArray($content, $entityId = null)
{
$data = ['header' => [], 'data' => []];
$lines = str_getcsv($content, "\n");
foreach ($lines as $index => $line) {
if ($index == 0) {
$data['header'] = str_getcsv($line);
} else {
$row = array_combine($data['header'], str_getcsv($line));
if ($entityId !== null && !empty($row[$entityId])) {
$data['data'][$row[$entityId]] = $row;
} else {
$data['data'][] = $row;
}
}
}
return $data;
}
/**
* Test filename getter. Filename must be set in constructor.
*/
public function testGetFileName()
{
$this->assertEquals($this->_model->getEntityTypeCode(), $this->_model->getFileName());
}
}
@@ -0,0 +1,407 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CustomerImportExport\Model\Export;
use Magento\Framework\Locale\ResolverInterface as LocaleResolver;
use Magento\Customer\Model\Attribute;
use Magento\ImportExport\Model\Export;
use Magento\ImportExport\Model\Import;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\ImportExport\Model\Export\Adapter\Csv;
use Magento\Customer\Model\Customer as CustomerModel;
use Magento\Customer\Model\ResourceModel\Attribute\Collection;
use Magento\Customer\Model\ResourceModel\Customer\Collection as CustomerCollection;
/**
* Tests for customer export model.
*
* @magentoAppArea adminhtml
*/
class CustomerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Customer
*/
protected $_model;
/**
* @var ObjectManagerInterface
*/
private $objectManager;
/**
* @var array
*/
private $attributeValues;
/**
* @var array
*/
private $attributeTypes;
/**
* @var Collection
*/
private $attributeCollection;
/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->_model = $this->objectManager->create(Customer::class);
$this->attributeCollection = $this->objectManager->create(Collection::class);
}
/**
* Export "Customer Main File".
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
* @return void
*/
public function testExport()
{
$this->processCustomerAttribute();
$expectedAttributes = $this->getExpectedAttributes();
$lines = $this->export($expectedAttributes);
$this->checkExportData($lines, $expectedAttributes);
}
/**
* Export with Multi Websites "Customer Main File".
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers_with_websites.php
* @return void
*/
public function testExportWithMultiWebsites(): void
{
$this->processCustomerAttribute();
$expectedAttributes = $this->getExpectedAttributes();
$lines = $this->export($expectedAttributes);
$this->checkExportData($lines, $expectedAttributes);
}
/**
* Return attributes which should be exported.
*
* @return array
*/
private function getExpectedAttributes(): array
{
$expectedAttributes = [];
/** @var Attribute $attribute */
foreach ($this->attributeCollection as $attribute) {
$expectedAttributes[] = $attribute->getAttributeCode();
}
return array_diff($expectedAttributes, $this->_model->getDisabledAttributes());
}
/**
* Prepare Customer attribute.
*
* @return void
*/
private function processCustomerAttribute(): void
{
$this->initAttributeValues($this->attributeCollection);
$this->initAttributeTypes($this->attributeCollection);
}
/**
* Export customer.
*
* @param array $expectedAttributes
* @return array
*/
private function export(array $expectedAttributes): array
{
$this->_model->setWriter($this->objectManager->create(Csv::class));
$data = $this->_model->export();
$this->assertNotEmpty($data);
$lines = $this->_csvToArray($data, 'email');
$this->assertEquals(
count($expectedAttributes),
count(array_intersect($expectedAttributes, $lines['header'])),
'Expected attribute codes were not exported.'
);
$this->assertNotEmpty($lines['data'], 'No data was exported.');
return $lines;
}
/**
* Check that exported data is correct.
*
* @param array $lines
* @param array $expectedAttributes
* @return void
*/
private function checkExportData(array $lines, array $expectedAttributes): void
{
/** @var CustomerModel[] $customers */
$customers = $this->objectManager->create(CustomerCollection::class);
foreach ($customers as $customer) {
$data = $this->processCustomerData($customer, $expectedAttributes);
$exportData = $lines['data'][$data['email']];
$exportData = $this->unsetDuplicateData($exportData);
foreach ($data as $key => $value) {
$this->assertEquals($value, $exportData[$key], "Attribute '{$key}' is not equal.");
}
}
}
/**
* Initialize attribute option values.
*
* @param Collection $attributeCollection
* @return CustomerTest
*/
private function initAttributeValues(Collection $attributeCollection): CustomerTest
{
/** @var Attribute $attribute */
foreach ($attributeCollection as $attribute) {
$this->attributeValues[$attribute->getAttributeCode()] = $this->_model->getAttributeOptions($attribute);
}
return $this;
}
/**
* Initialize attribute types.
*
* @param \Magento\Customer\Model\ResourceModel\Attribute\Collection $attributeCollection
* @return CustomerTest
*/
private function initAttributeTypes(Collection $attributeCollection): CustomerTest
{
/** @var Attribute $attribute */
foreach ($attributeCollection as $attribute) {
$this->attributeTypes[$attribute->getAttributeCode()] = $attribute->getFrontendInput();
}
return $this;
}
/**
* Format Customer data as same as export data.
*
* @param CustomerModel $item
* @param array $expectedAttributes
* @return array
*/
private function processCustomerData(CustomerModel $item, array $expectedAttributes): array
{
$data = [];
foreach ($expectedAttributes as $attributeCode) {
$attributeValue = $item->getData($attributeCode);
if ($this->isMultiselect($attributeCode)) {
$values = [];
$attributeValue = explode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attributeValue);
foreach ($attributeValue as $value) {
$values[] = $this->getAttributeValueById($attributeCode, $value);
}
$data[$attributeCode] = implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $values);
} else {
$data[$attributeCode] = $this->getAttributeValueById($attributeCode, $attributeValue);
}
}
return $data;
}
/**
* Check that attribute is multiselect type by attribute code.
*
* @param string $attributeCode
* @return bool
*/
private function isMultiselect(string $attributeCode): bool
{
return isset($this->attributeTypes[$attributeCode])
&& $this->attributeTypes[$attributeCode] === 'multiselect';
}
/**
* Return attribute value by id.
*
* @param string $attributeCode
* @param int|string $valueId
* @return int|string|array
*/
private function getAttributeValueById(string $attributeCode, $valueId)
{
if (isset($this->attributeValues[$attributeCode])
&& isset($this->attributeValues[$attributeCode][$valueId])
) {
return $this->attributeValues[$attributeCode][$valueId];
}
return $valueId;
}
/**
* Unset non-useful or duplicate data from exported file data.
*
* @param array $data
* @return array
*/
private function unsetDuplicateData(array $data): array
{
unset($data['_website']);
unset($data['_store']);
unset($data['password']);
return $data;
}
/**
* Test entity type code value
*/
public function testGetEntityTypeCode()
{
$this->assertEquals('customer', $this->_model->getEntityTypeCode());
}
/**
* Test type of attribute collection
*/
public function testGetAttributeCollection()
{
$this->assertInstanceOf(Collection::class, $this->_model->getAttributeCollection());
}
/**
* Test for method filterAttributeCollection()
*/
public function testFilterAttributeCollection()
{
/** @var $collection Collection */
$collection = $this->_model->getAttributeCollection();
$collection = $this->_model->filterAttributeCollection($collection);
/**
* Check that disabled attributes is not existed in attribute collection
*/
$existedAttributes = [];
/** @var $attribute Attribute */
foreach ($collection as $attribute) {
$existedAttributes[] = $attribute->getAttributeCode();
}
$disabledAttributes = $this->_model->getDisabledAttributes();
foreach ($disabledAttributes as $attributeCode) {
$this->assertNotContains(
$attributeCode,
$existedAttributes,
'Disabled attribute "' . $attributeCode . '" existed in collection'
);
}
/**
* Check that all overridden attributes were affected during filtering process
*/
$overriddenAttributes = $this->_model->getOverriddenAttributes();
/** @var $attribute Attribute */
foreach ($collection as $attribute) {
if (isset($overriddenAttributes[$attribute->getAttributeCode()])) {
foreach ($overriddenAttributes[$attribute->getAttributeCode()] as $propertyKey => $property) {
$this->assertEquals(
$property,
$attribute->getData($propertyKey),
'Value of property "' . $propertyKey . '" is not equals'
);
}
}
}
}
/**
* Test for method filterEntityCollection()
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
* @dataProvider filterDataProvider
* @param string $locale
* @param int $count
* @param array $filter
*/
public function testFilterEntityCollection(string $locale, int $count, array $filter)
{
$localeResolver = $this->objectManager->get(LocaleResolver::class);
$localeResolver->setLocale($locale);
$filter += [
'email' => 'example.com',
'store_id' => $this->objectManager->get(StoreManagerInterface::class)->getStore()->getId(),
];
$parameters = [Export::FILTER_ELEMENT_GROUP => $filter];
$this->_model->setParameters($parameters);
/** @var $customers Collection */
$collection = $this->_model->filterEntityCollection(
$this->objectManager->create(
CustomerCollection::class
)
);
$collection->load();
$this->assertCount($count, $collection);
}
/**
* @return array
*/
public function filterDataProvider(): array
{
return [
['en_US', 1, ['created_at' => ['01/02/1999', '01/03/1999']]],
['en_US', 0, ['created_at' => ['02/01/1999', '02/02/1999']]],
['en_US', 2, ['created_at' => ['03/04/1999', null]]],
['en_US', 3, ['created_at' => [null, '05/07/1999']]],
['en_AU', 1, ['created_at' => ['02/01/1999', '02/02/1999']]],
['en_AU', 0, ['created_at' => ['01/02/1999', '01/03/1999']]],
['en_AU', 2, ['created_at' => ['04/03/1999', null]]],
['en_AU', 3, ['created_at' => [null, '07/05/1999']]],
['de_DE', 1, ['created_at' => ['02.01.1999', '03.01.1999']]],
['de_DE', 0, ['created_at' => ['01.02.1999', '01.03.1999']]],
['de_DE', 2, ['created_at' => ['04.03.1999', null]]],
['en_AU', 3, ['created_at' => [null, '07.05.1999']]],
];
}
/**
* Export CSV string to array
*
* @param string $content
* @param mixed $entityId
* @return array
*/
protected function _csvToArray($content, $entityId = null)
{
$data = ['header' => [], 'data' => []];
$lines = str_getcsv($content, "\n");
foreach ($lines as $index => $line) {
if ($index == 0) {
$data['header'] = str_getcsv($line);
} else {
$row = array_combine($data['header'], str_getcsv($line));
if ($entityId !== null && !empty($row[$entityId])) {
$data['data'][$row[$entityId]] = $row;
} else {
$data['data'][] = $row;
}
}
}
return $data;
}
}
@@ -0,0 +1,712 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Test class for \Magento\CustomerImportExport\Model\Import\Address
*/
namespace Magento\CustomerImportExport\Model\Import;
use Magento\Catalog\Model\ResourceModel\Product;
use Magento\Customer\Api\AddressRepositoryInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\AddressRegistry;
use Magento\Customer\Model\Indexer\Processor;
use Magento\Customer\Model\ResourceModel\Address\Collection;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime;
use Magento\ImportExport\Model\Import as ImportModel;
use Magento\ImportExport\Model\Import\Adapter as ImportAdapter;
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
use Magento\ImportExport\Model\Import\Source\Csv;
use Magento\ImportExport\Model\ResourceModel\Helper;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Indexer\StateInterface;
use Magento\TestFramework\ObjectManager;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AddressTest extends TestCase
{
/**
* Tested class name
*
* @var string
*/
protected $_testClassName = Address::class;
/**
* Fixture key from fixture
*
* @var string
*/
protected $_fixtureKey = '_fixture/Magento_ImportExport_Customers_Array';
/**
* Address entity adapter instance
*
* @var Address
*/
protected $_entityAdapter;
/**
* Important data from address_import_update.csv (postcode is key)
*
* @var array
*/
protected $_updateData = [
'address' => [ // address records
'update' => '19107', // address with updates
'new' => '85034', // new address
'no_customer' => '33602', // there is no customer with this primary key (email+website)
'new_no_address_id' => '32301'// new address without address id
],
'update' => [ // this data is changed in CSV file
'19107' => [
'firstname' => 'Katy',
'middlename' => 'T.',
],
],
'remove' => [ // this data is not set in CSV file
'19107' => [
'city' => 'Philadelphia',
'region' => null,
],
],
'default' => [ // new default billing/shipping addresses
'billing' => '85034',
'shipping' => '19107',
],
];
/**
* Important data from address_import_delete.csv (postcode is key)
*
* @var array
*/
protected $_deleteData = [
'delete' => '19107', // deleted address
'not_delete' => '72701', // not deleted address
];
/** @var \Magento\Customer\Model\ResourceModel\Customer */
protected $customerResource;
/**
* @var Processor
*/
private $indexerProcessor;
/**
* Init new instance of address entity adapter
*/
protected function setUp(): void
{
/** @var Product $productResource */
$this->customerResource = Bootstrap::getObjectManager()->get(
\Magento\Customer\Model\ResourceModel\Customer::class
);
$this->_entityAdapter = Bootstrap::getObjectManager()->create(
$this->_testClassName
);
$this->indexerProcessor = Bootstrap::getObjectManager()->create(
Processor::class
);
}
/**
* Test _saveAddressEntity
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
*/
public function testSaveAddressEntities()
{
// invoke _saveAddressEntities
list($customerId, $addressId) = $this->_addTestAddress($this->_entityAdapter);
// check DB
$testAddress = Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\Address::class
);
$testAddress->load($addressId);
$this->assertEquals($addressId, $testAddress->getId(), 'Incorrect address ID.');
$this->assertEquals($customerId, $testAddress->getParentId(), 'Incorrect address customer ID.');
}
/**
* Add new test address for existing customer
*
* @param Address $entityAdapter
* @return array (customerID, addressID)
*/
protected function _addTestAddress(Address $entityAdapter)
{
/** @var $objectManager ObjectManager */
$objectManager = Bootstrap::getObjectManager();
$customers = $objectManager->get(Registry::class)->registry($this->_fixtureKey);
/** @var $customer \Magento\Customer\Model\Customer */
$customer = reset($customers);
$customerId = $customer->getId();
/** @var $addressModel \Magento\Customer\Model\Address */
$addressModel = Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\Address::class
);
$tableName = $addressModel->getResource()->getEntityTable();
$addressId = $objectManager->get(Helper::class)
->getNextAutoincrement($tableName);
$newEntityData = [
'entity_id' => $addressId,
'parent_id' => $customerId,
'created_at' => (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT),
'updated_at' => (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT),
];
// invoke _saveAddressEntities
$saveAddressEntities = new \ReflectionMethod($this->_testClassName, '_saveAddressEntities');
$saveAddressEntities->setAccessible(true);
$saveAddressEntities->invoke($entityAdapter, $newEntityData, []);
return [$customerId, $addressId];
}
/**
* Test _saveAddressAttributes
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
*/
public function testSaveAddressAttributes()
{
$this->markTestSkipped("to test _saveAddressAttributes attribute need to add custom address attribute");
// get attributes list
$attributesReflection = new \ReflectionProperty($this->_testClassName, '_attributes');
$attributesReflection->setAccessible(true);
$attributes = $attributesReflection->getValue($this->_entityAdapter);
// get some attribute
$attributeName = 'city';
$this->assertArrayHasKey($attributeName, $attributes, 'Key "' . $attributeName . '" should be an attribute.');
$attributeParams = $attributes[$attributeName];
$this->assertArrayHasKey('id', $attributeParams, 'Attribute must have an ID.');
$this->assertArrayHasKey('table', $attributeParams, 'Attribute must have a table.');
// create new address with attributes
$data = $this->_addTestAddress($this->_entityAdapter);
$addressId = $data[1];
$attributeId = $attributeParams['id'];
$attributeTable = $attributeParams['table'];
$attributeValue = 'Test City';
$attributeArray = [];
$attributeArray[$attributeTable][$addressId][$attributeId] = $attributeValue;
// invoke _saveAddressAttributes
$saveAttributes = new \ReflectionMethod($this->_testClassName, '_saveAddressAttributes');
$saveAttributes->setAccessible(true);
$saveAttributes->invoke($this->_entityAdapter, $attributeArray);
// check DB
/** @var $testAddress \Magento\Customer\Model\Address */
$testAddress = Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\Address::class
);
$testAddress->load($addressId);
$this->assertEquals($addressId, $testAddress->getId(), 'Incorrect address ID.');
$this->assertEquals($attributeValue, $testAddress->getData($attributeName), 'There is no attribute value.');
}
/**
* Test _saveCustomerDefaults
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
*/
public function testSaveCustomerDefaults()
{
/** @var $objectManager ObjectManager */
$objectManager = Bootstrap::getObjectManager();
// get not default address
$customers = $objectManager->get(Registry::class)->registry($this->_fixtureKey);
/** @var $notDefaultAddress \Magento\Customer\Model\Address */
$notDefaultAddress = null;
/** @var $addressCustomer \Magento\Customer\Model\Customer */
$addressCustomer = null;
/** @var $customer \Magento\Customer\Model\Customer */
foreach ($customers as $customer) {
/** @var $address \Magento\Customer\Model\Address */
foreach ($customer->getAddressesCollection() as $address) {
if (!$customer->getDefaultBillingAddress() && !$customer->getDefaultShippingAddress()) {
$notDefaultAddress = $address;
$addressCustomer = $customer;
break;
}
if ($notDefaultAddress) {
break;
}
}
}
$this->assertNotNull($notDefaultAddress, 'Not default address must exists.');
$this->assertNotNull($addressCustomer, 'Not default address customer must exists.');
$addressId = $notDefaultAddress->getId();
$customerId = $addressCustomer->getId();
// set customer defaults
$defaults = [
$this->customerResource->getTable('customer_entity') => [
$customerId => ['default_billing' => $addressId, 'default_shipping' => $addressId],
],
];
// invoke _saveCustomerDefaults
$saveDefaults = new \ReflectionMethod($this->_testClassName, '_saveCustomerDefaults');
$saveDefaults->setAccessible(true);
$saveDefaults->invoke($this->_entityAdapter, $defaults);
// check DB
/** @var $testCustomer \Magento\Customer\Model\Customer */
$testCustomer = Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\Customer::class
);
$testCustomer->load($customerId);
$this->assertEquals($customerId, $testCustomer->getId(), 'Customer must exists.');
$this->assertNotNull($testCustomer->getDefaultBillingAddress(), 'Default billing address must exists.');
$this->assertNotNull($testCustomer->getDefaultShippingAddress(), 'Default shipping address must exists.');
$this->assertEquals(
$addressId,
$testCustomer->getDefaultBillingAddress()->getId(),
'Incorrect default billing address.'
);
$this->assertEquals(
$addressId,
$testCustomer->getDefaultShippingAddress()->getId(),
'Incorrect default shipping address.'
);
}
/**
* Test import data method with add/update behaviour
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers_for_address_import.php
*/
public function testImportDataAddUpdate()
{
// set behaviour
$this->_entityAdapter->setParameters(
['behavior' => ImportModel::BEHAVIOR_ADD_UPDATE]
);
// set fixture CSV file
$sourceFile = __DIR__ . '/_files/address_import_update.csv';
/** @var $objectManager ObjectManager */
$objectManager = Bootstrap::getObjectManager();
$filesystem = $objectManager->create(Filesystem::class);
$directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$result = $this->_entityAdapter->setSource(
ImportAdapter::findAdapterFor($sourceFile, $directoryWrite)
)
->validateData()
->hasToBeTerminated();
$this->assertFalse($result, 'Validation result must be false.');
// import data
$this->_entityAdapter->importData();
// form attribute list
$keyAttribute = 'postcode';
$requiredAttributes[] = [$keyAttribute];
foreach (['update', 'remove'] as $action) {
foreach ($this->_updateData[$action] as $attributes) {
$requiredAttributes[] = array_keys($attributes);
}
}
$requiredAttributes = array_merge([], ...$requiredAttributes);
// get addresses
$addressCollection = Bootstrap::getObjectManager()->create(
Collection::class
);
$addressCollection->addAttributeToSelect($requiredAttributes);
$addresses = [];
/** @var $address \Magento\Customer\Model\Address */
foreach ($addressCollection as $address) {
$addresses[$address->getData($keyAttribute)] = $address;
}
// is addresses exists
$this->assertArrayHasKey($this->_updateData['address']['update'], $addresses, 'Address must exist.');
$this->assertArrayHasKey($this->_updateData['address']['new'], $addresses, 'Address must exist.');
$this->assertArrayNotHasKey(
$this->_updateData['address']['no_customer'],
$addresses,
'Address must not exist.'
);
$this->assertArrayHasKey(
$this->_updateData['address']['new_no_address_id'],
$addresses,
'Address must exist.'
);
// are updated address fields have new values
$updatedAddressId = $this->_updateData['address']['update'];
/** @var $updatedAddress \Magento\Customer\Model\Address */
$updatedAddress = $addresses[$updatedAddressId];
$updatedData = $this->_updateData['update'][$updatedAddressId];
foreach ($updatedData as $fieldName => $fieldValue) {
$this->assertEquals($fieldValue, $updatedAddress->getData($fieldName));
}
// are removed data fields have old values
$removedData = $this->_updateData['remove'][$updatedAddressId];
foreach ($removedData as $fieldName => $fieldValue) {
$this->assertEquals($fieldValue, $updatedAddress->getData($fieldName));
}
// are default billing/shipping addresses have new value
/** @var $customer \Magento\Customer\Model\Customer */
$customer = Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\Customer::class
);
$customer->setWebsiteId(0);
$customer->loadByEmail('BetsyParker@example.com');
$defaultsData = $this->_updateData['default'];
$this->assertEquals(
$defaultsData['billing'],
$customer->getDefaultBillingAddress()->getData($keyAttribute),
'Incorrect default billing address'
);
$this->assertEquals(
$defaultsData['shipping'],
$customer->getDefaultShippingAddress()->getData($keyAttribute),
'Incorrect default shipping address'
);
}
/**
* Test import data method with delete behaviour
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers_for_address_import.php
*/
public function testImportDataDelete()
{
// set behaviour
$this->_entityAdapter->setParameters(['behavior' => ImportModel::BEHAVIOR_DELETE]);
// set fixture CSV file
$sourceFile = __DIR__ . '/_files/address_import_delete.csv';
/** @var $objectManager ObjectManager */
$objectManager = Bootstrap::getObjectManager();
$filesystem = $objectManager->create(Filesystem::class);
$directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$result = $this->_entityAdapter->setSource(
ImportAdapter::findAdapterFor($sourceFile, $directoryWrite)
)->validateData()->hasToBeTerminated();
$this->assertTrue(!$result, 'Validation result must be true.');
// import data
$this->_entityAdapter->importData();
// key attribute
$keyAttribute = 'postcode';
// get addresses
/** @var $addressCollection Collection */
$addressCollection = Bootstrap::getObjectManager()->create(
Collection::class
);
$addressCollection->addAttributeToSelect($keyAttribute);
$addresses = [];
/** @var $address \Magento\Customer\Model\Address */
foreach ($addressCollection as $address) {
$addresses[$address->getData($keyAttribute)] = $address;
}
// is addresses exists
$this->assertArrayNotHasKey($this->_deleteData['delete'], $addresses, 'Address must not exist.');
$this->assertArrayHasKey($this->_deleteData['not_delete'], $addresses, 'Address must exist.');
}
/**
* Case when attribute settings for two websites are different.
*
* @magentoAppArea adminhtml
* @magentoAppIsolation enabled
* @magentoDbIsolation enabled
* @magentoDataFixture Magento/CustomerImportExport/_files/two_addresses.php
* @return void
*/
public function testDifferentOptions(): void
{
/** @var $objectManager ObjectManager */
$objectManager = Bootstrap::getObjectManager();
/** @var Filesystem $filesystem */
$filesystem = $objectManager->create(Filesystem::class);
//Only add/update behaviour will have validation in place required to
//test this case
$this->_entityAdapter->setParameters(
['behavior' => ImportModel::BEHAVIOR_ADD_UPDATE]
);
//Load from
$sourceFile = __DIR__ . '/_files/two_addresses_import_update.csv';
$directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
//Validate
$adapter = ImportAdapter::findAdapterFor($sourceFile, $directoryWrite);
$errors = $this->_entityAdapter->setSource($adapter)->validateData();
$this->assertEmpty($errors->getErrorsCount(), 'CSV must be valid');
//Import
$imported = $this->_entityAdapter->importData();
$this->assertTrue($imported, 'Must be successfully imported');
}
/**
* Test customer indexer gets invalidated after import when Update on Schedule mode is set
*
* @magentoDbIsolation enabled
*/
public function testCustomerIndexer(): void
{
$file = __DIR__ . '/_files/address_import_update.csv';
$filesystem = Bootstrap::getObjectManager()
->create(Filesystem::class);
$directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$source = new Csv($file, $directoryWrite);
$this->_entityAdapter
->setParameters(['behavior' => ImportModel::BEHAVIOR_ADD_UPDATE])
->setSource($source)
->validateData()
->hasToBeTerminated();
$this->indexerProcessor->getIndexer()->reindexAll();
$statusBeforeImport = $this->indexerProcessor->getIndexer()->getStatus();
$this->indexerProcessor->getIndexer()->setScheduled(true);
$this->_entityAdapter->importData();
$statusAfterImport = $this->indexerProcessor->getIndexer()->getStatus();
$this->assertEquals(StateInterface::STATUS_VALID, $statusBeforeImport);
$this->assertEquals(StateInterface::STATUS_INVALID, $statusAfterImport);
}
/**
* Test import address with region for a country that does not have regions defined
*
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
*/
public function testImportAddressWithOptionalRegion()
{
$customer = $this->getCustomer('BetsyParker@example.com');
$file = __DIR__ . '/_files/import_uk_address.csv';
$errors = $this->doImport($file);
$this->assertImportValidationPassed($errors);
$address = $this->getAddresses(
[
'parent_id' => $customer->getId(),
'country_id' => 'GB',
]
);
$this->assertCount(1, $address);
$this->assertNull($address[0]->getRegionId());
$this->assertEquals('Liverpool', $address[0]->getRegion()->getRegion());
}
/**
* Test update first name and last name
*
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
*/
public function testUpdateFirstAndLastName()
{
$customer = $this->getCustomer('BetsyParker@example.com');
$addresses = $this->getAddresses(
[
'parent_id' => $customer->getId(),
]
);
$this->assertCount(1, $addresses);
$address = $addresses[0];
$row = [
'_website' => 'base',
'_email' => $customer->getEmail(),
'_entity_id' => $address->getId(),
'firstname' => 'Mark',
'lastname' => 'Antony',
];
$file = $this->generateImportFile([$row]);
$errors = $this->doImport($file);
$this->assertImportValidationPassed($errors);
$objectManager = Bootstrap::getObjectManager();
//clear cache
$objectManager->get(AddressRegistry::class)->remove($address->getId());
$addresses = $this->getAddresses(
[
'parent_id' => $customer->getId(),
'entity_id' => $address->getId(),
]
);
$this->assertCount(1, $addresses);
$updatedAddress = $addresses[0];
//assert that firstname and lastname were updated
$this->assertEquals($row['firstname'], $updatedAddress->getFirstname());
$this->assertEquals($row['lastname'], $updatedAddress->getLastname());
//assert other values have not changed
$this->assertEquals($address->getStreet(), $updatedAddress->getStreet());
$this->assertEquals($address->getCity(), $updatedAddress->getCity());
$this->assertEquals($address->getCountryId(), $updatedAddress->getCountryId());
$this->assertEquals($address->getTelephone(), $updatedAddress->getTelephone());
$this->assertEquals($address->getRegionId(), $updatedAddress->getRegionId());
//assert empty non-required values changed
$this->assertEquals(null, $updatedAddress->getPostcode());
}
/**
* Get Addresses by filter
*
* @param array $filter
* @return AddressInterface[]
*/
private function getAddresses(array $filter): array
{
$objectManager = Bootstrap::getObjectManager();
/** @var AddressRepositoryInterface $repository */
$repository = $objectManager->create(AddressRepositoryInterface::class);
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
foreach ($filter as $attr => $value) {
$searchCriteriaBuilder->addFilter($attr, $value);
}
return $repository->getList($searchCriteriaBuilder->create())->getItems();
}
/**
* @param string $email
* @return CustomerInterface
*/
private function getCustomer(string $email): CustomerInterface
{
$objectManager = Bootstrap::getObjectManager();
$customerRepository = $objectManager->get(CustomerRepositoryInterface::class);
return $customerRepository->get($email);
}
/**
* @param string $file
* @param string $behavior
* @param bool $validateOnly
* @return ProcessingErrorAggregatorInterface
*/
private function doImport(
string $file,
string $behavior = ImportModel::BEHAVIOR_ADD_UPDATE,
bool $validateOnly = false
): ProcessingErrorAggregatorInterface {
$objectManager = Bootstrap::getObjectManager();
/** @var Filesystem $filesystem */
$filesystem = $objectManager->create(Filesystem::class);
$directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$source = ImportAdapter::findAdapterFor($file, $directoryWrite);
$errors = $this->_entityAdapter
->setParameters(['behavior' => $behavior])
->setSource($source)
->validateData();
if (!$validateOnly && !$errors->getAllErrors()) {
$this->_entityAdapter->importData();
}
return $errors;
}
/**
* @param array $data
* @return string
*/
private function generateImportFile(array $data): string
{
$objectManager = Bootstrap::getObjectManager();
/** @var Filesystem $filesystem */
$filesystem = $objectManager->get(Filesystem::class);
$tmpDir = $filesystem->getDirectoryWrite(DirectoryList::TMP);
$tmpFilename = uniqid('test_import_address_') . '.csv';
$stream = $tmpDir->openFile($tmpFilename, 'w+');
$stream->lock();
$stream->writeCsv($this->getFields());
$emptyRow = array_fill_keys($this->getFields(), '');
foreach ($data as $row) {
$row = array_replace($emptyRow, $row);
$stream->writeCsv($row);
}
$stream->unlock();
$stream->close();
return $tmpDir->getAbsolutePath($tmpFilename);
}
/**
* @param ProcessingErrorAggregatorInterface $errors
*/
private function assertImportValidationPassed(ProcessingErrorAggregatorInterface $errors): void
{
if ($errors->getAllErrors()) {
$messages = [];
$messages[] = 'Import validation failed';
$messages[] = '';
foreach ($errors->getAllErrors() as $error) {
$messages[] = sprintf(
'%s: #%d [%s] %s: %s',
strtoupper($error->getErrorLevel()),
$error->getRowNumber(),
$error->getErrorCode(),
$error->getErrorMessage(),
$error->getErrorDescription()
);
}
$this->fail(implode("\n", $messages));
}
}
/**
* @return array
*/
private function getFields(): array
{
return [
'_website',
'_email',
'_entity_id',
'city',
'company',
'country_id',
'fax',
'firstname',
'lastname',
'middlename',
'postcode',
'prefix',
'region',
'region_id',
'street',
'suffix',
'telephone',
'vat_id',
'vat_is_valid',
'vat_request_date',
'vat_request_id',
'vat_request_success',
'_address_default_billing_',
'_address_default_shipping_',
];
}
}
@@ -0,0 +1,232 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CustomerImportExport\Model\Import;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
/**
* Test for CustomerComposite import class
*/
class CustomerCompositeTest extends \PHPUnit\Framework\TestCase
{
/**#@+
* Attributes used in test assertions
*/
const ATTRIBUTE_CODE_FIRST_NAME = 'firstname';
const ATTRIBUTE_CODE_LAST_NAME = 'lastname';
/**#@-*/
/**#@+
* Source *.csv file names for different behaviors
*/
const UPDATE_FILE_NAME = 'customer_composite_update.csv';
const DELETE_FILE_NAME = 'customer_composite_delete.csv';
/**#@-*/
/**
* Object Manager instance
*
* @var \Magento\TestFramework\ObjectManager
*/
protected $_objectManager;
/**
* Composite customer entity adapter instance
*
* @var CustomerComposite
*/
protected $_entityAdapter;
/**
* Additional customer attributes for assertion
*
* @var array
*/
protected $_customerAttributes = [self::ATTRIBUTE_CODE_FIRST_NAME, self::ATTRIBUTE_CODE_LAST_NAME];
/**
* Customers and addresses before import, address ID is postcode
*
* @var array
*/
protected $_beforeImport = [
'betsyparker@example.com' => [
'addresses' => ['19107', '72701'],
'data' => [self::ATTRIBUTE_CODE_FIRST_NAME => 'Betsy', self::ATTRIBUTE_CODE_LAST_NAME => 'Parker'],
],
];
/**
* Customers and addresses after import, address ID is postcode
*
* @var array
*/
protected $_afterImport = [
'betsyparker@example.com' => [
'addresses' => ['19107', '72701', '19108'],
'data' => [
self::ATTRIBUTE_CODE_FIRST_NAME => 'NotBetsy',
self::ATTRIBUTE_CODE_LAST_NAME => 'NotParker',
],
],
'anthonyanealy@magento.com' => ['addresses' => ['72701', '92664']],
'loribbanks@magento.com' => ['addresses' => ['98801']],
'kellynilson@magento.com' => ['addresses' => []],
];
protected function setUp(): void
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_entityAdapter = $this->_objectManager->create(
\Magento\CustomerImportExport\Model\Import\CustomerComposite::class
);
}
/**
* Assertion of current customer and address data
*
* @param array $expectedData
*/
protected function _assertCustomerData(array $expectedData)
{
/** @var $collection \Magento\Customer\Model\ResourceModel\Customer\Collection */
$collection = $this->_objectManager->create(\Magento\Customer\Model\ResourceModel\Customer\Collection::class);
$collection->addAttributeToSelect($this->_customerAttributes);
$customers = $collection->getItems();
$this->assertSameSize($expectedData, $customers);
/** @var $customer \Magento\Customer\Model\Customer */
foreach ($customers as $customer) {
// assert customer existence
$email = strtolower($customer->getEmail());
$this->assertArrayHasKey($email, $expectedData);
// assert customer data (only for required customers)
if (isset($expectedData[$email]['data'])) {
foreach ($expectedData[$email]['data'] as $attribute => $expectedValue) {
$this->assertEquals($expectedValue, $customer->getData($attribute));
}
}
// assert address data
$addresses = $customer->getAddresses();
$this->assertSameSize($expectedData[$email]['addresses'], $addresses);
/** @var $address \Magento\Customer\Model\Address */
foreach ($addresses as $address) {
$this->assertContains($address->getData('postcode'), $expectedData[$email]['addresses']);
}
}
}
/**
* @param string $behavior
* @param string $sourceFile
* @param array $dataBefore
* @param array $dataAfter
* @param int $updatedItemsCount
* @param int $createdItemsCount
* @param int $deletedItemsCount
* @param array $errors
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers_for_address_import.php
* @magentoAppIsolation enabled
*
* @dataProvider importDataDataProvider
*/
public function testImportData(
$behavior,
$sourceFile,
array $dataBefore,
array $dataAfter,
$updatedItemsCount,
$createdItemsCount,
$deletedItemsCount,
array $errors = []
) {
\Magento\TestFramework\Helper\Bootstrap::getInstance()
->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
// set entity adapter parameters
$this->_entityAdapter->setParameters(['behavior' => $behavior]);
/** @var \Magento\Framework\Filesystem $filesystem */
$filesystem = $this->_objectManager->create(\Magento\Framework\Filesystem::class);
$rootDirectory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$this->_entityAdapter->getErrorAggregator()->initValidationStrategy(
ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_STOP_ON_ERROR,
10
);
// set fixture CSV file
$result = $this->_entityAdapter->setSource(
\Magento\ImportExport\Model\Import\Adapter::findAdapterFor($sourceFile, $rootDirectory)
)
->validateData()
->hasToBeTerminated();
if ($errors) {
$this->assertTrue($result);
} else {
$this->assertFalse($result);
}
// assert validation errors
// can't use error codes because entity adapter gathers only error messages from aggregated adapters
$actualErrors = array_values($this->_entityAdapter->getErrorAggregator()->getRowsGroupedByErrorCode());
$this->assertEquals($errors, $actualErrors);
// assert data before import
$this->_assertCustomerData($dataBefore);
// import data
$this->_entityAdapter->importData();
$this->assertSame($updatedItemsCount, $this->_entityAdapter->getUpdatedItemsCount());
$this->assertSame($createdItemsCount, $this->_entityAdapter->getCreatedItemsCount());
$this->assertSame($deletedItemsCount, $this->_entityAdapter->getDeletedItemsCount());
// assert data after import
$this->_assertCustomerData($dataAfter);
}
/**
* Data provider for testImportData
*
* @return array
*/
public function importDataDataProvider()
{
$filesDirectory = __DIR__ . '/_files/';
$sourceData = [
'delete_behavior' => [
'$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE,
'$sourceFile' => $filesDirectory . self::DELETE_FILE_NAME,
'$dataBefore' => $this->_beforeImport,
'$dataAfter' => [],
'$updatedItemsCount' => 0,
'$createdItemsCount' => 0,
'$deletedItemsCount' => 1,
'$errors' => [],
],
];
$sourceData['add_update_behavior'] = [
'$behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_ADD_UPDATE,
'$sourceFile' => $filesDirectory . self::UPDATE_FILE_NAME,
'$dataBefore' => $this->_beforeImport,
'$dataAfter' => $this->_afterImport,
'$updatedItemsCount' => 1,
'$createdItemsCount' => 3,
'$deletedItemsCount' => 0,
'$errors' => [],
];
return $sourceData;
}
}
@@ -0,0 +1,540 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CustomerImportExport\Model\Import;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\Indexer\Processor;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem\Directory\Write as DirectoryWrite;
use Magento\Framework\Filesystem\File\WriteFactory;
use Magento\Framework\Indexer\StateInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\ImportExport\Model\Import;
use Magento\ImportExport\Model\Import\Source\CsvFactory;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Test for class Customer which covers validation logic
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class CustomerTest extends \PHPUnit\Framework\TestCase
{
/**
* Model object which used for tests
*
* @var ObjectManagerInterface
*/
private $objectManager;
/**
* Model object which used for tests
*
* @var Customer&\PHPUnit\Framework\MockObject\MockObject
*/
protected $_model;
/**
* @var array
*/
protected $_customerData;
/**
* @var DirectoryWrite
*/
protected $directoryWrite;
/**
* @var Processor
*/
private $indexerProcessor;
/**
* @var CsvFactory
*/
private $csvFactory;
/**
* @var WriteFactory
*/
private $writeFactory;
/**
* Create all necessary data for tests
*/
protected function setUp(): void
{
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
$this->_model = $this->objectManager->create(Customer::class);
$this->_model->setParameters(['behavior' => Import::BEHAVIOR_ADD_UPDATE]);
$this->indexerProcessor = $this->objectManager->create(\Magento\Customer\Model\Indexer\Processor::class);
$propertyAccessor = new \ReflectionProperty($this->_model, 'errorMessageTemplates');
$propertyAccessor->setAccessible(true);
$propertyAccessor->setValue($this->_model, []);
$this->_customerData = [
'firstname' => 'Firstname',
'lastname' => 'Lastname',
'group_id' => 1,
Customer::COLUMN_EMAIL => 'customer@example.com',
Customer::COLUMN_WEBSITE => 'base',
Customer::COLUMN_STORE => 'default',
'store_id' => 1,
'website_id' => 1,
'password' => 'password',
];
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
$this->directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$this->writeFactory = $this->objectManager->get(WriteFactory::class);
$this->csvFactory = $this->objectManager->get(CsvFactory::class);
}
/**
* Test importData() method
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer.php
*/
public function testImportData()
{
// 3 customers will be imported.
// 1 of this customers is already exist, but its first and last name were changed in file
$expectAddedCustomers = 5;
$source = new \Magento\ImportExport\Model\Import\Source\Csv(
__DIR__ . '/_files/customers_with_gender_to_import.csv',
$this->directoryWrite
);
$existingCustomer = $this->getCustomer('CharlesTAlston@teleworm.us', 1);
/** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
$customersCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\ResourceModel\Customer\Collection::class
);
$customersCollection->addAttributeToSelect('firstname', 'inner')->addAttributeToSelect('lastname', 'inner');
$existCustomersCount = count($customersCollection->load());
$customersCollection->resetData();
$customersCollection->clear();
$this->_model
->setParameters(['behavior' => Import::BEHAVIOR_ADD_UPDATE])
->setSource($source)
->validateData()
->hasToBeTerminated();
$this->_model->importData();
$customers = $customersCollection->getItems();
$addedCustomers = count($customers) - $existCustomersCount;
$this->assertEquals($expectAddedCustomers, $addedCustomers, 'Added unexpected amount of customers');
$updatedCustomer = $customers[$existingCustomer->getId()];
$this->assertNotEquals(
$existingCustomer->getFirstname(),
$updatedCustomer->getFirstname(),
'Firstname must be changed'
);
$this->assertNotEquals(
$existingCustomer->getLastname(),
$updatedCustomer->getLastname(),
'Lastname must be changed'
);
$this->assertNotEquals(
$existingCustomer->getCreatedAt(),
$updatedCustomer->getCreatedAt(),
'Creation date must be changed'
);
$this->assertEquals(
$existingCustomer->getGender(),
$updatedCustomer->getGender(),
'Gender must be changed'
);
}
/**
* Decompresses if gz compressed, stores in memory or temp file, and loads CSV adapter
*
* @param string $importData
* @return Import\AbstractSource
*/
private function createImportAdapter(string $importData)
{
if (0 === strncmp("\x1f\x8b", $importData, 2)) { // gz's magic string
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$importData = gzdecode($importData);
}
$openedFile = $this->writeFactory->create('php://temp', '', 'w');
$openedFile->write($importData);
unset($importData);
$directory = $this->directoryWrite;
$adapter = $this->csvFactory->create(['directory' => $directory, 'file' => $openedFile]);
return $adapter;
}
/**
* Test validateSource() and importData() and using same $ids between them
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer.php
*/
public function testValidateSourceAndImportSource()
{
/** @var Import $import */
$import = $this->objectManager->create(Import::class);
$importData = \file_get_contents(__DIR__ . '/_files/2k_customers.csv.gz');
$source = $this->createImportAdapter($importData);
unset($importData);
$import->setData([
'form_key' => 'Ded3z8XBEaMWt3sH',
'entity' => 'customer',
'behavior' => 'add_update',
'validation_strategy' => 'validation-stop-on-errors',
'allowed_error_count' => '10',
'_import_field_separator' => ',',
'_import_multiple_value_separator' => ',',
'_import_empty_attribute_value_constant' => '__EMPTY__VALUE__',
'import_images_file_dir' => '',
'_import_ids' => '',
]);
$import->validateSource($source);
$ids = $import->getValidatedIds();
$errorAggregator = $import->getErrorAggregator();
$errorStrings = [];
foreach ($errorAggregator->getAllErrors() as $error) {
$errorStrings[] = sprintf(
"Error:\nRowNumber: %s\nColumnName: %s\nCode: %s\nDescription: %s\nLevel: %s\nMessage: %s\n",
(string)$error->getRowNumber(),
$error->getColumnName(),
$error->getErrorCode(),
$error->getErrorDescription(),
$error->getErrorLevel(),
$error->getErrorMessage(),
);
}
if (!empty($errorStrings)) {
$exceptionString = sprintf(
"Errors:\n%s\n",
implode("\n", $errorStrings)
);
throw new \Exception($exceptionString);
}
$this->assertCount(20, $ids);
/** @var Import $import2 */
$import2 = $this->objectManager->create(Import::class);
$import2->setData([
'form_key' => 'DedGz8CNEaMWt3sH',
'entity' => 'customer',
'behavior' => 'add_update',
'validation_strategy' => 'validation-stop-on-errors',
'allowed_error_count' => '10',
'_import_field_separator' => ',',
'_import_multiple_value_separator' => ',',
'_import_empty_attribute_value_constant' => '__EMPTY__VALUE__',
'import_images_file_dir' => '',
'_import_ids' => implode(',', $ids),
]);
$this->assertEmpty($import2->getValidatedIds());
$import2->importSource();
$createdItemsCount = $import2->getCreatedItemsCount();
$this->assertEquals(2000, $createdItemsCount);
}
/**
* Tests importData() method.
*
* @magentoDataFixture Magento/Customer/_files/import_export/customer.php
*
* @return void
*/
public function testImportDataWithOneAdditionalColumn(): void
{
$source = new \Magento\ImportExport\Model\Import\Source\Csv(
__DIR__ . '/_files/customer_to_import_with_one_additional_column.csv',
$this->directoryWrite
);
$existingCustomer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\Customer::class
);
$existingCustomer->setWebsiteId(1);
$existingCustomer = $existingCustomer->loadByEmail('CharlesTAlston@teleworm.us');
/** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
$customersCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\ResourceModel\Customer\Collection::class
);
$customersCollection->resetData();
$customersCollection->clear();
$this->_model
->setParameters(['behavior' => Import::BEHAVIOR_ADD_UPDATE])
->setSource($source)
->validateData()
->hasToBeTerminated();
sleep(1);
$this->_model->importData();
$customers = $customersCollection->getItems();
$updatedCustomer = $customers[$existingCustomer->getId()];
$this->assertNotEquals(
$existingCustomer->getFirstname(),
$updatedCustomer->getFirstname(),
'Firstname must be changed'
);
$this->assertNotEquals(
$existingCustomer->getUpdatedAt(),
$updatedCustomer->getUpdatedAt(),
'Updated at date must be changed'
);
$this->assertEquals(
$existingCustomer->getLastname(),
$updatedCustomer->getLastname(),
'Lastname must not be changed'
);
$this->assertEquals(
$existingCustomer->getStoreId(),
$updatedCustomer->getStoreId(),
'Store Id must not be changed'
);
$this->assertEquals(
$existingCustomer->getCreatedAt(),
$updatedCustomer->getCreatedAt(),
'Creation date must not be changed'
);
$this->assertEquals(
$existingCustomer->getGroupId(),
$updatedCustomer->getGroupId(),
'Customer group must not be changed'
);
}
/**
* Test importData() method (delete behavior)
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
*/
public function testDeleteData()
{
\Magento\TestFramework\Helper\Bootstrap::getInstance()
->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
$source = new \Magento\ImportExport\Model\Import\Source\Csv(
__DIR__ . '/_files/customers_to_delete.csv',
$this->directoryWrite
);
/** @var $customerCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */
$customerCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Customer\Model\ResourceModel\Customer\Collection::class
);
$this->assertEquals(3, $customerCollection->count(), 'Count of existing customers are invalid');
$this->_model->setParameters(['behavior' => Import::BEHAVIOR_DELETE])
->setSource($source)
->validateData();
$this->_model->importData();
$customerCollection->resetData();
$customerCollection->clear();
$this->assertEmpty($customerCollection->count(), 'Customers were not imported');
}
public function testGetEntityTypeCode()
{
$this->assertEquals('customer', $this->_model->getEntityTypeCode());
}
public function testValidateRowDuplicateEmail()
{
$this->_model->getErrorAggregator()->clear();
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(0, $this->_model->getErrorAggregator()->getErrorsCount());
$this->_customerData[Customer::COLUMN_EMAIL] = strtoupper(
$this->_customerData[Customer::COLUMN_EMAIL]
);
$this->_model->validateRow($this->_customerData, 1);
$this->assertEquals(1, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_DUPLICATE_EMAIL_SITE])
);
}
public function testValidateRowInvalidEmail()
{
$this->_model->getErrorAggregator()->clear();
$this->_customerData[Customer::COLUMN_EMAIL] = 'wrong_email@format';
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(1, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_INVALID_EMAIL])
);
}
public function testValidateRowInvalidWebsite()
{
$this->_model->getErrorAggregator()->clear();
$this->_customerData[Customer::COLUMN_WEBSITE] = 'not_existing_web_site';
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(1, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_INVALID_WEBSITE])
);
}
public function testValidateRowInvalidStore()
{
$this->_model->getErrorAggregator()->clear();
$this->_customerData[Customer::COLUMN_STORE] = 'not_existing_web_store';
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(1, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_INVALID_STORE])
);
}
public function testValidateRowPasswordLengthIncorrect()
{
$this->_model->getErrorAggregator()->clear();
$this->_customerData['password'] = '12345';
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(1, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_PASSWORD_LENGTH])
);
}
public function testValidateRowPasswordLengthCorrect()
{
$this->_model->getErrorAggregator()->clear();
$this->_customerData['password'] = '1234567890';
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(0, $this->_model->getErrorAggregator()->getErrorsCount());
}
/**
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
*/
public function testValidateRowAttributeRequired()
{
$this->_model->getErrorAggregator()->clear();
unset($this->_customerData['firstname']);
unset($this->_customerData['lastname']);
unset($this->_customerData['group_id']);
$this->_model->validateRow($this->_customerData, 0);
$this->assertEquals(0, $this->_model->getErrorAggregator()->getErrorsCount());
$this->_customerData[Customer::COLUMN_EMAIL] = 'new.customer@example.com';
$this->_model->validateRow($this->_customerData, 1);
$this->assertGreaterThan(0, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_VALUE_IS_REQUIRED])
);
}
public function testValidateEmailForDeleteBehavior()
{
$this->_model->getErrorAggregator()->clear();
$this->_customerData[Customer::COLUMN_EMAIL] = 'new.customer@example.com';
$this->_model->setParameters(['behavior' => Import::BEHAVIOR_DELETE]);
$this->_model->validateRow($this->_customerData, 0);
$this->assertGreaterThan(0, $this->_model->getErrorAggregator()->getErrorsCount());
$this->assertNotEmpty(
$this->_model->getErrorAggregator()->getErrorsByCode([Customer::ERROR_CUSTOMER_NOT_FOUND])
);
}
/**
* Test import existing customers
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
* @return void
*/
public function testUpdateExistingCustomers(): void
{
$this->doImport(__DIR__ . '/_files/customers_to_update.csv', Import::BEHAVIOR_ADD_UPDATE);
$customer = $this->getCustomer('customer@example.com', 1);
$this->assertEquals('Firstname-updated', $customer->getFirstname());
$this->assertEquals('Lastname-updated', $customer->getLastname());
$this->assertEquals(1, $customer->getStoreId());
$customer = $this->getCustomer('julie.worrell@example.com', 1);
$this->assertEquals('Julie-updated', $customer->getFirstname());
$this->assertEquals('Worrell-updated', $customer->getLastname());
$this->assertEquals(1, $customer->getStoreId());
$customer = $this->getCustomer('david.lamar@example.com', 1);
$this->assertEquals('David-updated', $customer->getFirstname());
$this->assertEquals('Lamar-updated', $customer->getLastname());
$this->assertEquals(1, $customer->getStoreId());
}
/**
* Test customer indexer gets invalidated after import when Update on Schedule mode is set
*
* @magentoDbIsolation enabled
* @return void
*/
public function testCustomerIndexer(): void
{
$this->indexerProcessor->getIndexer()->reindexAll();
$statusBeforeImport = $this->indexerProcessor->getIndexer()->getStatus();
$this->indexerProcessor->getIndexer()->setScheduled(true);
$this->doImport(__DIR__ . '/_files/customers_with_gender_to_import.csv', Import::BEHAVIOR_ADD_UPDATE);
$statusAfterImport = $this->indexerProcessor->getIndexer()->getStatus();
$this->assertEquals(StateInterface::STATUS_VALID, $statusBeforeImport);
$this->assertEquals(StateInterface::STATUS_INVALID, $statusAfterImport);
}
/**
* Gets customer entity.
*
* @param string $email
* @param int $websiteId
* @return CustomerInterface
* @throws NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function getCustomer(string $email, int $websiteId): CustomerInterface
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var CustomerRepositoryInterface $repository */
$repository = $objectManager->get(CustomerRepositoryInterface::class);
return $repository->get($email, $websiteId);
}
/**
* Import using given file and behavior
*
* @param string $file
* @param string $behavior
*/
private function doImport(string $file, string $behavior): void
{
$source = new \Magento\ImportExport\Model\Import\Source\Csv($file, $this->directoryWrite);
$this->_model
->setParameters(['behavior' => $behavior])
->setSource($source)
->validateData()
->hasToBeTerminated();
$this->_model->importData();
}
}
@@ -0,0 +1,2 @@
"_website","_email","_entity_id"
"admin","BetsyParker@example.com",1
1 _website _email _entity_id
2 admin BetsyParker@example.com 1
@@ -0,0 +1,5 @@
"_website","_email","_entity_id","city","company","country_id","fax","firstname","lastname","middlename","postcode","prefix","region","region_id","street","suffix","telephone","vat_id","vat_is_valid","vat_request_date","vat_request_id","vat_request_success","_address_default_billing_","_address_default_shipping_"
"admin","BetsyParker@example.com",1,,,"US",,"Katy","Parker","T.",19107,,,,"1079 Rocky Road",,"215-629-9720",,,,,,,1
"admin","BetsyParker@example.com",3,"Phoenix",,"US",,"Brad","Brown","H.",85034,,"Arizona",4,"4225 Martha Street",,"928-707-1577",,,,,,1,
"admin","BetsyParker@example.com",,"Tallahassee",,"US",,"William ","Compton","M.",32301,,"Florida",18,"1973 Drainer Avenue",,"850-590-7403",,,,,,,
"admin","BetsyParker@example.com",,"Tallahassee",,"UA",,"An ","Compton","M.",32301,,,18,"1973 Drainer Avenue",,"850-590-7403",,,,,,,
1 _website _email _entity_id city company country_id fax firstname lastname middlename postcode prefix region region_id street suffix telephone vat_id vat_is_valid vat_request_date vat_request_id vat_request_success _address_default_billing_ _address_default_shipping_
2 admin BetsyParker@example.com 1 US Katy Parker T. 19107 1079 Rocky Road 215-629-9720 1
3 admin BetsyParker@example.com 3 Phoenix US Brad Brown H. 85034 Arizona 4 4225 Martha Street 928-707-1577 1
4 admin BetsyParker@example.com Tallahassee US William Compton M. 32301 Florida 18 1973 Drainer Avenue 850-590-7403
5 admin BetsyParker@example.com Tallahassee UA An Compton M. 32301 18 1973 Drainer Avenue 850-590-7403
@@ -0,0 +1,2 @@
"email","_website","_store"
"BetsyParker@example.com","admin","admin"
1 email _website _store
2 BetsyParker@example.com admin admin
@@ -0,0 +1,6 @@
"email","_website","_store","confirmation","created_at","created_in","disable_auto_group_change","dob","firstname","gender","group_id","lastname","middlename","password_hash","prefix","rp_token","rp_token_created_at","store_id","suffix","taxvat","website_id","password","_address_city","_address_company","_address_country_id","_address_fax","_address_firstname","_address_lastname","_address_middlename","_address_postcode","_address_prefix","_address_region","_address_street","_address_suffix","_address_telephone","_address_vat_id","_address_default_billing_","_address_default_shipping_"
"AnthonyANealy@magento.com","base","admin",,"05/06/2012 15:53","Admin",0,,"Anthony","Male",1,"Nealy","A.","6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF",,,,0,,,1,,"Fayetteville",,"US",,"Anthony","Nealy",,72701,,"Arkansas","3176 Cambridge Court",,"479-899-9849",,1,1
,,,,,,,,,,,,,,,,,,,,,,"Irvine",,"US",,"Anthony","Nealy",,92664,,"California","4709 Pleasant Hill Road",,"562-208-2310",,,
"LoriBBanks@magento.com","admin","admin",,"05/06/2012 15:59","Admin",0,,"Lori","Female",1,"Banks","B.","7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz",,,,0,,,0,,"Wenatchee",,"US",,"Lori","Banks",,98801,,"Washington","2573 Goodwin Avenue",,"509-421-4364",,1,1
"BetsyParker@example.com","admin","admin",,"05/06/2012 16:13","Admin",0,,"NotBetsy","Female",1,"NotParker","H.","145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1",,,,0,,,2,,"Philadelphia",,"US",,"Betsy","Parker",,19108,,"Pennsylvania","1079 Rocky Road 1079 Rocky Road 2",,"215-629-9720",,1,1
"KellyNIlson@magento.com","base","admin",,"05/06/2012 17:11","Admin",0,,"Kelly","Female",1,"Nilson","H.","145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1",,,,0,,,2,,,,,,,,,,,,,,,,,
1 email _website _store confirmation created_at created_in disable_auto_group_change dob firstname gender group_id lastname middlename password_hash prefix rp_token rp_token_created_at store_id suffix taxvat website_id password _address_city _address_company _address_country_id _address_fax _address_firstname _address_lastname _address_middlename _address_postcode _address_prefix _address_region _address_street _address_suffix _address_telephone _address_vat_id _address_default_billing_ _address_default_shipping_
2 AnthonyANealy@magento.com base admin 05/06/2012 15:53 Admin 0 Anthony Male 1 Nealy A. 6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF 0 1 Fayetteville US Anthony Nealy 72701 Arkansas 3176 Cambridge Court 479-899-9849 1 1
3 Irvine US Anthony Nealy 92664 California 4709 Pleasant Hill Road 562-208-2310
4 LoriBBanks@magento.com admin admin 05/06/2012 15:59 Admin 0 Lori Female 1 Banks B. 7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz 0 0 Wenatchee US Lori Banks 98801 Washington 2573 Goodwin Avenue 509-421-4364 1 1
5 BetsyParker@example.com admin admin 05/06/2012 16:13 Admin 0 NotBetsy Female 1 NotParker H. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2 Philadelphia US Betsy Parker 19108 Pennsylvania 1079 Rocky Road 1079 Rocky Road 2 215-629-9720 1 1
6 KellyNIlson@magento.com base admin 05/06/2012 17:11 Admin 0 Kelly Female 1 Nilson H. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
@@ -0,0 +1,2 @@
email,_website,firstname
CharlesTAlston@teleworm.us,base,Jhon
1 email _website firstname
2 CharlesTAlston@teleworm.us base Jhon
@@ -0,0 +1,4 @@
email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password
customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Male,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,Male,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
1 email _website _store confirmation created_at created_in default_billing default_shipping disable_auto_group_change dob firstname gender group_id lastname middlename password_hash prefix rp_token rp_token_created_at store_id suffix taxvat website_id password
2 customer@example.com base admin 5/6/2012 16:15 Admin 4 4 0 Firstname Male 1 Lastname T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
3 julie.worrell@example.com base admin 5/6/2012 16:19 Admin 4 4 0 Julie Female 1 Worrell T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
4 david.lamar@example.com base admin 5/6/2012 16:25 Admin 4 4 0 David Male 1 Lamar T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
@@ -0,0 +1,7 @@
email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password
AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Male,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1,
LoriBBanks@magento.com,admin,admin,,5/6/2012 15:59,Admin,3,3,0,5/6/2010,Lori,Female,1,Banks,B.,7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz,,,,0,,,0,
CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,0,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Male,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
1 email _website _store confirmation created_at created_in default_billing default_shipping disable_auto_group_change dob firstname gender group_id lastname middlename password_hash prefix rp_token rp_token_created_at store_id suffix taxvat website_id password
2 AnthonyANealy@magento.com base admin 5/6/2012 15:53 Admin 1 1 0 5/6/2010 Anthony Male 1 Nealy A. 6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF 0 1
3 LoriBBanks@magento.com admin admin 5/6/2012 15:59 Admin 3 3 0 5/6/2010 Lori Female 1 Banks B. 7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz 0 0
4 CharlesTAlston@teleworm.us base admin 5/6/2012 16:13 Admin 4 4 0 Jhon Female 1 Doe T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
5 customer@example.com base admin 5/6/2012 16:15 Admin 4 4 0 Firstname Male 1 Lastname T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
6 julie.worrell@example.com base admin 5/6/2012 16:19 Admin 4 4 0 Julie Female 1 Worrell T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
7 david.lamar@example.com base admin 5/6/2012 16:25 Admin 4 4 0 David 1 Lamar T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
@@ -0,0 +1,4 @@
email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password
customer@example.com,base,"default",,5/6/2012 16:15,Admin,"1","1",0,,"Firstname-updated",Male,1,"Lastname-updated",T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,"1",
julie.worrell@example.com,base,"",,5/6/2012 16:19,Admin,"1","1",0,,"Julie-updated",Female,1,"Worrell-updated",T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,"1",
david.lamar@example.com,base,"",,5/6/2012 16:25,Admin,"1","1",0,,"David-updated",Male,1,"Lamar-updated",T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,"1",
1 email _website _store confirmation created_at created_in default_billing default_shipping disable_auto_group_change dob firstname gender group_id lastname middlename password_hash prefix rp_token rp_token_created_at store_id suffix taxvat website_id password
2 customer@example.com base default 5/6/2012 16:15 Admin 1 1 0 Firstname-updated Male 1 Lastname-updated T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 1
3 julie.worrell@example.com base 5/6/2012 16:19 Admin 1 1 0 Julie-updated Female 1 Worrell-updated T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 1
4 david.lamar@example.com base 5/6/2012 16:25 Admin 1 1 0 David-updated Male 1 Lamar-updated T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 1
@@ -0,0 +1,7 @@
email,_website,_store,confirmation,created_at,created_in,default_billing,default_shipping,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password
AnthonyANealy@magento.com,base,admin,,5/6/2012 15:53,Admin,1,1,0,5/6/2010,Anthony,Female,1,Nealy,A.,6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF,,,,0,,,1,
LoriBBanks@magento.com,admin,admin,,5/6/2012 15:59,Admin,3,3,0,5/6/2010,Lori,Female,1,Banks,B.,7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz,,,,0,,,0,
CharlesTAlston@teleworm.us,base,admin,,5/6/2012 16:13,Admin,4,4,0,,Jhon,Female,1,Doe,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
customer@example.com,base,admin,,5/6/2012 16:15,Admin,4,4,0,,Firstname,Female,1,Lastname,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
julie.worrell@example.com,base,admin,,5/6/2012 16:19,Admin,4,4,0,,Julie,Female,1,Worrell,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
david.lamar@example.com,base,admin,,5/6/2012 16:25,Admin,4,4,0,,David,,1,Lamar,T.,145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1,,,,0,,,2,
1 email _website _store confirmation created_at created_in default_billing default_shipping disable_auto_group_change dob firstname gender group_id lastname middlename password_hash prefix rp_token rp_token_created_at store_id suffix taxvat website_id password
2 AnthonyANealy@magento.com base admin 5/6/2012 15:53 Admin 1 1 0 5/6/2010 Anthony Female 1 Nealy A. 6a9c9bfb2ba88a6ad2a64e7402df44a763e0c48cd21d7af9e7e796cd4677ee28:RF 0 1
3 LoriBBanks@magento.com admin admin 5/6/2012 15:59 Admin 3 3 0 5/6/2010 Lori Female 1 Banks B. 7ad6dbdc83d3e9f598825dc58b84678c7351e4281f6bc2b277a32dcd88b9756b:pz 0 0
4 CharlesTAlston@teleworm.us base admin 5/6/2012 16:13 Admin 4 4 0 Jhon Female 1 Doe T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
5 customer@example.com base admin 5/6/2012 16:15 Admin 4 4 0 Firstname Female 1 Lastname T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
6 julie.worrell@example.com base admin 5/6/2012 16:19 Admin 4 4 0 Julie Female 1 Worrell T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
7 david.lamar@example.com base admin 5/6/2012 16:25 Admin 4 4 0 David 1 Lamar T. 145d12bfff8a6a279eb61e277e3d727c0ba95acc1131237f1594ddbb7687a564:l1 0 2
@@ -0,0 +1,2 @@
_website,_email,_entity_id,city,company,country_id,fax,firstname,lastname,middlename,postcode,prefix,region,region_id,street,suffix,telephone,vat_id,vat_is_valid,vat_request_date,vat_request_id,vat_request_success,_address_default_billing_,_address_default_shipping_
base,"BetsyParker@example.com",,Liverpool,,GB,,Mike,Miller,,"L2 2AY",,"Liverpool",0,"Moorfields, Vernon St",," +443450507080",,,,,,,
1 _website _email _entity_id city company country_id fax firstname lastname middlename postcode prefix region region_id street suffix telephone vat_id vat_is_valid vat_request_date vat_request_id vat_request_success _address_default_billing_ _address_default_shipping_
2 base BetsyParker@example.com Liverpool GB Mike Miller L2 2AY Liverpool 0 Moorfields, Vernon St +443450507080
@@ -0,0 +1,3 @@
"_website","_email","_entity_id","city","company","country_id","fax","firstname","lastname","middlename","postcode","prefix","region","region_id","street","suffix","telephone","vat_id","vat_is_valid","vat_request_date","vat_request_id","vat_request_success","_address_default_billing_","_address_default_shipping_"
"base","customer@example.com",1,"Montgivray",,"FR",,"John","Smith",,36400,,"Paris",257,"1 Avenue du Lion d'Argent",,"33254060414",,,,,,1,1
"test","customer2@example.com",2,"Madrid",,"ES",,"First","Last",,28045,,"Madrid",161,"Calle de Méndez Álvaro, 72",,"34912759224",,,,,,1,1
1 _website _email _entity_id city company country_id fax firstname lastname middlename postcode prefix region region_id street suffix telephone vat_id vat_is_valid vat_request_date vat_request_id vat_request_success _address_default_billing_ _address_default_shipping_
2 base customer@example.com 1 Montgivray FR John Smith 36400 Paris 257 1 Avenue du Lion d'Argent 33254060414 1 1
3 test customer2@example.com 2 Madrid ES First Last 28045 Madrid 161 Calle de Méndez Álvaro, 72 34912759224 1 1