calendar.lib.test.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 testAddWeek(){
  14. $timestamp=12;
  15. $num=1;
  16. $res = add_week($timestamp,$num);
  17. $this->assertTrue(is_numeric($res));
  18. //var_dump($res);
  19. }
  20. public function testAddMonth(){
  21. $timestamp=5;
  22. $num=1;
  23. $res = add_month($timestamp,$num);
  24. $this->assertTrue(is_numeric($res));
  25. //var_dump($res);
  26. }
  27. public function testAddYear(){
  28. $timestamp=9999;
  29. $num=1;
  30. $res = add_year($timestamp,$num);
  31. $this->assertTrue(is_numeric($res));
  32. //var_dump($res);
  33. }
  34. /**
  35. * Adds a repetitive item to the database
  36. * @param array Course info
  37. * @param int The original event's id
  38. * @param string Type of repetition
  39. * @param int Timestamp of end of repetition (repeating until that date)
  40. * @param array Original event's destination
  41. * @return boolean False if error, True otherwise
  42. */
  43. public function testAgendaAddRepeatItem(){
  44. //this function is not used or deprecated
  45. }
  46. public function testCalculateStartEndOfWeek(){
  47. $week_number=4;
  48. $year=2011;
  49. $res = calculate_start_end_of_week($week_number, $year);
  50. $this->assertTrue(is_array($res));
  51. $this->assertTrue($res);
  52. //var_dump($res);
  53. }
  54. public function testGetDayAgendaitems() {
  55. $courses_dbs=array();
  56. $month=01;
  57. $year=2010;
  58. $day='1';
  59. $res = get_day_agendaitems($courses_dbs, $month, $year, $day);
  60. $this->assertTrue(is_array($res));
  61. }
  62. public function testDeleteAgendaItem(){
  63. $id=1;
  64. $res = delete_agenda_item($id);
  65. $this->assertTrue(is_bool($res));
  66. }
  67. public function testDisplayMinimonthcalendar(){
  68. ob_start();
  69. global $DaysShort;
  70. $agendaitems=array('test','test2');
  71. $month=01;
  72. $year=2010;
  73. $monthName='';
  74. $res = display_minimonthcalendar($agendaitems, $month, $year, $monthName);
  75. ob_end_clean();
  76. $this->assertTrue(is_null($res));
  77. //var_dump($res);
  78. }
  79. public function testShowUserFilterForm(){
  80. ob_start();
  81. $res = show_user_filter_form();
  82. ob_end_clean();
  83. $this->assertTrue(is_null($res));
  84. }
  85. public function testIsRepeatedEvent() {
  86. //This is deprecated or not used
  87. }
  88. }