123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- <?php
- require_once(api_get_path(LIBRARY_PATH).'document.lib.php');
- class TestDocumentManager extends UnitTestCase {
- public function __construct() {
- $this->UnitTestCase('Document Manager library - main/inc/lib/document.lib.test.php');
- }
-
- public function testcheck_readonly() {
- global $user_id, $_course;
- $file='';
- $res=DocumentManager::check_readonly($_course,$user_id,$file);
- $this->assertTrue(is_bool($res));
- }
-
- function testdelete_document() {
- global $_course;
- $path='';
- $base_work_dir='';
- ob_start();
- $res=DocumentManager::delete_document($_course, $path, $base_work_dir);
- ob_end_clean();
- $this->assertTrue(is_bool($res));
- }
-
- function testdelete_document_from_search_engine() {
- global $cidReq;
- $course_id = $cidReq;
- $document_id='';
- $res=DocumentManager::delete_document_from_search_engine($course_id, $document_id);
- $this->assertNull($res);
- }
-
- function testfile_get_mime_type() {
- $filename='';
- $res=DocumentManager::file_get_mime_type($filename);
- $this->assertTrue(is_string($res));
- }
-
- function testfile_send_for_download() {
- $full_file_name='';
- $forced = false;
- $name = '';
- $res=DocumentManager::file_send_for_download($full_file_name, $forced, $name);
- $this->assertTrue(is_bool($res));
- }
-
-
- function testget_all_document_data() {
- global $_course;
- $path = '/';
- $to_group_id = 0;
- $to_user_id = NULL;
- $can_see_invisible = false;
- $res=DocumentManager::get_all_document_data($_course, $path,
- $to_group_id, $to_user_id, $can_see_invisible);
- if (empty($_course['dbName'])) {
- $this->assertFalse($res);
- } else {
- $this->assertTrue(is_array($res));
- }
- }
-
- function testget_all_document_folders() {
- global $_course;
- $to_group_id = '0';
- $can_see_invisible = false;
- $res = DocumentManager::get_all_document_folders($_course, $to_group_id, $can_see_invisible);
- if (empty($_course['dbName'])) {
- $this->assertFalse($res);
- } else {
- $this->assertTrue(is_array($res));
- }
- }
-
-
-
- function testget_document_id() {
- global $_course;
- $path = Database::escape_string($path);
- $res=DocumentManager::get_document_id($_course, $path);
- $this->assertTrue(is_bool($res));
- }
-
- function testis_folder() {
- global $_course;
- $document_id = 1;
- $res=DocumentManager::is_folder($_course, $document_id);
- $this->assertTrue(is_bool($res));
- }
-
- function testis_visible() {
- global $_course;
- $doc_path = Database::escape_string($doc_path);
- $res=DocumentManager::is_visible($doc_path, $_course);
- $this->assertTrue(is_bool($res));
- }
-
- function testset_document_as_template() {
- global $_course,$_user;
- $title='test';
- $description='test';
- $document_id_for_template='';
- $couse_code=$_course;
- $user_id=$_user;
- $image='';
- $res=DocumentManager::set_document_as_template($title, $description,
- $document_id_for_template,
- $couse_code, $user_id,
- $image
- );
- $this->assertTrue(is_bool($res));
- }
- function testdocuments_total_space() {
- $to_group_id='0';
- $res= DocumentManager::documents_total_space($to_group_id);
- if(!is_null($res)):
- $this->assertTrue(is_numeric($res));
- endif;
- }
- function testenough_space() {
- $file_size='';
- $max_dir_space='';
- $res= DocumentManager::enough_space($file_size, $max_dir_space);
- $this->assertTrue(is_bool($res));
- }
-
-
-
-
- function testunset_document_as_template() {
- $document_id=Database::escape_string($document_id);
- $course_code=Database::escape_string($course_code);
- $user_id=Database::escape_string($user_id);
- $res=DocumentManager::unset_document_as_template($document_id,
- $course_code,
- $user_id
- );
- $this->assertNull($res);
-
- }
-
- }
- ?>
|