2008-05-26 00:57:32 +04:00
|
|
|
<?php
|
2009-01-04 19:15:32 +03:00
|
|
|
/* CURRENTLY NOT USED */
|
2008-05-26 00:57:32 +04:00
|
|
|
require_once 'lib/DoctrineTestInit.php';
|
|
|
|
|
2008-07-11 14:48:04 +04:00
|
|
|
class Orm_Entity_AccessorTest extends Doctrine_OrmTestCase
|
2008-05-26 00:57:32 +04:00
|
|
|
{
|
|
|
|
public function testGetterSetterOverride()
|
2008-07-11 14:48:04 +04:00
|
|
|
{
|
2008-05-26 00:57:32 +04:00
|
|
|
$entity1 = new CustomAccessorMutatorTestEntity();
|
|
|
|
$entity1->username = 'romanb';
|
|
|
|
$this->assertEquals('romanb?!', $entity1->username);
|
|
|
|
|
|
|
|
$entity2 = new MagicAccessorMutatorTestEntity();
|
|
|
|
$entity2->username = 'romanb';
|
|
|
|
$this->assertEquals('romanb?!', $entity1->username);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-11 14:48:04 +04:00
|
|
|
|
|
|
|
/* Local test classes */
|
|
|
|
|
2008-12-18 17:08:11 +03:00
|
|
|
class CustomAccessorMutatorTestEntity extends Doctrine_Common_VirtualPropertyObject
|
2008-05-26 00:57:32 +04:00
|
|
|
{
|
2008-12-18 17:08:11 +03:00
|
|
|
static function construct() {
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'id', 'int');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__,
|
|
|
|
'username', 'string', 'getUsernameCustom', 'setUsernameCustom');
|
|
|
|
}
|
|
|
|
|
2008-07-21 00:13:24 +04:00
|
|
|
public static function initMetadata($mapping)
|
2008-05-26 00:57:32 +04:00
|
|
|
{
|
2008-07-21 00:13:24 +04:00
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'id',
|
|
|
|
'type' => 'integer',
|
|
|
|
'length' => 4,
|
|
|
|
'id' => true
|
|
|
|
));
|
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'username',
|
|
|
|
'type' => 'string',
|
2008-12-18 17:08:11 +03:00
|
|
|
'length' => 50
|
2008-07-21 00:13:24 +04:00
|
|
|
));
|
2008-05-26 00:57:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsernameCustom()
|
|
|
|
{
|
2008-08-02 21:41:37 +04:00
|
|
|
return $this->_get('username') . "!";
|
2008-05-26 00:57:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUsernameCustom($username)
|
|
|
|
{
|
2008-08-02 21:41:37 +04:00
|
|
|
$this->_set('username', $username . "?");
|
2008-05-26 00:57:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-18 17:08:11 +03:00
|
|
|
class MagicAccessorMutatorTestEntity extends Doctrine_Common_VirtualPropertyObject
|
2008-05-26 00:57:32 +04:00
|
|
|
{
|
2008-12-18 17:08:11 +03:00
|
|
|
static function construct() {
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'id', 'int');
|
|
|
|
Doctrine_Common_VirtualPropertySystem::register(__CLASS__, 'username', 'string');
|
|
|
|
}
|
|
|
|
|
2008-07-21 00:13:24 +04:00
|
|
|
public static function initMetadata($mapping)
|
2008-05-26 00:57:32 +04:00
|
|
|
{
|
2008-07-21 00:13:24 +04:00
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'id',
|
|
|
|
'type' => 'integer',
|
|
|
|
'length' => 4,
|
|
|
|
'id' => true
|
|
|
|
));
|
|
|
|
$mapping->mapField(array(
|
|
|
|
'fieldName' => 'username',
|
|
|
|
'type' => 'string',
|
|
|
|
'length' => 50
|
|
|
|
));
|
2008-05-26 00:57:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsername()
|
|
|
|
{
|
2008-08-02 21:41:37 +04:00
|
|
|
return $this->_get('username') . "!";
|
2008-05-26 00:57:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUsername($username)
|
|
|
|
{
|
2008-08-02 21:41:37 +04:00
|
|
|
$this->_set('username', $username . "?");
|
2008-05-26 00:57:32 +04:00
|
|
|
}
|
|
|
|
}
|