626DTestCase.php 1.33 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * Doctrine_Ticket_626D_TestCase
 *
 * @package     Doctrine
 * @author      Tamcy <7am.online@gmail.com>
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @category    Object Relational Mapping
10
 * @link        www.phpdoctrine.org
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 * @since       1.0
 * @version     $Revision$
 */

class Doctrine_Ticket_626D_TestCase extends Doctrine_UnitTestCase
{
    public function prepareData() 
    { }

    public function prepareTables()
    {
      $this->tables = array('T626D_Student1');
      parent::prepareTables();
    }

    protected function newStudent($cls, $id, $name)
    {
      $u = new $cls;
      $u->id = $id;
      $u->name = $name;
      $u->save();
      return $u;
    }

    public function testFieldNames()
    {
      $student1 = $this->newStudent('T626D_Student1', '07090002', 'First Student');

      try {
40
        $student = $this->conn->getRepository('T626D_Student1')->find('07090002');
41 42 43 44 45 46 47 48
        $this->pass();
      } catch (Exception $e) {
        $this->fail($e->__toString());
      }
    }
}


49
class T626D_Student1 extends Doctrine_Entity
50
{
51
  public static function initMetadata($class)
52
  {
53
    $class->setTableName('T626D_Student_record_1');
54

55 56
    $class->setColumn('s_id as id', 'varchar', 30, array (  'primary' => true,));
    $class->setColumn('s_name as name', 'varchar', 50, array ());
57 58
  }
}