/** * Test export method * * @magentoDataFixture Mage/ImportExport/_files/customers.php */ public function testExport() { $expectedAttributes = array(); /** @var $collection Mage_Customer_Model_Resource_Attribute_Collection */ $collection = Mage::getResourceModel('Mage_Customer_Model_Resource_Attribute_Collection'); /** @var $attribute Mage_Customer_Model_Attribute */ foreach ($collection as $attribute) { $expectedAttributes[] = $attribute->getAttributeCode(); } $this->_model->setWriter(Mage::getModel('Mage_ImportExport_Model_Export_Adapter_Csv')); $data = $this->_model->export(); $this->assertNotEmpty($data); $lines = $this->_csvToArray($data, 'email'); $this->assertEquals(count($expectedAttributes), count(array_intersect($expectedAttributes, $lines['header'])), 'Expected attribute codes were not exported'); $this->assertNotEmpty($data['data'], 'No data was exported'); /** @var $customers Mage_Customer_Model_Customer[] */ $customers = Mage::registry('_fixture/Mage_ImportExport_Customer_Collection'); foreach ($customers as $key => $customer) { foreach ($expectedAttributes as $code) { if (!in_array($code, $this->_model->getDisabledAttributes()) && isset($lines[$key][$code])) { $this->assertEquals($customer->getData($code), $lines[$key][$code], 'Attribute "' . $code . '" is not equal'); } } } }