classmanager.lib.test.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'classmanager.lib.php');
  3. class TestClassManager extends UnitTestCase {
  4. public function __construct(){
  5. $this->UnitTestCase('Class (students) manager library - main/inc/lib/classmanager.lib.test.php');
  6. }
  7. function testAddUser() {
  8. $user_id='1';
  9. $class_id='1';
  10. $res=ClassManager::add_user($user_id, $class_id);
  11. $this->assertNull($res);
  12. $this->assertTrue(is_null($res));
  13. }
  14. function testclass_name_exists() {
  15. $name='arthur';
  16. $res=ClassManager::class_name_exists($name);
  17. $this->assertTrue(is_bool($res));
  18. }
  19. function testCreateClass() {
  20. $name='new class';
  21. $res=ClassManager::create_class($name);
  22. $this->assertTrue(is_bool($res));
  23. }
  24. function testDeleteClass() {
  25. $class_id='new class';
  26. $res=ClassManager::delete_class($class_id);
  27. $this->assertTrue(is_null($res));
  28. }
  29. function testGetClassId() {
  30. $name='new class';
  31. $res=ClassManager::get_class_id($name);
  32. $this->assertTrue(is_numeric($res));
  33. }
  34. function testGetClassInfo() {
  35. $class_id='1';
  36. $res=ClassManager::get_class_info($class_id);
  37. $this->assertTrue(is_array($res));
  38. }
  39. function testGetClassesInCourse() {
  40. $course_code='FDI';
  41. $res=ClassManager::get_classes_in_course($course_code);
  42. $this->assertTrue(is_array($res));
  43. }
  44. function testGetCourses() {
  45. $class_id='1';
  46. $res=ClassManager::get_courses($class_id);
  47. $this->assertTrue(is_array($res));
  48. }
  49. function testGetUsers() {
  50. $class_id='1';
  51. $res=ClassManager::get_users($class_id);
  52. $this->assertTrue(is_array($res));
  53. }
  54. function testSetName() {
  55. $name='new class';
  56. $class_id='1';
  57. $res=ClassManager::set_name($name, $class_id);
  58. $this->assertTrue(is_null($res));
  59. }
  60. function testSubscribeToCourse() {
  61. $class_id='1';
  62. $course_code='FDI';
  63. $res=ClassManager::subscribe_to_course($class_id,$course_code);
  64. $this->assertTrue(is_null($res));
  65. }
  66. function testUnsubscribeFromCourse() {
  67. $class_id='1';
  68. $course_code='FDI';
  69. $res=ClassManager::unsubscribe_from_course($class_id, $course_code);
  70. $this->assertTrue(is_null($res));
  71. }
  72. function testUnsubscribeUser() {
  73. $user_id='1';
  74. $class_id='1';
  75. $res=ClassManager::unsubscribe_user($user_id, $class_id);
  76. $this->assertTrue(is_null($res));
  77. }
  78. }
  79. ?>