username = 'romanb'; $this->assertEquals('romanb?!', $entity1->username); $entity2 = new MagicAccessorMutatorTestEntity(); $entity2->username = 'romanb'; $this->assertEquals('romanb?!', $entity1->username); } } /* Local test classes */ class CustomAccessorMutatorTestEntity extends Doctrine_Entity { public static function initMetadata($mapping) { $mapping->mapField(array( 'fieldName' => 'id', 'type' => 'integer', 'length' => 4, 'id' => true )); $mapping->mapField(array( 'fieldName' => 'username', 'type' => 'string', 'length' => 50, 'accessor' => 'getUsernameCustom', 'mutator' => 'setUsernameCustom' )); } public function getUsernameCustom() { return $this->_rawGetField('username') . "!"; } public function setUsernameCustom($username) { $this->_rawSetField('username', $username . "?"); } } class MagicAccessorMutatorTestEntity extends Doctrine_Entity { public static function initMetadata($mapping) { $mapping->mapField(array( 'fieldName' => 'id', 'type' => 'integer', 'length' => 4, 'id' => true )); $mapping->mapField(array( 'fieldName' => 'username', 'type' => 'string', 'length' => 50 )); } public function getUsername() { return $this->_rawGetField('username') . "!"; } public function setUsername($username) { $this->_rawSetField('username', $username . "?"); } }