123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- <?php
- class TestCategoryClass extends UnitTestCase {
- public function TestCategoryClass() {
- $this->UnitTestCase('Test Category Class');
- }
- public function __construct() {
- $this->UnitTestCase('Gradebook categories library - main/gradebook/lib/be/category.class.test.php');
-
- TestManager::create_test_course('COURSECATEGORYCLASS');
- $this->category = new Category();
- $this->category->set_id(1);
- $this->category->set_name('test');
- $this->category->set_description('test description');
- $this->category->set_user_id(1);
- $this->category->set_course_code('COURSECATEGORYCLASS');
- $this->category->set_certificate_min_score(20);
- $this->category->set_parent_id(0);
- $this->category->set_session_id(1);
- $this->category->set_weight(1);
- $this->category->set_visible(1);
- }
-
- public function testadd() {
- $_SESSION['id_session'] = 1;
- $res = $this->category->add();
- $this->assertTrue(is_null($res));
- $_SESSION['id_session'] = null;
-
- }
-
- public function testapply_visibility_to_children() {
- $res = $this->category->apply_visibility_to_children();
- $this->assertTrue(is_null($res));
-
- }
-
- public function testcalc_score() {
- $res = $this->category->calc_score($stud_id = null);
- $this->assertTrue(is_null($res));
-
- }
-
- public function testdoes_name_exist() {
- $name = 'test';
- $parent=1;
- $res = $this->category->does_name_exist($name, $parent);
- $this->assertTrue(is_bool($res));
-
- }
-
- public function testfind_category() {
- $name_mask = 'test';
- $allcat=array();
- $res = $this->category->find_category($name_mask,$allcat);
- $this->assertTrue(is_array($res));
-
- }
-
- public function testget_all_courses() {
- $user_id = 1;
- $res = $this->category->get_all_courses($user_id);
- $this->assertTrue(is_array($res));
-
- }
- public function testget_certificate_min_score() {
- $res = $this->category->get_certificate_min_score();
- $this->assertTrue(is_numeric($res));
-
- }
- public function testget_course_code() {
- $res = $this->category->get_course_code();
- $this->assertTrue(is_string($res));
-
- }
- public function testget_description() {
- $res = $this->category->get_description();
- $this->assertTrue(is_string($res));
-
- }
-
- public function testget_evaluations() {
- $res = $this->category->get_evaluations($stud_id = null, $recursive = false);
- $this->assertTrue(is_array($res));
-
- }
- public function testget_icon_name() {
- $res = $this->category->get_icon_name();
- $this->assertTrue(is_string($res));
-
- }
- public function testget_id() {
- $res = $this->category->get_id();
- $this->assertTrue(is_numeric($res));
-
- }
- public function testget_independent_categories_with_result_for_student() {
- $cat_id=1;
- $stud_id=1;
- $res = $this->category->get_independent_categories_with_result_for_student($cat_id, $stud_id, $cats = array());
- $this->assertTrue(is_array($res));
-
- }
- public function testget_item_type() {
- $res = $this->category->get_item_type();
- $this->assertTrue(is_string($res));
-
- }
- public function testget_links() {
- $res = $this->category->get_links($stud_id = null, $recursive = false);
- $this->assertTrue(is_array($res));
-
- }
- public function testget_name() {
- $res = $this->category->get_name();
- $this->assertTrue(is_string($res));
-
- }
- public function testget_not_created_course_categories() {
- $user_id = 1;
- $res = $this->category->get_not_created_course_categories($user_id);
- $this->assertTrue(is_array($res));
-
- }
- public function testget_parent_id() {
- $res = $this->category->get_parent_id();
- $this->assertTrue(is_numeric($res));
-
- }
-
- public function testget_root_categories_for_student() {
- $stud_id=1;
- $res = $this->category->get_root_categories_for_student($stud_id, $course_code = null, $session_id = null);
- $this->assertTrue(is_array($res));
-
- }
-
- public function testget_root_categories_for_teacher() {
- $user_id=1;
- $res = $this->category->get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null);
- $this->assertTrue(is_array($res));
-
- }
- public function testget_session_id() {
- $user_id=1;
- $res = $this->category->get_session_id($user_id, $course_code = null, $session_id = null);
- $this->assertTrue(is_numeric($res));
-
- }
-
- public function testget_subcategories() {
- $res = $this->category->get_subcategories($stud_id = null, $course_code = null, $session_id = null);
- $this->assertTrue(is_array($res));
-
- }
-
- public function testget_target_categories() {
- $res = $this->category->get_target_categories();
- if(is_array($res)) {
- $this->assertTrue(is_array($res));
- } else {
- $this->assertTrue(is_null($res));
- }
- var_dump($res);
- }
-
- public function testget_tree() {
- $res = $this->category->get_tree();
- $this->assertTrue(is_array($res));
-
- }
- public function testget_user_id() {
- $res = $this->category->get_user_id();
- $this->assertTrue(is_numeric($res));
-
- }
- public function testget_weight() {
- $res = $this->category->get_weight();
- $this->assertTrue(is_numeric($res));
-
- }
-
- public function testhas_evaluations_with_results_for_student() {
- $stud_id = 1;
- $res = $this->category->has_evaluations_with_results_for_student($stud_id);
- $this->assertTrue(is_bool($res));
-
- }
-
- public function testis_certificate_available() {
- $user_id = 1;
- $res = $this->category->is_certificate_available($user_id);
- $this->assertTrue(is_bool($res));
-
- }
-
- public function testis_course() {
- $res = $this->category->is_course();
- $this->assertTrue(is_bool($res));
-
- }
-
- public function testis_movable() {
- $res = $this->category->is_movable();
- $this->assertTrue(is_bool($res));
-
- }
- public function testis_visible() {
- $res = $this->category->is_visible();
- $this->assertTrue(is_numeric($res));
-
- }
-
- public function testload() {
- $res = $this->category->load($id = null, $user_id = null, $course_code = null, $parent_id = null, $visible = null, $session = null, $show_session_categories = true);
- $this->assertTrue(is_array($res));
-
- }
-
- public function testmove_to_cat() {
- $res = $this->category->move_to_cat($this->category);
- $this->assertTrue(is_null($res));
-
- }
-
- public function testsave() {
- $res = $this->category->save();
- $this->assertTrue(is_null($res));
-
- }
-
- public function testshow_message_resource_delete() {
- $course_id = 1;
- $res = $this->category->show_message_resource_delete($course_id);
- $this->assertTrue(is_bool($res));
-
- }
-
- public function testshows_all_information_an_category() {
- $res = $this->category->shows_all_information_an_category($selectcat='');
- $this->assertTrue(is_null($res));
-
- }
-
- public function testupdate_category_delete() {
- $course_id = 1;
- $res = $this->category->update_category_delete($course_id);
- $this->assertTrue(is_null($res));
-
- }
-
- public function testdelete() {
- $res = $this->category->delete();
- $this->assertTrue(is_null($res));
-
- }
-
- public function testdelete_all() {
- $res = $this->category->delete_all();
- $this->assertTrue(is_null($res));
-
- }
- public function __destruct() {
-
- TestManager::delete_test_course('COURSECATEGORYCLASS');
- }
- }
- ?>
|