本文整理汇总了PHP中Student::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::getAll方法的具体用法?PHP Student::getAll怎么用?PHP Student::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_save
function test_save()
{
//Arrange
$name = "Joleen";
$enrollment = "2015-09-18";
$test_student = new Student($name, $enrollment);
$test_student->save();
//Act
$result = Student::getAll();
//Assert
$this->assertEquals($test_student, $result[0]);
}
示例2: find
static function find($search_id)
{
$found_student = null;
$students = Student::getAll();
foreach ($students as $student) {
$student_id = $student->getId();
if ($student_id == $search_id) {
$found_student = $student;
}
}
return $found_student;
}
示例3: test_deleteOne
function test_deleteOne()
{
$name = "Chris";
$date = "1111-11-11";
$test_student = new Student($name, $date);
$test_student->save();
$name2 = "Dillon";
$test_student2 = new Student($name2, $date);
$test_student2->save();
$test_student->deleteOne();
$this->assertEquals(Student::getAll(), [$test_student2]);
}
示例4: testSave
function testSave()
{
//Arrange
$student_name = "Johnny Mcfly";
$date_enrollment = "12-12-2012";
$test_student = new Student($student_name, $date_enrollment);
//Act
$test_student->save();
//Assert
$result = Student::getAll();
$this->assertEquals($test_student, $result[0]);
}
示例5: testGetAll
function testGetAll()
{
$name = "Bob";
$enrollment_date = "2015-01-01";
$test_student = new Student($name, $enrollment_date);
$test_student->save();
$name2 = "Kevin";
$enrollment_date2 = "2015-02-01";
$test_student2 = new Student($name, $enrollment_date);
$test_student2->save();
$result = Student::getAll();
$this->assertEquals([$test_student, $test_student2], $result);
}
示例6: testSave
function testSave()
{
//Arrange
$student_id = 1;
$student_name = "History";
$date_enrolled = "2015-12-12";
$test_student = new Student($student_name, $date_enrolled);
//Act
$test_student->save();
//Assert
$result = Student::getAll();
$this->assertEquals($test_student, $result[0]);
}
示例7: testSave
function testSave()
{
//Arrange
$student_name = "Mike Laser";
$date_enrollment = "2014-08-15";
$id = 3;
$test_student = new Student($student_name, $date_enrollment, $id);
//Act
$test_student->save();
//Assert
$result = Student::getAll();
$this->assertEquals($test_student, $result[0]);
}
示例8: test_DeleteAll
function test_DeleteAll()
{
//Arrange
$name = "Mike";
$enrollment_date = "2015-12-12";
$test_student = new Student($name, $enrollment_date);
$test_student->save();
$name2 = "The Same Exact Name";
$enrollment_date2 = "2015-12-12";
$test_student2 = new Student($name2, $enrollment_date2);
$test_student2->save();
Student::deleteAll();
$result = Student::getAll();
$this->assertEquals([], $result);
}
示例9: testDeleteStudent
function testDeleteStudent()
{
//Arrange
$name = "Elliot Michaels";
$date = "2015-08-03";
$id = 1;
$test_student = new Student($name, $date, $id);
$test_student->save();
$name2 = "Drake Michaels";
$date2 = "2011-02-02";
$id2 = 2;
$test_student2 = new Student($name2, $date2, $id2);
$test_student2->save();
//Act
$test_student->delete();
//Assert
$this->assertEquals([$test_student2], Student::getAll());
}
示例10: test_deleteAll
function test_deleteAll()
{
//Arrange
$name = "Steve Beekman";
$date = "2015-08-23";
$test_student = new Student($name, $date);
$test_student->save();
$name2 = "Fred Flintstone";
$date2 = "0001-01-01";
$test_student2 = new Student($name2, $date2);
$test_student2->save();
//Act
Student::deleteAll();
$result = Student::getAll();
//Assert
$this->assertEquals([], $result);
}
示例11: testDeleteAll
function testDeleteAll()
{
//Arrange
$name = "Bob";
$date_of_enrollment = "2015-08-15";
$test_student = new Student($name, $date_of_enrollment);
$test_student->save();
$name2 = "Jackie";
$date_of_enrollment2 = "2015-09-16";
$test_student2 = new Student($name2, $date_of_enrollment2);
$test_student2->save();
//Act
Student::deleteAll();
//Assert
$result = Student::getAll();
$this->assertEquals([], $result);
}
示例12: array
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;
示例13: test_deleteStudent
function test_deleteStudent()
{
//Arrange
$student_name = "Joker";
$enrollment_date = "6000-12-14";
$id = 1;
$student = new Student($student_name, $enrollment_date, $id);
$student->save();
$student_name2 = "Riddler";
$enrollment_date2 = "7000-08-09";
$id2 = 2;
$student2 = new Student($student_name2, $enrollment_date2, $id2);
$student2->save();
//Act
$student->delete();
//Assert
$this->assertEquals([$student2], Student::getAll());
}
示例14: test_delete
function test_delete()
{
//Arrange
$test_department = new Department("Biology", "346 Stupid Avenue");
$test_department->save();
$name = "Ashlin Aronin";
$enrollment_date = "2015-08-24";
$test_student = new Student($name, $enrollment_date, $test_department->getId());
$test_student->save();
$name2 = "John Nolastname";
$enrollment_date2 = "2015-07-20";
$test_student2 = new Student($name, $enrollment_date, $test_department->getId());
$test_student2->save();
//Act
$test_student->delete();
//Assert
$result = Student::getAll();
$this->assertEquals([$test_student2], $result);
}
示例15: test_deleteAll
function test_deleteAll()
{
//Arrange
$student_name = "Bob";
$enroll_date = "2012-10-20";
$id = null;
$test_student = new Student($student_name, $enroll_date, $id);
$test_student->save();
$student_name2 = "Sue";
$enroll_date2 = "2013-09-09";
$test_student2 = new Student($student_name2, $enroll_date2, $id);
$test_student2->save();
//Act
Student::deleteAll();
$result = Student::getAll();
//Assert
$this->assertEquals([], $result);
}