public function testValidateRowForDelete() { // _validateRowForDelete should be called only once $this->_model->expects($this->once())->method('_validateRowForDelete'); // delete action $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE]); $this->_clearValidatedRows(); $this->assertAttributeEquals([], '_validatedRows', $this->_model); $this->assertTrue($this->_model->validateRow([], 2)); $this->assertAttributeEquals([2 => true], '_validatedRows', $this->_model); $this->assertAttributeEquals(1, '_processedEntitiesCount', $this->_model); $this->assertTrue($this->_model->validateRow([], 2)); }
/** * @param \Magento\Framework\Stdlib\StringUtils $string * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\App\ResourceConnection $resource * @param ProcessingErrorAggregatorInterface $errorAggregator * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\StorageFactory $storageFactory * @param \Magento\Customer\Model\AddressFactory $addressFactory * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionColFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\ResourceModel\Address\CollectionFactory $addressColFactory * @param \Magento\Customer\Model\ResourceModel\Address\Attribute\CollectionFactory $attributesFactory * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param array $data * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\Stdlib\StringUtils $string, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\App\ResourceConnection $resource, ProcessingErrorAggregatorInterface $errorAggregator, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\StorageFactory $storageFactory, \Magento\Customer\Model\AddressFactory $addressFactory, \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionColFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\ResourceModel\Address\CollectionFactory $addressColFactory, \Magento\Customer\Model\ResourceModel\Address\Attribute\CollectionFactory $attributesFactory, \Magento\Framework\Stdlib\DateTime $dateTime, array $data = []) { $this->_customerFactory = $customerFactory; $this->_addressFactory = $addressFactory; $this->_eavConfig = $eavConfig; $this->_resourceHelper = $resourceHelper; $this->dateTime = $dateTime; if (!isset($data['attribute_collection'])) { /** @var $attributeCollection \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection */ $attributeCollection = $attributesFactory->create(); $attributeCollection->addSystemHiddenFilter()->addExcludeHiddenFrontendFilter(); $data['attribute_collection'] = $attributeCollection; } parent::__construct($string, $scopeConfig, $importFactory, $resourceHelper, $resource, $errorAggregator, $storeManager, $collectionFactory, $eavConfig, $storageFactory, $data); $this->_addressCollection = isset($data['address_collection']) ? $data['address_collection'] : $addressColFactory->create(); $this->_entityTable = isset($data['entity_table']) ? $data['entity_table'] : $addressFactory->create()->getResource()->getEntityTable(); $this->_regionCollection = isset($data['region_collection']) ? $data['region_collection'] : $regionColFactory->create(); $this->addMessageTemplate(self::ERROR_ADDRESS_ID_IS_EMPTY, __('Customer address id column is not specified')); $this->addMessageTemplate(self::ERROR_ADDRESS_NOT_FOUND, __('We can\'t find that customer address.')); $this->addMessageTemplate(self::ERROR_INVALID_REGION, __('Please enter a valid region.')); $this->addMessageTemplate(self::ERROR_DUPLICATE_PK, __('We found another row with this email, website and address ID combination.')); $this->_initAttributes(); $this->_initAddresses()->_initCountryRegions(); }
/** * @param \Magento\Framework\Stdlib\StringUtils $string * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\App\ResourceConnection $resource * @param ProcessingErrorAggregatorInterface $errorAggregator * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\StorageFactory $storageFactory * @param \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attrCollectionFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\Stdlib\StringUtils $string, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\App\ResourceConnection $resource, ProcessingErrorAggregatorInterface $errorAggregator, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\StorageFactory $storageFactory, \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $attrCollectionFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, array $data = []) { $this->_resourceHelper = $resourceHelper; if (isset($data['attribute_collection'])) { $this->_attributeCollection = $data['attribute_collection']; unset($data['attribute_collection']); } else { $this->_attributeCollection = $attrCollectionFactory->create(); $this->_attributeCollection->addSystemHiddenFilterWithPasswordHash(); $data['attribute_collection'] = $this->_attributeCollection; } parent::__construct($string, $scopeConfig, $importFactory, $resourceHelper, $resource, $errorAggregator, $storeManager, $collectionFactory, $eavConfig, $storageFactory, $data); $this->_specialAttributes[] = self::COLUMN_WEBSITE; $this->_specialAttributes[] = self::COLUMN_STORE; $this->_permanentAttributes[] = self::COLUMN_EMAIL; $this->_permanentAttributes[] = self::COLUMN_WEBSITE; $this->_indexValueAttributes[] = 'group_id'; $this->addMessageTemplate(self::ERROR_DUPLICATE_EMAIL_SITE, __('This email is found more than once in the import file.')); $this->addMessageTemplate(self::ERROR_ROW_IS_ORPHAN, __('Orphan rows that will be skipped due default row errors')); $this->addMessageTemplate(self::ERROR_INVALID_STORE, __('Invalid value in Store column (store does not exists?)')); $this->addMessageTemplate(self::ERROR_EMAIL_SITE_NOT_FOUND, __('We can\'t find that email and website combination.')); $this->addMessageTemplate(self::ERROR_PASSWORD_LENGTH, __('Please enter a password with a valid length.')); $this->_initStores(true)->_initAttributes(); $this->_customerModel = $customerFactory->create(); /** @var $customerResource \Magento\Customer\Model\ResourceModel\Customer */ $customerResource = $this->_customerModel->getResource(); $this->_entityTable = $customerResource->getEntityTable(); }