/** * Test whether correct methods are invoked in case of custom behaviour for each row in action column */ public function testImportDataWithCustomBehaviour() { $this->_model = $this->_getModelMockForTestImportDataWithCustomBehaviour(); $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_CUSTOM]); // validation in validateSaveCustomerEntities and validateDeleteCustomerEntities $this->_model->importData(); }
/** * Import data rows * * @return bool */ protected function _importData() { $result = $this->_customerEntity->importData(); if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE) { return $result && $this->_addressEntity->importData(); } return $result; }
/** * 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_import.csv', $this->directoryWrite); /** @var $customerCollection \Magento\Customer\Model\Resource\Customer\Collection */ $customerCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Resource\\Customer\\Collection'); $this->assertEquals(3, $customerCollection->count(), 'Count of existing customers are invalid'); $this->_model->setParameters(['behavior' => Import::BEHAVIOR_DELETE])->setSource($source)->isDataValid(); $this->_model->importData(); $customerCollection->resetData(); $customerCollection->clear(); $this->assertEmpty($customerCollection->count(), 'Customers were not imported'); }