示例#1
0
 /**
  * Validate the $student->validate_class_enrolment_limit function.
  */
 public function test_validate_class_enrolment_limit()
 {
     $this->load_csv_data();
     $student = new student(array('userid' => 104, 'classid' => 101));
     $student->load();
     $student->save();
     try {
         $result = $student->validate_class_enrolment_limit();
         $this->assertTrue($result);
     } catch (Exception $e) {
         // Should not reach here.
         $this->assertFalse(true);
     }
     $class = new pmclass(101);
     $class->load();
     $class->maxstudents = 1;
     $class->save();
     $student = new student(array('userid' => 103, 'classid' => 101));
     try {
         $result = $student->validate_class_enrolment_limit();
     } catch (Exception $e) {
         $this->assertTrue($e instanceof pmclass_enrolment_limit_validation_exception);
     }
 }