/** * Create source adapter mock and set it into model object which tested in this class * * @param array $columns value which will be returned by method getColNames() * @return \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject */ protected function _createSourceAdapterMock(array $columns) { /** @var $source \Magento\ImportExport\Model\Import\AbstractSource|\PHPUnit_Framework_MockObject_MockObject */ $source = $this->getMockForAbstractClass('Magento\\ImportExport\\Model\\Import\\AbstractSource', [], '', false, true, true, ['getColNames']); $source->expects($this->any())->method('getColNames')->will($this->returnValue($columns)); $this->_model->setSource($source); return $source; }
/** * @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 array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @throws \Magento\Framework\Exception\LocalizedException */ 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, array $data = []) { parent::__construct($string, $scopeConfig, $importFactory, $resourceHelper, $resource, $errorAggregator, $data); $this->_storeManager = $storeManager; $this->_attributeCollection = isset($data['attribute_collection']) ? $data['attribute_collection'] : $collectionFactory->create(static::ATTRIBUTE_COLLECTION_NAME); if (isset($data['entity_type_id'])) { $this->_entityTypeId = $data['entity_type_id']; } else { $this->_entityTypeId = $eavConfig->getEntityType($this->getEntityTypeCode())->getEntityTypeId(); } }
/** * Prepare validated row data for saving to db * * @param array $rowData * @return array */ protected function _prepareRowForDb(array $rowData) { $rowData['_scope'] = $this->_getRowScope($rowData); $rowData[Address::COLUMN_WEBSITE] = $this->_currentWebsiteCode; $rowData[Address::COLUMN_EMAIL] = $this->_currentEmail; $rowData[Address::COLUMN_ADDRESS_ID] = null; return parent::_prepareRowForDb($rowData); }