function createLecture($course, $alt_course = null, $title = '')
 {
     $lecture = new LectureForTest();
     $title = $title ?: 'Lecture_' . rand(0, 100);
     $lecture->setTitle($title);
     $lecture->setCourse($course);
     if ($alt_course) {
         $lecture->setAltCourse($alt_course);
     }
     $lecture->save();
     return $lecture;
 }
 function save($error_list = null)
 {
     parent::save($error_list);
     $this->save_calls++;
 }
Esempio n. 3
0
 function testSettingExistingParentMakesExistingObjectDirty()
 {
     $course = new CourseForTest();
     $course->setTitle('course');
     $course->save();
     $lecture = new LectureForTest();
     $lecture->setTitle('test');
     $lecture->save();
     $lecture->setCourse($course);
     $this->assertTrue($lecture->isDirty());
     $lecture->save();
     $lecture2 = new LectureForTest($lecture->getId());
     $this->assertEqual($lecture2->getCourse()->getTitle(), $course->getTitle());
 }
 function testCorrectUsageCrossRelations()
 {
     $program = new ProgramForTest();
     $program->setTitle('Program');
     $program->save();
     $course = new CourseForTest();
     $course->setProgram($program);
     $course->save();
     $lecture = new LectureForTest();
     $lecture->setCourse($course);
     $lecture->setCachedProgram($program);
     $lecture->save();
     try {
         $finded_lectures = $program->getCachedLectures()->find(array('join' => array('course')))->getArray();
     } catch (lmbException $e) {
         $this->assertTrue(false);
     }
 }
Esempio n. 5
0
 function testImportWhereOne2ManyParentIsObject()
 {
     $course = new CourseForTest();
     $course->setTitle('Some course');
     $l = new LectureForTest();
     $l->setTitle('Physics');
     $l->setCourse($course);
     $l->save();
     $source = array('title' => $l->getTitle(), 'course' => $course);
     $l2 = new LectureForTest();
     $l2->import($source);
     $this->assertEqual($l2->getTitle(), $l->getTitle());
     $this->assertEqual($l2->getCourse()->getTitle(), $course->getTitle());
 }