1<?php 2class Doctrine_Ticket_1205_TestCase extends Doctrine_UnitTestCase 3{ 4 public function prepareData() 5 { 6 $user = new Ticket1205TestUser(); 7 $user->id = 1; 8 $user->first_name = 'Slick'; 9 $user->last_name = 'Rick'; 10 $user->save(); 11 12 $address = new Ticket1205TestAddress(); 13 $address->id = 1; 14 $address->user_id = 1; 15 $address->city = 'Anywhere'; 16 $address->save(); 17 } 18 19 public function prepareTables() 20 { 21 $this->tables[] = 'Ticket1205TestUser'; 22 $this->tables[] = 'Ticket1205TestAddress'; 23 parent::prepareTables(); 24 } 25 26 public function testTicket() 27 { 28 try { 29 // Each Address has 1 User 30 $q = Doctrine_Query::create() 31 ->from('Ticket1205TestAddress a') 32 ->innerjoin('a.User u') 33 ->execute(array(), Doctrine_Core::HYDRATE_ARRAY); 34 $this->fail(); 35 } catch (Exception $e) { 36 $this->pass(); 37 } 38 } 39} 40 41class Ticket1205HydrationListener extends Doctrine_Record_Listener 42{ 43 public function postHydrate(Doctrine_Event $event) 44 { 45 throw new Exception('This is called so we are successfull!'); 46 } 47} 48 49class Ticket1205TestUser extends Doctrine_Record 50{ 51 public function setTableDefinition() 52 { 53 $this->setTableName('ticket1205_user'); 54 $this->hasColumn('first_name', 'string', 31); 55 $this->hasColumn('last_name', 'string', 31); 56 } 57 58 public function setUp() 59 { 60 $this->addListener(new Ticket1205HydrationListener()); 61 $this->hasMany('Ticket1205TestAddress as Addresses', array('local' => 'id', 62 'foreign' => 'user_id')); 63 } 64} 65 66class Ticket1205TestAddress extends Doctrine_Record 67{ 68 public function setTableDefinition() 69 { 70 $this->setTableName('ticket1205_address'); 71 $this->hasColumn('user_id', 'integer', 4, array('notnull' => true)); 72 $this->hasColumn('city', 'string', 31); 73 } 74 75 public function setUp() 76 { 77 $this->hasOne('Ticket1205TestUser as User', array('local' => 'user_id', 78 'foreign' => 'id')); 79 } 80}