#438: Updated test case syntax
This commit is contained in:
parent
3aa991821b
commit
8bb65f0cf6
@ -77,7 +77,8 @@ class Doctrine_Ticket_438_TestCase extends Doctrine_UnitTestCase
|
||||
$this->newStudentCourse($student1, $course1);
|
||||
$this->newStudentCourse($student1, $course2);
|
||||
|
||||
// 1. Fetch relationship on demand
|
||||
|
||||
// 1. Fetch relationship on demand (multiple queries)
|
||||
$q = new Doctrine_Query();
|
||||
$q->from('T438_StudentCourse sc')
|
||||
->where('sc.student_id = ? AND sc.course_id = ?',array('07090002', 'MATH001'));
|
||||
@ -93,9 +94,10 @@ class Doctrine_Ticket_438_TestCase extends Doctrine_UnitTestCase
|
||||
$q = new Doctrine_Query();
|
||||
$q->select('sc.*, s.*, c.*')
|
||||
->from('T438_StudentCourse sc, sc.Student s, sc.Course c')
|
||||
->where('sc.student_id = ? AND sc.course_id = ?',array('07090002', 'MATH001'));
|
||||
->where('sc.student_id = ? AND sc.course_id = ?',array('07090002', 'MATH001'))
|
||||
->execute();
|
||||
|
||||
$record = $q->execute()->getFirst();
|
||||
$record = $q->getFirst();
|
||||
$this->assertEqual($record->student_id, '07090002');
|
||||
$this->assertEqual($record->course_id, 'MATH001');
|
||||
|
||||
@ -117,7 +119,7 @@ class T438_Student extends Doctrine_Record
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->hasMany('T438_Course as StudyCourses', array('refClass' => 'T438_StudentCourse', 'local' => 'sc_student_id', 'foreign' => 'sc_course_id'));
|
||||
$this->hasMany('T438_Course as StudyCourses', array('refClass' => 'T438_StudentCourse', 'local' => 'student_id', 'foreign' => 'course_id'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,12 +136,10 @@ class T438_Course extends Doctrine_Record
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->hasMany('T438_Student as Students', array('refClass' => 'T438_StudentCourse', 'local' => 'sc_course_id', 'foreign' => 'sc_student_id'));
|
||||
$this->hasMany('T438_Student as Students', array('refClass' => 'T438_StudentCourse', 'local' => 'course_id', 'foreign' => 'student_id'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class T438_StudentCourse extends Doctrine_Record
|
||||
{
|
||||
public function setTableDefinition()
|
||||
@ -148,12 +148,12 @@ class T438_StudentCourse extends Doctrine_Record
|
||||
|
||||
$this->hasColumn('sc_student_id as student_id', 'varchar', 30, array ( 'primary' => true,));
|
||||
$this->hasColumn('sc_course_id as course_id', 'varchar', 20, array ( 'primary' => true,));
|
||||
$this->hasColumn('sc_remark as remark', 'varchar', 500, array ());
|
||||
$this->hasColumn('sc_remark as remark', 'varchar', 500, array ());
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->ownsOne('T438_Student as Student', array('local' => 'sc_student_id', 'foreign' => 's_id'));
|
||||
$this->ownsOne('T438_Course as Course', array('local' => 'sc_course_id', 'foreign' => 'c_id'));
|
||||
$this->hasOne('T438_Student as Student', array('local' => 'student_id', 'foreign' => 'id'));
|
||||
$this->hasOne('T438_Course as Course', array('local' => 'course_id', 'foreign' => 'id'));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user