calendar.lib.test.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. class TestCalendar extends UnitTestCase
  3. {
  4. public function TestCalendar(){
  5. $this->UnitTestCase('Admin calendar library - main/admin/calendar.inc.test.php');
  6. }
  7. public function testToJavascript(){
  8. $res = to_javascript();
  9. $this->assertTrue($res);
  10. $this->assertTrue(is_string($res));
  11. //var_dump($res);
  12. }
  13. public function testStoreNewAgendaItem(){
  14. global $_user;
  15. $res_store = store_new_agenda_item();
  16. $this->assertTrue(is_numeric($res_store));
  17. //delete the new agenda item in the database
  18. if (is_numeric($res_store)) {
  19. $res_delete = delete_agenda_item($res_store);
  20. $this->assertTrue(is_numeric($res_store));
  21. }
  22. }
  23. public function testAddWeek(){
  24. $timestamp=12;
  25. $num=1;
  26. $res = add_week($timestamp,$num);
  27. $this->assertTrue(is_numeric($res));
  28. //var_dump($res);
  29. }
  30. public function testAddMonth(){
  31. $timestamp=5;
  32. $num=1;
  33. $res = add_month($timestamp,$num);
  34. $this->assertTrue(is_numeric($res));
  35. //var_dump($res);
  36. }
  37. public function testAddYear(){
  38. $timestamp=9999;
  39. $num=1;
  40. $res = add_year($timestamp,$num);
  41. $this->assertTrue(is_numeric($res));
  42. //var_dump($res);
  43. }
  44. /**
  45. * Adds a repetitive item to the database
  46. * @param array Course info
  47. * @param int The original event's id
  48. * @param string Type of repetition
  49. * @param int Timestamp of end of repetition (repeating until that date)
  50. * @param array Original event's destination
  51. * @return boolean False if error, True otherwise
  52. */
  53. public function testAgendaAddRepeatItem(){
  54. //this function is not used or deprecated
  55. }
  56. public function testCalculateStartEndOfWeek(){
  57. $week_number=4;
  58. $year=2011;
  59. $res = calculate_start_end_of_week($week_number, $year);
  60. $this->assertTrue(is_array($res));
  61. $this->assertTrue($res);
  62. //var_dump($res);
  63. }
  64. public function testGetDayAgendaitems() {
  65. $courses_dbs=array();
  66. $month=01;
  67. $year=2010;
  68. $day='1';
  69. $res = get_day_agendaitems($courses_dbs, $month, $year, $day);
  70. $this->assertTrue(is_array($res));
  71. }
  72. public function testDeleteAgendaItem(){
  73. $id=1;
  74. $res = delete_agenda_item($id);
  75. $this->assertTrue(is_bool($res));
  76. }
  77. public function testDisplayMinimonthcalendar(){
  78. ob_start();
  79. global $DaysShort;
  80. $agendaitems=array('test','test2');
  81. $month=01;
  82. $year=2010;
  83. $monthName='';
  84. $res = display_minimonthcalendar($agendaitems, $month, $year, $monthName);
  85. ob_end_clean();
  86. $this->assertTrue(is_null($res));
  87. //var_dump($res);
  88. }
  89. public function testShowUserFilterForm(){
  90. ob_start();
  91. $res = show_user_filter_form();
  92. ob_end_clean();
  93. $this->assertTrue(is_null($res));
  94. }
  95. public function testIsRepeatedEvent() {
  96. //This is deprecated or not used
  97. }
  98. }