1<?php
2
3/**
4 * Doctrine_Ticket_626_TestCase
5 *
6 * @package     Doctrine
7 * @author      Tamcy <7am.online@gmail.com>
8 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
9 * @category    Object Relational Mapping
10 * @link        www.doctrine-project.org
11 * @since       1.0
12 * @version     $Revision$
13 */
14
15class Doctrine_Ticket_626C_TestCase extends Doctrine_UnitTestCase
16{
17    public function prepareData()
18    { }
19
20    public function prepareTables()
21    {
22      $this->tables = array('T626C_Student1', 'T626C_Student2');
23      parent::prepareTables();
24    }
25
26    protected function newStudent($cls, $id, $name)
27    {
28      $u = new $cls;
29      $u->id = $id;
30      $u->name = $name;
31      $u->save();
32      return $u;
33    }
34
35    public function testFieldNames()
36    {
37      $student1 = $this->newStudent('T626C_Student1', '07090002', 'First Student');
38
39      try {
40        $students = Doctrine_Query::create()
41          ->from('T626C_Student1 s INDEXBY s.id')
42          ->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
43        $this->pass();
44      } catch (Exception $e) {
45        $this->fail($e->__toString());
46      }
47    }
48
49    public function testColNames()
50    {
51      $student1 = $this->newStudent('T626C_Student2', '07090002', 'First Student');
52
53      try {
54        $students = Doctrine_Query::create()
55          ->from('T626C_Student2 s INDEXBY s.id')
56          ->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
57        $this->pass();
58      } catch (Exception $e) {
59        $this->fail($e->__toString());
60      }
61    }
62}
63
64
65class T626C_Student1 extends Doctrine_Record
66{
67  public function setTableDefinition()
68  {
69    $this->setTableName('T626C_Student_record_1');
70
71    $this->hasColumn('s_id as id', 'varchar', 30, array (  'primary' => true,));
72    $this->hasColumn('s_name as name', 'varchar', 50, array ());
73  }
74}
75
76class T626C_Student2 extends Doctrine_Record
77{
78  public function setTableDefinition()
79  {
80    $this->setTableName('T626C_Student_record_2');
81
82    $this->hasColumn('id', 'varchar', 30, array (  'primary' => true,));
83    $this->hasColumn('name', 'varchar', 50, array ());
84  }
85}