/** * Test for method filterEntityCollection() * * @magentoDataFixture Mage/ImportExport/_files/customers.php */ public function testFilterEntityCollection() { $createdAtDate = '2038-01-01'; /** * Change created_at date of first customer for future filter test. */ $customers = Mage::registry('_fixture/Mage_ImportExport_Customer_Collection'); $customers[0]->setCreatedAt($createdAtDate); $customers[0]->save(); /** * Change type of created_at attribute. In this case we have possibility to test date rage filter */ $attributeCollection = Mage::getResourceModel('Mage_Customer_Model_Resource_Attribute_Collection'); $attributeCollection->addFieldToFilter('attribute_code', 'created_at'); /** @var $createdAtAttribute Mage_Customer_Model_Attribute */ $createdAtAttribute = $attributeCollection->getFirstItem(); $createdAtAttribute->setBackendType('datetime'); $createdAtAttribute->save(); /** * Prepare filter.asd */ $parameters = array(Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP => array('email' => 'example.com', 'created_at' => array($createdAtDate, ''), 'store_id' => Mage::app()->getStore()->getId())); $this->_model->setParameters($parameters); /** @var $customers Mage_Customer_Model_Resource_Customer_Collection */ $collection = $this->_model->filterEntityCollection(Mage::getResourceModel('Mage_Customer_Model_Resource_Customer_Collection')); $collection->load(); $this->assertCount(1, $collection); $this->assertEquals($customers[0]->getId(), $collection->getFirstItem()->getId()); }
/** * Test for method exportItem() * * @covers Mage_ImportExport_Model_Export_Entity_Eav_Customer::exportItem */ public function testExportItem() { $writer = $this->getMockForAbstractClass('Mage_ImportExport_Model_Export_Adapter_Abstract', array(), '', false, false, true, array('writeRow')); $writer->expects($this->once())->method('writeRow')->will($this->returnCallback(array($this, 'validateWriteRow'))); $this->_model->setWriter($writer); $item = $this->getMockForAbstractClass('Mage_Core_Model_Abstract', array($this->_customerData)); $this->_model->exportItem($item); }
/** * Test for method exportItem() * * @covers Mage_ImportExport_Model_Export_Entity_Eav_Customer::exportItem */ public function testExportItem() { /** @var $writer Mage_ImportExport_Model_Export_Adapter_Abstract */ $writer = $this->getMockForAbstractClass('Mage_ImportExport_Model_Export_Adapter_Abstract', array(), '', false, false, true, array('writeRow')); $writer->expects($this->once())->method('writeRow')->will($this->returnCallback(array($this, 'validateWriteRow'))); $this->_model->setWriter($writer); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $arguments = $objectManagerHelper->getConstructArguments(Magento_Test_Helper_ObjectManager::MODEL_ENTITY, 'Mage_Core_Model_Abstract'); $arguments['data'] = $this->_customerData; $item = $this->getMockForAbstractClass('Mage_Core_Model_Abstract', $arguments); $this->_model->exportItem($item); }
/** * Set parameters (push filters from post into export customer model) * * @param array $parameters * @return Mage_ImportExport_Model_Export_Entity_Eav_Customer_Address */ public function setParameters(array $parameters) { // push filters from post into export customer model $this->_customerEntity->setParameters($parameters); $this->_initCustomers(); return parent::setParameters($parameters); }