1<?php
2/**
3 * Doctrine_Ticket_697_TestCase
4 *
5 * @package     Doctrine
6 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
7 * @category    Object Relational Mapping
8 * @link        www.doctrine-project.org
9 * @since       1.0
10 * @version     $Revision$
11 */
12
13class Doctrine_Ticket_697_TestCase extends Doctrine_UnitTestCase
14{
15    public function prepareData()
16    { }
17
18    public function prepareTables()
19    {
20        $this->tables = array('T697_Person', 'T697_User');
21        parent::prepareTables();
22    }
23
24    public function testIdsAreSetWhenSavingSubclassInstancesInCTI()
25    {
26        $p = new T697_Person();
27        $p['name']='Rodrigo';
28        $p->save();
29        $this->assertEqual(1, $p->id);
30
31        $u = new T697_User();
32        $u['name']='Fernandes';
33        $u['password']='Doctrine RULES';
34        $u->save();
35        $this->assertEqual(2, $u->id);
36    }
37}
38
39class T697_Person extends Doctrine_Record
40{
41    public function setTableDefinition()
42    {
43        $this->hasColumn('name', 'string', 30);
44    }
45}
46
47//Class table inheritance
48class T697_User extends T697_Person {
49    public function setTableDefinition()
50    {
51        $this->hasColumn('password', 'string', 30);
52    }
53}
54