1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/tests/Ticket/697TestCase.php

63 lines
1.6 KiB
PHP
Raw Normal View History

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
* @link www.phpdoctrine.com
* @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()
{
$personTable = $this->conn->getTable('T697_Person');
$userTable = $this->conn->getTable('T697_User');
//var_dump($userTable->getColumns());
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);
}
}
class T697_Person extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setInheritanceType(Doctrine::INHERITANCETYPE_JOINED,
array('T697_Person' => array('dtype' => 1), 'T697_User' => array('dtype' => 2)));
$this->setTableName('t697_person');
2007-12-28 14:51:48 +03:00
$this->hasColumn('name', 'string', 30);
$this->hasColumn('dtype', 'integer', 4);
2007-12-28 14:51:48 +03:00
}
}
//Class table inheritance
class T697_User extends T697_Person {
public function setTableDefinition()
{
$this->setTableName('t697_user');
2007-12-28 14:51:48 +03:00
$this->hasColumn('password', 'string', 30);
}
}