notebook.lib.test.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. class TestNotebook extends UnitTestCase {
  3. public function __construct() {
  4. $this->UnitTestCase('Glossary library - main/inc/lib/notebook.lib.test.php');
  5. TestManager::create_test_course('COURSENOTEBOOK');
  6. }
  7. public function __destruct() {
  8. TestManager::delete_test_course('COURSENOTEBOOK');
  9. }
  10. public function testJavascriptNotebookOutputsString() {
  11. $res = NotebookManager::javascript_notebook(null);
  12. $lang = get_lang("NoteConfirmDelete");
  13. $this->assertTrue(is_string($res));
  14. $this->assertPattern('/script/m',$res);
  15. $this->assertPattern('/\/script/m',$res);
  16. }
  17. public function testSaveNoteIsFalseWhenNoteIsNull() {
  18. $resNull = NotebookManager::save_note(null);
  19. $this->assertFalse($resNull);
  20. }
  21. public function testSaveNoteIsFalseWhenNoteIsNegativeInt() {
  22. $resFalse = NotebookManager::save_note(-1);
  23. $this->assertFalse($resFalse);
  24. }
  25. public function testSaveNoteIsFalseWhenNoteIsEmptyArray() {
  26. $res = NotebookManager::save_note(array());
  27. $this->assertTrue(is_bool($res));
  28. }
  29. public function testGetNoteInformationIsFalseWhenNoteIsNull() {
  30. $resNull = NotebookManager::get_note_information(null);
  31. $this->assertFalse($resNull);
  32. }
  33. public function testGetNoteInformationIsFalseWhenNoteIsNegativeInt() {
  34. $resFalse = NotebookManager::get_note_information(-1);
  35. $this->assertFalse($resFalse);
  36. }
  37. public function testGetNoteInformationIsArray() {
  38. $res = NotebookManager::get_note_information(1);
  39. $this->assertTrue(is_array($res));
  40. }
  41. public function testUpdateNoteIsFalseWhenNoteIsNull() {
  42. $resNull = NotebookManager::update_note(null);
  43. $this->assertFalse($resNull);
  44. }
  45. public function testUpdateNoteIsFalseWhenNoteDoesNotExist() {
  46. $resFalse = NotebookManager::update_note('char');
  47. $this->assertFalse($resFalse);
  48. }
  49. public function testUpdateNoteIsFalseWhenNoteIsEmptyArray() {
  50. $res = NotebookManager::update_note(array());
  51. $this->assertFalse($res);
  52. }
  53. public function testDisplayNotes() {
  54. ob_start();
  55. $res = NotebookManager::display_notes();
  56. $this->assertTrue(is_null($res));
  57. ob_end_clean();
  58. }
  59. public function testDeleteNoteIsFalseWhenNoteIsNull() {
  60. $resNull = NotebookManager::delete_note(null);
  61. $this->assertFalse($resNull);
  62. }
  63. public function testDeleteNoteIsFalseWhenNoteIsNegative() {
  64. $resFalse = NotebookManager::delete_note(-1);
  65. $this->assertFalse($resFalse);
  66. }
  67. public function testDeleteNoteISFalseWhenNoteDoesNotExist() {
  68. $res = NotebookManager::delete_note(1);
  69. $this->assertFalse($res);
  70. }
  71. }