From 3d4ff2248e03e7586e3d42a4a040e506566baba1 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Thu, 18 Feb 2010 15:38:43 -0500 Subject: [PATCH] Added a new file attendancelink.class.test.php CT#191 --- .../lib/be/attendancelink.class.test.php | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 tests/main/gradebook/lib/be/attendancelink.class.test.php diff --git a/tests/main/gradebook/lib/be/attendancelink.class.test.php b/tests/main/gradebook/lib/be/attendancelink.class.test.php new file mode 100644 index 0000000000..c31f2ab917 --- /dev/null +++ b/tests/main/gradebook/lib/be/attendancelink.class.test.php @@ -0,0 +1,135 @@ +UnitTestCase('Test Attendance Link'); + } + + public function __construct() { + // The constructor acts like a global setUp for the class + require_once api_get_path(SYS_TEST_PATH).'setup.inc.php'; + global $date; + $this->attendance = new AttendanceLink(); + $this->attendance->set_course_code('COURSETEST'); + $this->attendance->set_id (1); + $this->attendance->set_type (LINK_ATTENDANCE); + $this->attendance->set_ref_id (1) ; + $this->attendance->set_user_id (1); + $this->attendance->set_category_id(1); + $this->attendance->set_date ($date); + $this->attendance->set_weight (1); + $this->attendance->set_visible (1); + $this->attendance->set_session_id(1); + } + + public function testcalc_score() { + $res = $this->attendance->calc_score($stud_id = null); + $this->assertTrue(is_null($res)); + //var_dump($res); + } + + /** + * Generate an array of all attendances available. + * @return array 2-dimensional array - every element contains 2 subelements (id, name) + */ + + public function testget_all_links() { + $_SESSION['id_session'] = 1; + $res = $this->attendance->get_all_links(); + if(!is_array($res)){ + $this->assertTrue(is_null($res)); + } else { + $this->assertTrue(is_array($res)); + } + $_SESSION['id_session'] = null; + //var_dump($res); + } + + /** + * @return string description + */ + + public function testget_description() { + $res = $this->attendance->get_description(); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testget_link() { + $res = $this->attendance->get_link(); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testget_name() { + $res = $this->attendance->get_name(); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testget_not_created_links() { + $res = $this->attendance->get_not_created_links(); + $this->assertTrue(is_array($res)); + //var_dump($res); + } + + public function testget_test_id() { + $res = $this->attendance->get_test_id(); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + public function testget_type_name() { + $res = $this->attendance->get_type_name(); + $this->assertTrue(is_string($res)); + //var_dump($res); + } + + /** + * Has anyone done this exercise yet ? + */ + + public function testhas_results() { + $res = $this->attendance->has_results(); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + public function testis_allowed_to_change_name() { + $res = $this->attendance->is_allowed_to_change_name(); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + public function testis_valid_link() { + $res = $this->attendance->is_valid_link(); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + public function testneeds_max() { + $res = $this->attendance->needs_max(); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + public function testneeds_name_and_description() { + $res = $this->attendance->needs_name_and_description(); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + public function testneeds_results() { + $res = $this->attendance->needs_results(); + $this->assertTrue(is_bool($res)); + //var_dump($res); + } + + public function __destruct() { + // The destructor acts like a global tearDown for the class + require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php'; + } +} +?>