attendancelink.class.test.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. class TestAttendanceLink extends UnitTestCase {
  3. public function TestAttendanceLink() {
  4. $this->UnitTestCase('Test Attendance Link');
  5. }
  6. public function __construct() {
  7. $this->UnitTestCase('Gradebook attendances library - main/gradebook/lib/be/attendancelink.class.test.php');
  8. // The constructor acts like a global setUp for the class
  9. global $date;
  10. TestManager::create_test_course('COURSEATTENDANCELINK');
  11. $this->attendance = new AttendanceLink();
  12. $this->attendance->set_course_code('COURSEATTENDANCELINK');
  13. $this->attendance->set_id (1);
  14. $this->attendance->set_type (LINK_ATTENDANCE);
  15. $this->attendance->set_ref_id (1) ;
  16. $this->attendance->set_user_id (1);
  17. $this->attendance->set_category_id(1);
  18. $this->attendance->set_date ($date);
  19. $this->attendance->set_weight (1);
  20. $this->attendance->set_visible (1);
  21. $this->attendance->set_session_id(1);
  22. }
  23. public function testcalc_score() {
  24. $res = $this->attendance->calc_score($stud_id = null);
  25. $this->assertTrue(is_null($res));
  26. //var_dump($res);
  27. }
  28. /**
  29. * Generate an array of all attendances available.
  30. * @return array 2-dimensional array - every element contains 2 subelements (id, name)
  31. */
  32. public function testget_all_links() {
  33. $_SESSION['id_session'] = 1;
  34. $res = $this->attendance->get_all_links();
  35. if(!is_array($res)){
  36. $this->assertTrue(is_null($res));
  37. } else {
  38. $this->assertTrue(is_array($res));
  39. }
  40. $_SESSION['id_session'] = null;
  41. //var_dump($res);
  42. }
  43. /**
  44. * @return string description
  45. */
  46. public function testget_description() {
  47. $res = $this->attendance->get_description();
  48. $this->assertTrue(is_string($res));
  49. //var_dump($res);
  50. }
  51. public function testget_link() {
  52. $res = $this->attendance->get_link();
  53. $this->assertTrue(is_string($res));
  54. //var_dump($res);
  55. }
  56. public function testget_name() {
  57. $res = $this->attendance->get_name();
  58. $this->assertTrue(is_string($res));
  59. //var_dump($res);
  60. }
  61. public function testget_not_created_links() {
  62. $res = $this->attendance->get_not_created_links();
  63. $this->assertTrue(is_array($res));
  64. //var_dump($res);
  65. }
  66. public function testget_test_id() {
  67. $res = $this->attendance->get_test_id();
  68. $this->assertTrue(is_string($res));
  69. //var_dump($res);
  70. }
  71. public function testget_type_name() {
  72. $res = $this->attendance->get_type_name();
  73. $this->assertTrue(is_string($res));
  74. //var_dump($res);
  75. }
  76. /**
  77. * Has anyone done this exercise yet ?
  78. */
  79. public function testhas_results() {
  80. $res = $this->attendance->has_results();
  81. $this->assertTrue(is_bool($res));
  82. //var_dump($res);
  83. }
  84. public function testis_allowed_to_change_name() {
  85. $res = $this->attendance->is_allowed_to_change_name();
  86. $this->assertTrue(is_bool($res));
  87. //var_dump($res);
  88. }
  89. public function testis_valid_link() {
  90. $res = $this->attendance->is_valid_link();
  91. $this->assertTrue(is_bool($res));
  92. //var_dump($res);
  93. }
  94. public function testneeds_max() {
  95. $res = $this->attendance->needs_max();
  96. $this->assertTrue(is_bool($res));
  97. //var_dump($res);
  98. }
  99. public function testneeds_name_and_description() {
  100. $res = $this->attendance->needs_name_and_description();
  101. $this->assertTrue(is_bool($res));
  102. //var_dump($res);
  103. }
  104. public function testneeds_results() {
  105. $res = $this->attendance->needs_results();
  106. $this->assertTrue(is_bool($res));
  107. //var_dump($res);
  108. }
  109. public function __destruct() {
  110. // The destructor acts like a global tearDown for the class
  111. TestManager::delete_test_course('COURSEATTENDANCELINK');
  112. }
  113. }
  114. ?>