Пример #1
0
 /**
  * Test import data method with delete behaviour
  *
  * @magentoDataFixture Mage/ImportExport/_files/customers_for_address_import.php
  * @covers Mage_ImportExport_Model_Import_Entity_Eav_Customer_Address::_importData
  */
 public function testImportDataDelete()
 {
     // set behaviour
     $this->_entityAdapter->setParameters(array('behavior' => Mage_ImportExport_Model_Import::BEHAVIOR_DELETE));
     // set fixture CSV file
     $sourceFile = __DIR__ . '/../_files/address_import_delete.csv';
     $result = $this->_entityAdapter->setSource(Mage_ImportExport_Model_Import_Adapter::findAdapterFor($sourceFile))->isDataValid();
     $this->assertTrue($result, 'Validation result must be true.');
     // import data
     $this->_entityAdapter->importData();
     // key attribute
     $keyAttribute = 'postcode';
     // get addresses
     /** @var $addressCollection Mage_Customer_Model_Resource_Address_Collection */
     $addressCollection = Mage::getResourceModel('Mage_Customer_Model_Resource_Address_Collection');
     $addressCollection->addAttributeToSelect($keyAttribute);
     $addresses = array();
     /** @var $address Mage_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.');
 }
Пример #2
0
 /**
  * Test if correct methods are invoked according to different custom behaviours
  *
  * @covers Mage_ImportExport_Model_Import_Entity_Eav_Customer_Address::_importData
  */
 public function testImportDataWithCustomBehaviour()
 {
     $this->_model = $this->_getModelMockForTestImportDataWithCustomBehaviour();
     $this->_model->setParameters(array('behavior' => Mage_ImportExport_Model_Import::BEHAVIOR_CUSTOM));
     // validation in validateSaveAddressEntities and validateDeleteAddressEntities
     $this->_model->importData();
 }
Пример #3
0
 /**
  * Import data rows
  *
  * @return boolean
  */
 protected function _importData()
 {
     $result = $this->_customerEntity->importData();
     if ($this->getBehavior() != Mage_ImportExport_Model_Import::BEHAVIOR_DELETE) {
         return $result && $this->_addressEntity->importData();
     }
     return $result;
 }