Пример #1
0
 /**
  * Test if correct methods are invoked according to different custom behaviours
  *
  * @covers \Magento\CustomerImportExport\Model\Import\Address::_importData
  */
 public function testImportDataWithCustomBehaviour()
 {
     $this->_model = $this->_getModelMockForTestImportDataWithCustomBehaviour();
     $this->_model->setParameters(['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_CUSTOM]);
     // validation in validateSaveAddressEntities and validateDeleteAddressEntities
     $this->_model->importData();
 }
Пример #2
0
 /**
  * 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' => \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE]);
     // set fixture CSV file
     $sourceFile = __DIR__ . '/_files/address_import_delete.csv';
     /** @var $objectManager \Magento\TestFramework\ObjectManager */
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $filesystem = $objectManager->create('Magento\\Framework\\Filesystem');
     $directoryWrite = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
     $result = $this->_entityAdapter->setSource(\Magento\ImportExport\Model\Import\Adapter::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 \Magento\Customer\Model\ResourceModel\Address\Collection */
     $addressCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\ResourceModel\\Address\\Collection');
     $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.');
 }
Пример #3
0
 /**
  * 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;
 }