system_announcements.lib.test.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'system_announcements.lib.php');
  3. class TestSystemAnnouncementManager extends UnitTestCase {
  4. public function __construct(){
  5. $this->UnitTestCase('System announcements library - main/inc/lib/system_announcements.lib.test.php');
  6. }
  7. function test_add_announcement() {
  8. $title='Anuncio';
  9. $content='Contenido del anuncio';
  10. $date_start='2010-01-02';
  11. $date_end='2010-01-03';
  12. $visible_teacher = 0;
  13. $visible_student = 0;
  14. $visible_guest = 0;
  15. $lang = null;
  16. $send_mail=0;
  17. $res=SystemAnnouncementManager::add_announcement($title, $content, $date_start, $date_end, $visible_teacher, $visible_student, $visible_guest, $lang, $send_mail);
  18. $this->assertTrue(is_bool($res));
  19. }
  20. function test_count_nb_announcement() {
  21. $res=SystemAnnouncementManager::count_nb_announcement($start = 0,$user_id = '');
  22. $this->assertTrue(is_numeric($res));
  23. }
  24. function test_delete_announcement() {
  25. $id='';
  26. $res=SystemAnnouncementManager::delete_announcement($id);
  27. $this->assertTrue(is_bool($res));
  28. }
  29. function test_display_all_announcements() {
  30. $visible='';
  31. $res=SystemAnnouncementManager::display_all_announcements($visible, $id = -1,$start = 0,$user_id='');
  32. $this->assertTrue(is_null($res));
  33. }
  34. function test_display_announcements() {
  35. $visible='';
  36. $res=SystemAnnouncementManager::display_announcements($visible, $id = -1);
  37. $this->assertNull($res);
  38. }
  39. function test_display_arrow() {
  40. $user_id='';
  41. $res=SystemAnnouncementManager::display_arrow($user_id);
  42. $this->assertTrue(is_null($res));
  43. //var_dump($res);
  44. }
  45. function test_get_all_announcements() {
  46. $res=SystemAnnouncementManager::get_all_announcements();
  47. $this->assertTrue(is_array($res));
  48. //var_dump($res);
  49. }
  50. function test_get_announcement() {
  51. $id='';
  52. $res=SystemAnnouncementManager::get_announcement($id);
  53. $this->assertTrue(is_bool($res));
  54. //var_dump($res);
  55. }
  56. function test_send_system_announcement_by_email_is_true_on_teacher_null() {
  57. global $_user, $_setting, $charset;
  58. $title = $content = $teacher = $student = '';
  59. $res=SystemAnnouncementManager::send_system_announcement_by_email($title,$content,$teacher, $student);
  60. $this->assertTrue($res);
  61. }
  62. //Test removed until we can make sure the e-mail is sent to a valid e-mail address, otherwise the function returns false because the e-mail sending fails
  63. /*
  64. function test_send_system_announcement_by_email_is_true_on_teacher_not_null() {
  65. global $_user, $_setting, $charset;
  66. $title = 'abc';
  67. $content = 'bcd';
  68. $student = 0;
  69. $teacher = 1;
  70. $res=SystemAnnouncementManager::send_system_announcement_by_email($title,$content,$teacher, $student);
  71. $this->assertTrue($res);
  72. }*/
  73. function test_set_visibility() {
  74. $announcement_id = $user = $visible='';
  75. $res=SystemAnnouncementManager::set_visibility($announcement_id, $user, $visible);
  76. $this->assertTrue(is_bool($res));
  77. //var_dump($res);
  78. }
  79. function test_update_announcement() {
  80. $id=1;
  81. $title='Anuncio';
  82. $content='Contenido';
  83. $date_start='2010-01-02';
  84. $date_end='2010-01-03';
  85. $send_mail=0;
  86. ob_start();
  87. $res=SystemAnnouncementManager::update_announcement($id, $title, $content, $date_start, $date_end, $visible_teacher = 0, $visible_student = 0, $visible_guest = 0,$lang=null, $send_mail);
  88. $this->assertTrue(is_bool($res));
  89. ob_end_clean();
  90. //var_dump($res);
  91. }
  92. }
  93. ?>