예제 #1
0
 function testGetCourses()
 {
     //Arrange
     $date_enrolled = "2015-10-10";
     $student_name = "Ben Baker Billington";
     $student_id = 1;
     $test_student = new Student($student_name, $date_enrolled, $student_id);
     $test_student->save();
     $course_name2 = "Billy Joe Jim Bob";
     $course_id2 = 2;
     $test_course2 = new Course($course_name2, $date_enrolled, $course_id2);
     $test_course2->save();
     $course_name = "Jammin it, dude";
     $course_number = "102";
     $course_id = 3;
     $test_course = new Course($course_name, $course_number, $course_id);
     $test_course->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     //Assert
     $this->assertEquals([$test_course, $test_course2], $test_student->getCourses());
 }
예제 #2
0
 function test_addCourse()
 {
     //Arrange
     $name = "Steve Beekman";
     $date = "2015-08-23";
     $test_student = new Student($name, $date);
     $test_student->save();
     $title = "Intro to Typing: COM-91";
     $teacher = "Ancient Raven";
     $time = "TH 9PM-11PM";
     $semester = "Fall";
     $test_course = new Course($title, $teacher, $time, $semester);
     $test_course->save();
     //Act
     $result = [$test_course];
     $test_student->addCourse($test_course);
     //Assert
     $this->assertEquals($test_student->getCourses(), $result);
 }
예제 #3
0
 function testDelete()
 {
     //Arrange
     $name = "Biology 101";
     $number = 101;
     $id = 1;
     $test_course = new Course($name, $number, $id);
     $test_course->save();
     $name = "Auto";
     $number2 = 101;
     $id2 = 2;
     $test_student = new Student($name, $date, $id2);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }
예제 #4
0
 function test_addCourse()
 {
     //Arrange
     $course_name = "MTH101";
     $crn = 1234;
     $id = 1;
     $test_course = new Course($course_name, $crn, $id);
     $test_course->save();
     $student_name = "Bob";
     $enroll_date = "2012-10-20";
     $id2 = 2;
     $test_student = new Student($student_name, $enroll_date, $id2);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     //Assert
     $this->assertEquals($test_student->getCourses(), [$test_course]);
 }
 function test_addCourse()
 {
     //Arrange
     $name = "bowling";
     $id = 1;
     $course_number = "400";
     $test_course = new Course($name, $course_number, $id);
     $test_course->save();
     $name2 = "Lebowski";
     $enrollment_date = "2015-12-12";
     $id2 = 2;
     $test_student = new Student($name2, $enrollment_date, $id2);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $result = $test_student->getCourses();
     //Assert
     $this->assertEquals([$test_course], $result);
 }
 function testDelete()
 {
     //Arrange
     $course_name = "History";
     $id = 1;
     $crn = "HIST101";
     $test_course = new Course($course_name, $crn, $id);
     $test_course->save();
     $student_name = "Paco";
     $id2 = 2;
     $enroll_date = "2015-05-11";
     $test_student = new Student($student_name, $enroll_date, $id2);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->deleteOne();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }
 function test_addCourse_and_getCourses()
 {
     $name = "Western Civ";
     $number = "HST 101";
     $test_course = new Course($name, $number);
     $test_course->save();
     $name2 = "Remedial Math";
     $number2 = "MTH 64";
     $test_course2 = new Course($name2, $number2);
     $test_course2->save();
     $name = "Chris";
     $date = "1111-11-11";
     $test_student = new Student($name, $date);
     $test_student->save();
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $this->assertEquals($test_student->getCourses(), [$test_course, $test_course2]);
 }
예제 #8
0
     */
    public function getAddress()
    {
        return $this->address;
    }
    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }
}
$student = new Student(123, 'Bill', '123 foo road');
$student->addCourse('PHP')->addCourse('Python')->addCourse('Ruby');
echo '<pre>';
print_r($student);
echo 'Parent Class: ' . get_parent_class($student);
if ($student instanceof Person) {
    echo 'Yeah';
} else {
    echo 'No';
}
echo "\n\n";
 function test_getCourses()
 {
     //Arrange
     $course_name = "Being a bum";
     $id = 1;
     $test_course = new Course($course_name, $id);
     $test_course->save();
     $course_name2 = "Getting a toe";
     $id2 = 2;
     $test_course2 = new Course($course_name2, $id2);
     $test_course2->save();
     $student_name = "Jeff Lebowski";
     $id3 = 3;
     $test_student = new Student($student_name, $id3);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     //Assert
     $this->assertEquals($test_student->getCourses(), [$test_course, $test_course2]);
 }
예제 #10
0
 function testDelete()
 {
     //Arrange
     $name = "Ben";
     $enroll_date = "0000-00-00";
     $id = 1;
     $test_student = new Student($name, $enroll_date, $id);
     $test_student->save();
     $course_name = "Intro to Art";
     $course_number = "ART101";
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }
예제 #11
0
 function test_updateCompleted()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $test_student = new Student("Shmuel Irving-Jones", "2015-08-25", $test_department->getId());
     $test_student->save();
     $test_course = new Course("High Times", "CHEM420", $test_department->getId());
     $test_course->save();
     $test_course2 = new Course("Gavanese Jamelan", "MUSC69", $test_department->getId());
     $test_course2->save();
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     //Act
     $test_student->updateCompleted($test_course->getId());
     //Assert
     $this->assertEquals(true, $test_student->getCompleted($test_course->getId()));
 }
 function testGetCourses()
 {
     $student_name = "John Doe";
     $enrollment_date = "2015-09-01";
     $test_student = new Student($student_name, $enrollment_date);
     $test_student->save();
     $course_name = "History";
     $course_code = "HIST100";
     $test_course = new Course($course_name, $course_code);
     $test_course->save();
     $course_name2 = "Gym";
     $course_code2 = "GYM100";
     $test_course2 = new Course($course_name2, $course_code2);
     $test_course2->save();
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $this->assertEquals($test_student->getCourses(), [$test_course2, $test_course]);
 }
예제 #13
0
 function testGetCourses()
 {
     //Arrange
     $name = "Math";
     $course_num = "101";
     $id = 1;
     $test_course = new Course($name, $course_num, $id);
     $test_course->save();
     $name2 = "English";
     $course_num2 = "200";
     $id2 = 2;
     $test_course2 = new Course($name2, $course_num2, $id2);
     $test_course2->save();
     $name = "Rick";
     $date = "2015-08-15";
     $id = 1;
     $test_student = new Student($name, $date, $id);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $result = $test_student->getCourses();
     //Assert
     $this->assertEquals([$test_course, $test_course2], $result);
 }
예제 #14
0
 function loadAllStudents()
 {
     $start = microtime(true);
     $statement = "SELECT * FROM Action";
     $result = mysqli_query($GLOBALS['CONFIG']['mysqli'], $statement);
     /*if(mysqli_fetch_array($result)==null){
           return 1;
       }
       $query = new Query('action');
       $queryActions = $query->select('*',true);*/
     //Need to return ordered by session_id
     //This takes quite a bit of time. Need to shorten it.
     $end = microtime(true);
     echo 'MYSQL * action query took ' . ($end - $start) . ' seconds!<br>';
     $start = microtime(true);
     //$newStudent = new Student();
     //In order, add each student to the list, adding each course that they took, no, or yes.
     //foreach($queryActions as $action){
     while ($row = mysqli_fetch_row($result)) {
         /*
                     $id = $action->get('session_id');
                     $course = $action->get('course_id');
                     $major = $action->get('major');
                     $year = $action->get('year');
                     $choice = $action->get('choice');*/
         $id = $row[6];
         $course = $row[3];
         $major = $row[1];
         $year = $row[2];
         $choice = $row[4];
         if (isset($this->StudentList[$id])) {
             $CurrentStudent = $this->StudentList[$id];
             $CurrentStudent->addCourse($course, $choice);
         } else {
             $CurrentStudent = new Student($id);
             $CurrentStudent->setMajor($major);
             $CurrentStudent->setYear($year);
             $CurrentStudent->addCourse($course, $choice);
         }
         $this->StudentList[$id] = $CurrentStudent;
     }
     $end = microtime(true);
     echo 'PHP database class creation took ' . ($end - $start) . ' seconds!<br>';
 }
 function testGetCourses()
 {
     $name = "Bob";
     $enrollment_date = "2015-01-01";
     $test_student = new Student($name, $enrollment_date);
     $test_student->save();
     $course_name = "History";
     $course_number = "HIST100";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     $course_name2 = "Math";
     $course_number2 = "MATH100";
     $test_course2 = new Course($course_name, $course_number);
     $test_course2->save();
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $this->assertEquals($test_student->getCourses(), [$test_course, $test_course2]);
 }
 function test_getCourses()
 {
     //Arrange
     $name = "bob";
     $date_of_enrollment = "2015-09-16";
     $test_student = new Student($name, $date_of_enrollment);
     $test_student->save();
     $name2 = "Psychology 101";
     $course_number = "PSY101";
     $test_course = new Course($name2, $course_number);
     $test_course->save();
     $name3 = "Philosophy 101";
     $course_number2 = "PHIL101";
     $test_course2 = new Course($name3, $course_number2);
     $test_course2->save();
     //Act
     $test_student->addCourse($test_course->getId());
     $test_student->addCourse($test_course2->getId());
     //Assert
     $result = $test_student->getCourses();
     $this->assertEquals([$test_course, $test_course2], $result);
 }
 function test_getCourses()
 {
     //Arrange
     $name = "History of Rugs";
     $course_number = "200";
     $id = 1;
     $test_course = new Course($name, $course_number, $id);
     $test_course->save();
     $name2 = "White Russians";
     $course_number2 = "400";
     $id2 = 2;
     $test_course2 = new Course($name2, $course_number2, $id2);
     $test_course2->save();
     $student_name = "Donnie";
     $enrollment_date = "yesterday";
     $id3 = 3;
     $test_student = new Student($student_name, $enrollment_date, $id3);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $result = $test_student->getCourses();
     var_dump($result);
     //Assert
     $this->assertEquals([$test_course, $test_course2], $result);
 }
예제 #18
0
 function testDelete()
 {
     //Arrange
     $name = "Biology 101";
     $number = 101;
     $id = 1;
     $test_course = new Course($name, $number, $id);
     $test_course->save();
     $name = "Elliot Michaels";
     $date = "2015-08-03";
     $id = 1;
     $test_student = new Student($name, $date, $id);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->delete();
     //Assert
     $this->assertEquals([], $test_course->getStudents());
 }
 function testAddCourse()
 {
     $name = "Jimmy";
     $enrollment_date = "2015";
     $test_student = new Student($name, $enrollment_date);
     $test_student->save();
     $course_name = "Real Analysis I";
     $course_number = "Math 540";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     $test_student->addCourse($test_course);
     $this->assertEquals([$test_course], $test_student->getCourses());
 }
 function testGetCourses()
 {
     //Arrange
     $id = null;
     $name = "Intro to Math";
     $number = "MATH100";
     $test_course = new Course($id, $name, $number);
     $test_course->save();
     $id2 = null;
     $name2 = "Underwater Basketweaving";
     $number2 = "BS133";
     $test_course2 = new Course($id2, $name2, $number2);
     $test_course2->save();
     $id3 = null;
     $student_name = "Billy";
     $enroll_date = "2015-09-18";
     $test_student = new Student($id3, $student_name, $enroll_date);
     $test_student->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     //Assert
     $this->assertEquals([$test_course, $test_course2], $test_student->getCourses());
 }
예제 #21
0
 function test_getCourses()
 {
     //Arrange
     $test_student = new Student("Shmuel Irving-Jones", "2015-08-25");
     $test_student->save();
     $test_student2 = new Student("Billy Bartle-Barnaby", "2015-07-09");
     $test_student2->save();
     $test_course = new Course("High Times", "CHEM420");
     $test_course->save();
     $test_course2 = new Course("Gavanese Jamelan", "MUSC69");
     $test_course2->save();
     //Act
     $test_student->addCourse($test_course);
     $test_student->addCourse($test_course2);
     $test_student2->addCourse($test_course2);
     //Assert
     $this->assertEquals($test_student->getCourses(), [$test_course, $test_course2]);
 }
 function testDelete()
 {
     $name = "Math";
     $date = '0000-00-00';
     $id = null;
     $test_course = new Course($name, $id);
     $test_course->save();
     $student_name = "Student1";
     $course_id = $test_course->getId();
     $test_student = new Student($student_name, $id, $date, $course_id);
     $test_student->save();
     $test_student->addCourse($test_course);
     $test_student->delete();
     $this->assertEquals([], $test_course->getStudents());
 }
 function test_deleteAllCourses()
 {
     //Arrange
     $name = "Wesley Pong";
     $enrollment_date = "2015-09-09";
     $id = 1;
     $test_student = new Student($name, $enrollment_date, $id);
     $test_student->save();
     $course_name = "History";
     $id2 = 2;
     $course_number = 'HIST:101';
     $test_course = new Course($course_name, $course_number, $id2);
     $test_course->save();
     $course_name2 = "Lit";
     $id3 = 3;
     $course_number2 = 'Lit:101';
     $test_course2 = new Course($course_name2, $course_number2, $id3);
     $test_course2->save();
     $test_student->addCourse($test_course->getId());
     $test_student->addCourse($test_course2->getId());
     //Act
     $test_student->deleteAllCourses();
     $result = $test_student->getCourses();
     //Assert
     $this->assertEquals([], $result);
 }