/** * Successful if $value is Varien_Object an all condition are fulfilled. * * If read-only properties are set than $value mustn't have changes in them. * * @param Varien_Object|mixed $value * @return bool * @throws InvalidArgumentException when $value is not instanceof Varien_Object */ public function isValid($value) { $this->_clearMessages(); if (!$value instanceof Varien_Object) { throw new InvalidArgumentException('Instance of Varien_Object is expected.'); } if ($this->_readOnlyProperties) { if (!$value->hasDataChanges()) { return true; } foreach ($this->_readOnlyProperties as $property) { if ($this->_hasChanges($value->getData($property), $value->getOrigData($property))) { $this->_messages[__CLASS__] = array($this->getTranslator()->__("Read-only property cannot be changed.")); break; } } } return !count($this->_messages); }
/** * Tests Varien_Object->setDataChanges() */ public function testSetDataChanges() { $this->assertFalse($this->_object->hasDataChanges()); $this->_object->setDataChanges(true); $this->assertTrue($this->_object->hasDataChanges()); }