Improve test Notebook CT#191

skala
Carlos Vargas 15 years ago
parent 3dd25788c2
commit 6434532b89
  1. 80
      tests/main/inc/lib/notebook.lib.test.php
  2. 2
      tests/test_manager.inc.php
  3. 4
      tests/test_suite.php

@ -1,62 +1,64 @@
<?php <?php
require_once(api_get_path(LIBRARY_PATH).'notebook.lib.php');
//require_once api_get_path(SYS_CODE_PATH).'inc/global.inc.php';
class TestNotebook extends UnitTestCase { class TestNotebook extends UnitTestCase {
public function __construct() {
TestManager::create_test_course('COURSENOTEBOOK');
}
function testJavascriptNotebook() { public function testJavascriptNotebook() {
ob_start(); $res = NotebookManager::javascript_notebook(null);
$values =array(); $lang = get_lang("NoteConfirmDelete");
$res = NotebookManager::javascript_notebook($values); $this->assertTrue(is_string($res));
$this->assertTrue(is_string($res)); $this->assertPattern('/'.addslashes($lang).'/m',$res);
ob_end_clean();
//var_dump($res);
} }
function testSaveNote() { public function testSaveNote() {
ob_start(); $resNull = NotebookManager::save_note(null);
$values =array(); $this->assertFalse($resNull);
$res = NotebookManager::save_note($values); $resFalse = NotebookManager::save_note(-1);
$this->assertFalse($resFalse);
$res = NotebookManager::save_note(array());
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
ob_end_clean();
//var_dump($res);
} }
function testGetNoteInformation() { public function testGetNoteInformation() {
ob_start(); $resNull = NotebookManager::get_note_information(null);
$notebook_id=1; $this->assertFalse($resNull);
$res = NotebookManager::get_note_information($notebook_id); $resFalse = NotebookManager::get_note_information(-1);
$this->assertTrue(!(bool)$res); $this->assertFalse($resFalse);
ob_end_clean(); $res = NotebookManager::get_note_information(1);
//var_dump($res); $this->assertTrue(is_array($res));
} }
function testUpdateNote() { public function testUpdateNote() {
ob_start(); $resNull = NotebookManager::update_note(null);
$values=array(); $this->assertFalse($resNull);
$res = NotebookManager::update_note($values); $resFalse = NotebookManager::update_note('char');
$this->assertTrue(is_bool($res)); $this->assertFalse($resFalse);
ob_end_clean(); $res = NotebookManager::update_note(array());
//var_dump($res); $this->assertTrue(is_bool($res));
} }
function testDisplayNotes() { public function testDisplayNotes() {
ob_start(); ob_start();
$res = NotebookManager::display_notes(); $res = NotebookManager::display_notes();
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
ob_end_clean(); ob_end_clean();
//var_dump($res);
} }
function testDeleteNote() { public function testDeleteNote() {
ob_start(); $resNull = NotebookManager::delete_note(null);
$notebook_id=1; $this->assertFalse($resNull);
$res = NotebookManager::delete_note($notebook_id); $resFalse = NotebookManager::delete_note(-1);
$this->assertFalse($resFalse);
$res = NotebookManager::delete_note(1);
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
ob_end_clean();
//var_dump($res);
} }
public function __destruct() {
TestManager::delete_test_course('COURSENOTEBOOK');
}
} }
?> ?>

@ -68,6 +68,7 @@ require_once $maindir.'gradebook/lib/be/result.class.php';
require_once $maindir.'gradebook/lib/be/forumthreadlink.class.php'; require_once $maindir.'gradebook/lib/be/forumthreadlink.class.php';
/**Files inside '/../main/lib/' */ /**Files inside '/../main/lib/' */
require_once $libdir.'urlmanager.lib.php'; require_once $libdir.'urlmanager.lib.php';
require_once $libdir.'fileDisplay.lib.php'; require_once $libdir.'fileDisplay.lib.php';
@ -80,6 +81,7 @@ require_once $libdir.'xmd.lib.php';
require_once $libdir.'formvalidator/FormValidator.class.php'; require_once $libdir.'formvalidator/FormValidator.class.php';
require_once $libdir.'exercise_show_functions.lib.php'; require_once $libdir.'exercise_show_functions.lib.php';
require_once $libdir.'fileManage.lib.php'; require_once $libdir.'fileManage.lib.php';
require_once $libdir.'notebook.lib.php';
/**This files need be inside a buffering to clean the objects*/ /**This files need be inside a buffering to clean the objects*/
ob_start(); ob_start();

@ -110,8 +110,8 @@ class TestsSuite extends TestSuite {
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/webservices/user_import/import.lib.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'/main/webservices/user_import/import.lib.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/work/work.lib.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'/main/work/work.lib.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/glossary.lib.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/glossary.lib.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/notebook.lib.test.php'); */$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/notebook.lib.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/permissions/permissions_functions.inc.test.php'); /*$this->addFile(api_get_path(SYS_TEST_PATH).'/main/permissions/permissions_functions.inc.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/resourcelinker/resourcelinker.inc.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'/main/resourcelinker/resourcelinker.inc.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/survey/survey.lib.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'/main/survey/survey.lib.test.php');
$this->addFile(api_get_path(SYS_TEST_PATH).'/main/dropbox/dropbox_class.inc.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'/main/dropbox/dropbox_class.inc.test.php');

Loading…
Cancel
Save