2007-12-28 14:51:48 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Doctrine_Ticket_697_TestCase
|
|
|
|
*
|
|
|
|
* @package Doctrine
|
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
|
|
|
* @category Object Relational Mapping
|
2008-02-22 21:11:35 +03:00
|
|
|
* @link www.phpdoctrine.org
|
2007-12-28 14:51:48 +03:00
|
|
|
* @since 1.0
|
|
|
|
* @version $Revision$
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Doctrine_Ticket_697_TestCase extends Doctrine_UnitTestCase
|
|
|
|
{
|
|
|
|
public function prepareData()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
public function prepareTables()
|
|
|
|
{
|
|
|
|
$this->tables = array('T697_Person', 'T697_User');
|
|
|
|
parent::prepareTables();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIdsAreSetWhenSavingSubclassInstancesInCTI()
|
2008-02-04 00:29:57 +03:00
|
|
|
{
|
2007-12-28 14:51:48 +03:00
|
|
|
$p = new T697_Person();
|
|
|
|
$p['name']='Rodrigo';
|
|
|
|
$p->save();
|
|
|
|
$this->assertEqual(1, $p->id);
|
|
|
|
|
|
|
|
$u = new T697_User();
|
|
|
|
$u['name']='Fernandes';
|
|
|
|
$u['password']='Doctrine RULES';
|
|
|
|
$u->save();
|
|
|
|
$this->assertEqual(2, $u->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 01:20:34 +04:00
|
|
|
class T697_Person extends Doctrine_Entity
|
2007-12-28 14:51:48 +03:00
|
|
|
{
|
2008-02-04 00:29:57 +03:00
|
|
|
public static function initMetadata($class)
|
2007-12-28 14:51:48 +03:00
|
|
|
{
|
2008-03-23 14:30:29 +03:00
|
|
|
$class->setInheritanceType(Doctrine::INHERITANCE_TYPE_JOINED, array(
|
2008-02-04 00:29:57 +03:00
|
|
|
'discriminatorColumn' => 'dtype',
|
|
|
|
'discriminatorMap' => array(
|
|
|
|
1 => 'T697_Person', 2 => 'T697_User'
|
|
|
|
)
|
|
|
|
));
|
|
|
|
$class->setSubclasses(array('T697_User'));
|
|
|
|
$class->setTableName('t697_person');
|
|
|
|
$class->setColumn('name', 'string', 30);
|
|
|
|
$class->setColumn('dtype', 'integer', 4);
|
2007-12-28 14:51:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Class table inheritance
|
|
|
|
class T697_User extends T697_Person {
|
2008-02-04 00:29:57 +03:00
|
|
|
public static function initMetadata($class)
|
2007-12-28 14:51:48 +03:00
|
|
|
{
|
2008-02-04 00:29:57 +03:00
|
|
|
$class->setTableName('t697_user');
|
|
|
|
$class->setColumn('password', 'string', 30);
|
2007-12-28 14:51:48 +03:00
|
|
|
}
|
|
|
|
}
|