本文整理汇总了PHP中Course::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::getAll方法的具体用法?PHP Course::getAll怎么用?PHP Course::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
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;
}
示例2: test_deleteOne
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]);
}
示例3: testGetAll
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);
}
示例4: testSave
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]);
}
示例5: test_getAll
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);
}
示例6: testDelete
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());
}
示例7: testUpdateCourse
function testUpdateCourse()
{
$name = "John Doe";
$password = "password";
$email = "johndoe@osa.biz";
$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]);
}
示例8: testDeleteCourse
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());
}
示例9: test_deleteOne
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());
}
示例10: test_save
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]);
}
示例11: testDeleteAll
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);
}
示例12: testDeleteAll
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);
}
示例13: testDeleteAll
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);
}
示例14: function
});
$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;
示例15: test_delete
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]);
}