Example #1
0
 /**
  * Retrieve all necessary objects mocks which used inside customer storage
  *
  * @return array
  */
 protected function _getModelDependencies()
 {
     $select = $this->getMock('Varien_Db_Select', array('from'), array(), '', false);
     $select->expects($this->any())->method('from')->will($this->returnCallback(array($this, 'validateFrom')));
     $customerCollection = $this->getMock('Mage_Customer_Model_Resource_Customer_Collection', array('load', 'removeAttributeToSelect', 'getResource', 'getSelect'), array(), '', false);
     $resourceStub = new Varien_Object();
     $resourceStub->setEntityTable($this->_entityTable);
     $customerCollection->expects($this->once())->method('getResource')->will($this->returnValue($resourceStub));
     $customerCollection->expects($this->once())->method('getSelect')->will($this->returnValue($select));
     $byPagesIterator = $this->getMock('stdClass', array('iterate'));
     $byPagesIterator->expects($this->once())->method('iterate')->will($this->returnCallback(array($this, 'iterate')));
     return array('customer_collection' => $customerCollection, 'collection_by_pages_iterator' => $byPagesIterator, 'page_size' => 10);
 }
Example #2
0
 public function testWalkAttributes()
 {
     $code = 'test_attr';
     $set = 10;
     $object = $this->getMock('Mage_Catalog_Model_Product', null, array(), '', false);
     $object->setData(array('test_attr' => 'test_attr', 'attribute_set_id' => $set));
     $entityType = new Varien_Object();
     $entityType->setEntityTypeCode('test');
     $entityType->setEntityTypeId(0);
     $entityType->setEntityTable('table');
     $attributes = $this->_getAttributes();
     $attribute = $this->getMock('Mage_Eav_Model_Entity_Attribute_Abstract', array('isInSet', 'getBackend'), array(), '', false);
     $attribute->setAttributeId($code);
     $attribute->setAttributeCode($code);
     $attribute->expects($this->once())->method('isInSet')->with($this->equalTo($set))->will($this->returnValue(false));
     $attributes[$code] = $attribute;
     /** @var $model Mage_Catalog_Model_Resource_Abstract */
     $model = $this->getMock('Mage_Catalog_Model_Resource_Abstract', null, array(array('type' => $entityType, 'entityTable' => 'entityTable', 'attributesByCode' => $attributes)));
     $model->walkAttributes('backend/afterSave', array($object));
 }
Example #3
0
 public function testSave()
 {
     $code = 'test_attr';
     $set = 10;
     $object = $this->getMock('Mage_Catalog_Model_Product', null, array(), '', false);
     $object->setEntityTypeId(1);
     $object->setData(array('test_attr' => 'test_attr', 'attribute_set_id' => $set));
     $entityType = new Varien_Object();
     $entityType->setEntityTypeCode('test');
     $entityType->setEntityTypeId(0);
     $entityType->setEntityTable('table');
     $attributes = $this->_getAttributes();
     $attribute = $this->getMock('Mage_Eav_Model_Entity_Attribute_Abstract', array('getBackend', 'getBackendTable', 'isInSet', 'getApplyTo'), array(), '', false);
     $attribute->setAttributeId($code);
     /** @var $backendModel Mage_Eav_Model_Entity_Attribute_Backend_Abstract */
     $backendModel = $this->getMock('Mage_Eav_Model_Entity_Attribute_Backend_Abstract', array('getBackend', 'getBackendTable', 'getAffectedFields'));
     $backendModel->expects($this->once())->method('getAffectedFields')->will($this->returnValue(array('test_table' => array('value_id' => 0, 'attribute_id' => $code))));
     $backendModel->setAttribute($attribute);
     $attribute->expects($this->any())->method('getBackend')->will($this->returnValue($backendModel));
     $attribute->expects($this->any())->method('getBackendTable')->will($this->returnValue($code . '_table'));
     $attribute->expects($this->any())->method('isInSet')->with($this->equalTo($set))->will($this->returnValue(false));
     $attributes[$code] = $attribute;
     /** @var $model Mage_Eav_Model_Entity_Abstract */
     $model = $this->getMock('Mage_Eav_Model_Entity_Abstract', null, array(array('type' => $entityType, 'entityTable' => 'entityTable', 'attributesByCode' => $attributes)));
     $model->setConnection($this->_getAdapterMock());
     $model->isPartialSave(true);
     $model->save($object);
 }