static function find($search_id)
 {
     $found_course = null;
     $courses = Course::getAll();
     foreach ($courses as $course) {
         $course_id = $course->getCourseId();
         if ($course_id == $search_id) {
             $found_course = $course;
         }
     }
     return $found_course;
 }
 function test_deleteOne()
 {
     $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();
     $test_course->deleteOne();
     $this->assertEquals(Course::getAll(), [$test_course2]);
 }
 function testGetAll()
 {
     $name = "History";
     $course_number = "HIST100";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $name2 = "Math";
     $course_number2 = "MATH100";
     $test_course2 = new Course($name, $course_number);
     $test_course2->save();
     $result = Course::getAll();
     $this->assertEquals([$test_course, $test_course2], $result);
 }
 function testSave()
 {
     //Arrange
     $course_name = "HISTORY";
     $number = 101;
     $test_course = new Course($course_name, $number);
     //var_dump($test_course);
     //Act
     $test_course->save();
     //Assert
     $result = Course::getAll();
     $this->assertEquals($test_course, $result[0]);
 }
Beispiel #5
0
 function test_getAll()
 {
     //Arrange
     $name = "Math";
     $course_number = "112";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $name2 = "History";
     $course_number2 = "112";
     $test_course2 = new Course($name2, $course_number2);
     $test_course2->save();
     $result = Course::getAll();
     $this->assertEquals([$test_course, $test_course2], $result);
 }
 function testDelete()
 {
     //Arrange
     $course_name = "Vampires";
     $course_number = 1;
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     $course_name2 = "Discrete Math";
     $course_number2 = 1;
     $id2 = 2;
     $test_course2 = new Course($course_name2, $course_number2, $id2);
     $test_course2->save();
     //Act
     $test_course->delete();
     //Assert
     $this->assertEquals([$test_course2], Course::getAll());
 }
Beispiel #7
0
 function testUpdateCourse()
 {
     $name = "John Doe";
     $password = "******";
     $email = "*****@*****.**";
     $signed_in = 0;
     $test_user = new User($name, $password, $email, $signed_in);
     $test_user->save();
     $title = "Literature";
     $subject = "English";
     $description = "Deconstructing English literature.";
     $user_id = $test_user->getId();
     $test_course = new Course($title, $subject, $description, $user_id);
     $test_course->save();
     $title2 = "Algebra";
     $subject2 = "Math";
     $description2 = "Introduction to algebraic equations.";
     $test_course->updateCourse($title2, $subject2, $description2);
     $result = Course::getAll();
     $this->assertEquals($test_course, $result[0]);
 }
 function testDeleteCourse()
 {
     $name = "Math";
     $id = 1;
     $test_course = new Course($name);
     $test_course->save();
     $name2 = "Science";
     $id2 = 2;
     $test_course2 = new Course($name2);
     $test_course2->save();
     $test_course->delete();
     $this->assertEquals([$test_course2], Course::getAll());
 }
 function test_deleteOne()
 {
     $course_name = "History";
     $course_number = "HIST 101";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     $course_name2 = "Biology";
     $course_number2 = "BIO 101";
     $test_course2 = new Course($course_name2, $course_number2);
     $test_course2->save();
     $test_course->deleteOne();
     $this->assertEquals([$test_course2], Course::getAll());
 }
 function test_save()
 {
     //Arrange
     $course_name = "Monster Literature";
     $course_number = "ENG304";
     $test_course = new Course($course_name, $course_number);
     $test_course->save();
     //Act
     $result = Course::getAll();
     //Assert
     $this->assertEquals($test_course, $result[0]);
 }
 function testDeleteCourse()
 {
     $name = "Coding 101";
     $id = 1;
     $test_course = new Course($name);
     $test_course->save();
     $name2 = "Advanced Coding";
     $id2 = 2;
     $test_course2 = new Course($name2);
     $test_course2->save();
     $test_course->delete();
     $this->assertEquals([$test_course2], Course::getAll());
 }
Beispiel #12
0
 function testDeleteAll()
 {
     //Arrange
     $name = "Biology";
     $number = 101;
     $id = 1;
     $name2 = "Auto";
     $number2 = 101;
     $id2 = 2;
     $test_course = new Course($name, $number, $id);
     $test_course->save();
     $test_course2 = new Course($name2, $number2, $id2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     //Assert
     $result = Course::getAll();
     $this->assertEquals([], $result);
 }
 function testDeleteAll()
 {
     //Arrange
     $name = "Psychology 101";
     $course_number = "2015-08-15";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $name2 = "Psychology 102";
     $course_number2 = "PSY102";
     $test_course2 = new Course($name2, $course_number2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     //Assert
     $result = Course::getAll();
     $this->assertEquals([], $result);
 }
 function testDeleteAll()
 {
     //Arrange
     $name = "History";
     $course_number = "HIST101";
     $name2 = "English";
     $course_number2 = "ENG500";
     $test_course = new Course($name, $course_number);
     $test_course->save();
     $test_course2 = new Course($name2, $course_number2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     //Assert
     $result = Course::getAll();
     $this->assertEquals([], $result);
 }
Beispiel #15
0
});
$app->get("/students/{id}", function ($id) use($app) {
    $student = Student::find($id);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
$app->get("/students/{id}/edit", function ($id) use($app) {
    $student = Student::find($id);
    return $app['twig']->render('student_edit.html.twig', array('student' => $student));
});
$app->patch("/students/{id}", function ($id) use($app) {
    $name = $_POST['name'];
    $student = Student::find($id);
    $student->update($name);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
$app->post("/add_students", function () use($app) {
    $course = Course::find($_POST['course_id']);
    $student = Student::find($_POST['student_id']);
    $course->addStudent($student);
    return $app['twig']->render('course.html.twig', array('course' => $course, 'courses' => Course::getAll(), 'students' => $course->getStudents(), 'all_students' => Student::getAll()));
});
$app->post("/delete_students", function () use($app) {
    Student::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->delete("/students/{id}", function ($id) use($app) {
    $student = Student::find($id);
    $student->delete();
    return $app['twig']->render('students.html.twig', array('students' => Student::getAll()));
});
return $app;
Beispiel #16
0
 function test_delete()
 {
     //Arrange
     $name = "High Times";
     $code = "CHEM420";
     $test_course = new Course($name, $code);
     $test_course->save();
     $name2 = "Gavanese Jamelan";
     $code2 = "MUSC69";
     $test_course2 = new Course($name2, $code2);
     $test_course2->save();
     //Act
     $test_course->delete();
     $result = Course::getAll();
     //Assert
     $this->assertEquals($test_course2, $result[0]);
 }
 function testDelete()
 {
     $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_course->delete();
     $this->assertEquals([$test_course2], Course::getAll());
 }
    Course::deleteAll();
    return $app['twig']->render("courses.html.twig", array("courses" => Course::getAll()));
});
/////////
////////// STUDENTS
////////
$app->get("/students", function () use($app) {
    return $app['twig']->render("students.html.twig", array("students" => Student::getAll()));
});
$app->get("/students/{id}", function ($id) use($app) {
    $student = Student::find($id);
    return $app['twig']->render("student.html.twig", array("student" => $student, "courses" => $student->getCourses(), "all_courses" => Course::getAll()));
});
$app->post("/students", function () use($app) {
    $name = $_POST['name'];
    $enrollment_date = $_POST['enrollment_date'];
    $new_student = new Student($name, $enrollment_date);
    $new_student->save();
    return $app['twig']->render("students.html.twig", array("students" => Student::getAll()));
});
$app->post("/add_courses", function () use($app) {
    $course = Course::find($_POST["course_id"]);
    $course->addStudent($_POST["student_id"]);
    $student = Student::find($_POST["student_id"]);
    return $app['twig']->render("student.html.twig", array("student" => $student, "courses" => $student->getCourses(), "all_courses" => Course::getAll()));
});
$app->post("/delete_students", function () use($app) {
    Student::deleteAll();
    return $app['twig']->render("students.html.twig", array("students" => Student::getAll()));
});
return $app;
Beispiel #19
0
 function testDeletecourse()
 {
     //Arrange
     $course_name = "History 110";
     $id = 1;
     $course_number = "HST110";
     $test_course = new Course($course_name, $id, $course_number);
     $test_course->save();
     $course_name2 = "Math 101";
     $id2 = 2;
     $course_number2 = "MTH101";
     $test_course2 = new Course($course_name2, $id2, $course_number2);
     $test_course2->save();
     //Act
     $test_course->deleteOne();
     //Assert
     $this->assertEquals([$test_course2], Course::getAll());
 }
 function testDelete()
 {
     //Arrange
     $id = null;
     $name = "Intro to Math";
     $number = "MATH100";
     $test_course = new Course($id, $name, $number);
     $test_course->save();
     $id2 = null;
     $name2 = "Math for Dummies";
     $number2 = "MATH000";
     $test_course2 = new Course($id2, $name2, $number2);
     $test_course2->save();
     //Act
     $test_course2->delete();
     //Assert
     $this->assertEquals([$test_course], Course::getAll());
 }
Beispiel #21
0
 function test_deleteAll()
 {
     //Arrange
     $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();
     $title2 = "Intro to Ladders: SHOP-10";
     $teacher2 = "Jeff Winger";
     $time2 = "MWF 11AM-12PM";
     $semester2 = "Spring";
     $test_course2 = new Course($title2, $teacher2, $time2, $semester2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     $result = Course::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
 function test_delete()
 {
     //Arrange
     $test_department = new Department("Biology", "346 Stupid Avenue");
     $test_department->save();
     $name = "History 0001";
     $code = "HS001";
     $test_course = new Course($name, $code, $test_department->getId());
     $test_course->save();
     $name2 = "Dogs 101";
     $code2 = "DW101";
     $test_course2 = new Course($name2, $code2, $test_department->getId());
     $test_course2->save();
     //Act
     $test_course->delete();
     //Assert
     $result = Course::getAll();
     $this->assertEquals($test_course2, $result[0]);
 }
Beispiel #23
0
$app['debug'] = true;
$server = 'mysql:host=localhost;dbname=registrar';
$username = '******';
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
// needed for intial set up everything above this line
// link to Home page
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('courses' => Course::getAll(), 'students' => Student::getAll()));
});
// link to courses twig views page
$app->get("/courses", function () use($app) {
    return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll(), 'students' => Student::getAll()));
});
// link to courses twig views page
$app->get("/students", function () use($app) {
    return $app['twig']->render('students.html.twig', array('students' => Student::getAll(), 'courses' => Course::getAll()));
});
// path to edit individual student
// $app->get("/students/{id}", function($id) use($app) {
//     $student = Student::find($id);
//     return $app['twig']->render('student_edit.html.twig', array('student'=>$student, 'students'=> $course->getStudents()));
// path to update individual student
// $app->patch
// post edited student information
// $app-> post
// must have a return app at the bottom of app.php page
return $app;
 function testDeleteAll()
 {
     //Arrange
     $name = "Math";
     $course_num = "101";
     $id = 1;
     $test_course = new Course($name, $course_num, $id);
     $test_course->save();
     $name2 = "English";
     $course_num2 = "300";
     $id2 = 2;
     $test_course2 = new Course($name2, $course_num2, $id2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     $result = Course::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #25
0
//Listing all students for a selected course. Check all_students variable for error issue
$app->get("/courses/{id}", function ($id) use($app) {
    $course = Course::find($id);
    return $app['twig']->render('course.html.twig', array('course' => $course, 'students' => $course->getStudents(), 'all_students' => Student::getAll()));
});
//
$app->post("/add_courses", function () use($app) {
    $course = Course::find($_POST['course_id']);
    $student = Student::find($_POST['student_id']);
    $student->addCourse($course);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'students' => Student::getAll(), 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
//
$app->post("/delete_courses", function () use($app) {
    Course::deleteAll();
    return $app['twig']->render('index.html.twig');
});
//Updates course, comes from course.html, posts back to courses.html
$app->patch("/course/{id}/edit", function ($id) use($app) {
    $new_course_name = $_POST['new_course_name'];
    $course = Course::find($id);
    $course->update($new_course_name);
    return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll()));
});
//Deletes course, comes from course.html, posts back to courses.html
$app->delete("/course/{id}/edit", function ($id) use($app) {
    $course = Course::find($id);
    $course->deleteOne();
    return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll()));
});
return $app;
$app->get("/students/{id}", function ($id) use($app) {
    $student = Student::find($id);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
$app->post("/courses", function () use($app) {
    $name = $_POST['name'];
    $course_number = $_POST['course_number'];
    $course = new Course($name, $course_number);
    $course->save();
    return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll()));
});
$app->get("/courses/{id}", function ($id) use($app) {
    $course = Course::find($id);
    return $app['twig']->render('course.html.twig', array('course' => $course, 'students' => $course->getStudents(), 'all_students' => Student::getAll()));
});
$app->get("/courses", function () use($app) {
    return $app['twig']->render('courses.html.twig', array('courses' => Course::getAll()));
});
$app->post("/add_students", function () use($app) {
    $course = Course::find($_POST['course_id']);
    $student = Student::find($_POST['student_id']);
    $course->addStudent($student);
    return $app['twig']->render('course.html.twig', array('course' => $course, 'courses' => Course::getAll(), 'students' => $course->getStudents(), 'all_students' => Student::getAll()));
});
$app->post("/add_courses", function () use($app) {
    $student = Student::find($_POST['student_id']);
    $course = Course::find($_POST['course_id']);
    $student->addCourse($course);
    return $app['twig']->render('student.html.twig', array('student' => $student, 'students' => Student::getAll(), 'courses' => $student->getCourses(), 'all_courses' => Course::getAll()));
});
return $app;
 function test_getAll()
 {
     //Arrange
     $course_name = "MTH101";
     $crn = 1234;
     $id = null;
     $test_course = new Course($course_name, $crn, $id);
     $test_course->save();
     $course_name2 = "HST202";
     $crn2 = 5678;
     $test_course2 = new Course($course_name2, $crn2, $id);
     $test_course2->save();
     //Act
     $result = Course::getAll();
     //Assert
     $this->assertEquals([$test_course, $test_course2], $result);
 }
Beispiel #28
0
 function testDeleteCourse()
 {
     //Arrange
     $course_name = "Chemistry";
     $course_id = 1;
     $course_number = "1000";
     $test_course = new Course($course_name, $course_number, $course_id);
     $test_course->save();
     $course_name2 = "Underwater Basketweaving";
     $course_id2 = 2;
     $course_number2 = "2531";
     $test_course2 = new Course($course_name2, $course_number2, $course_id2);
     $test_course2->save();
     //Act
     $test_course->deleteCourse();
     //Assert
     $this->assertEquals([$test_course2], Course::getAll());
 }
 function test_deleteAll()
 {
     //Arrange
     $course_name = "History";
     $id = 1;
     $course_number = "HIST:111";
     $course_name2 = "Algebra";
     $id2 = 2;
     $course_number2 = "MTH:112";
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     $test_course2 = new Course($course_name2, $course_number2, $id2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     $result = Course::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
Beispiel #30
0
 function testDeleteAll()
 {
     //Arrange
     $course_name = "Intro to Art";
     $course_number = "ART101";
     $id = 1;
     $test_course = new Course($course_name, $course_number, $id);
     $test_course->save();
     $course_name2 = "Intro to Spanish";
     $course_number2 = "SPN101";
     $id2 = 2;
     $test_course2 = new Course($course_name2, $course_number2, $id2);
     $test_course2->save();
     //Act
     Course::deleteAll();
     $result = Course::getAll();
     //Assert
     $this->assertEquals([], $result);
 }