Feature #576 - Formal tests about the functions api_get_permissions_for_new_directories() and api_get_permissions_for_new_files() have been added.

skala
Ivan Tcholakov 15 years ago
parent 1405a36150
commit 81f294fa4e
  1. 52
      tests/main/inc/lib/main_api.lib.test.php
  2. 80
      tests/main/inc/lib/main_api.lib.test_standalone.php

@ -172,7 +172,7 @@ class TestMainApi extends UnitTestCase {
function testApiSessionClear() {
$variable = 'test';
if (!headers_sent()) {
if (!headers_sent()) {
$res=api_session_clear($variable);
}
$this->assertTrue(is_null($res));
@ -180,7 +180,7 @@ class TestMainApi extends UnitTestCase {
}
function testApiSessionDestroy(){
if (!headers_sent()) {
if (!headers_sent()) {
$res=api_session_destroy();
}
$this->assertTrue(is_null($res));
@ -257,7 +257,7 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue(is_numeric($res));
//var_dump($res);
}
function testApiGetSessionName(){
$session_id='';
@ -279,7 +279,7 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue(is_string($res));
//var_dump($res);
}
/* function deprecated
function testGetLang(){
global $language_interface, $language_interface_initial_value, $language_file,$variable;
@ -582,6 +582,22 @@ class TestMainApi extends UnitTestCase {
//var_dump($res);
}
public function testApiGetPermissionsForNewDirectories() {
$perm = trim(api_get_setting('permissions_for_new_directories'));
$perm = octdec(!empty($perm) ? $perm : '0777');
$res = api_get_permissions_for_new_directories();
$this->assertTrue($res === $perm);
//var_dump($res);
}
public function testApiGetPermissionsForNewFiles() {
$perm = trim(api_get_setting('permissions_for_new_files'));
$perm = octdec(!empty($perm) ? $perm : '0666');
$res = api_get_permissions_for_new_files();
$this->assertTrue($res === $perm);
//var_dump($res);
}
function testCopyr(){
$source = api_get_path(SYS_CODE_PATH).'app_share/DokeosAppShare.exe';
$dest = '';
@ -590,7 +606,7 @@ class TestMainApi extends UnitTestCase {
//var_dump($res);
}
function testApiChmod_R(){
function testApiChmod_R(){
$dirname = api_get_path(SYS_LANG_PATH);
$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4);
if ($perm_dir != '0777') {
@ -601,7 +617,7 @@ class TestMainApi extends UnitTestCase {
$filemode = '0777';
$res = api_chmod_R($path, $filemode);
unlink($path);
$this->assertTrue($res);
$this->assertTrue($res);
}
}
@ -618,7 +634,7 @@ class TestMainApi extends UnitTestCase {
}
function testApiStatusKey(){
$status = 'user';
$status = 'user';
$res = api_status_key($status);
$this->assertTrue(is_numeric($res));
}
@ -849,20 +865,20 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue($tool_list);
//var_dump($res);
}
public function TestDeleteCourse() {
$code = 'COURSEX';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
public function TestDeleteCourse() {
$code = 'COURSEX';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
}
closedir($handle);
}
}
}
}
?>

@ -56,7 +56,7 @@ class TestMainApi extends UnitTestCase {
$message[] = '';
$message[] = '';
$message[] = 'Changed behaviour of the function api_get_path() after Dokeos 1.8.6.1, i.e. as of Dokeos 1.8.6.2.';
$message[] = 'Changed behaviour of the function api_get_path() after Dokeos 1.8.6.1, i.e. as of Chamilo 1.8.6.2.';
$message[] = '---------------------------------------------------------------------------------------------------------------';
$message[] = '';
$message[] = 'Old behaviour (1.8.6.1) api_get_path(INCLUDE_PATH) = '.api_get_path_1_8_6_1(INCLUDE_PATH).'   |   '.'New behaviour (1.8.6.2) api_get_path(INCLUDE_PATH) = '.api_get_path(INCLUDE_PATH);
@ -336,45 +336,45 @@ class TestMainApi extends UnitTestCase {
}
/**
* Returns a full path to a certain Dokeos area, which you specify
* through a parameter.
*
* See $_configuration['course_folder'] in the configuration.php
* to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
*
* @param one of the following constants:
* WEB_SERVER_ROOT_PATH, SYS_SERVER_ROOT_PATH,
* WEB_PATH, SYS_PATH, REL_PATH, WEB_COURSE_PATH, SYS_COURSE_PATH,
* REL_COURSE_PATH, REL_CODE_PATH, WEB_CODE_PATH, SYS_CODE_PATH,
* SYS_LANG_PATH, WEB_IMG_PATH, GARBAGE_PATH, WEB_PLUGIN_PATH, SYS_PLUGIN_PATH, WEB_ARCHIVE_PATH, SYS_ARCHIVE_PATH,
* INCLUDE_PATH, WEB_LIBRARY_PATH, LIBRARY_PATH, CONFIGURATION_PATH
*
* @example assume that your server root is /var/www/ dokeos is installed in a subfolder dokeos/ and the URL of your campus is http://www.mydokeos.com
* The other configuration paramaters have not been changed.
* The different api_get_paths will give
* WEB_SERVER_ROOT_PATH http://www.mydokeos.com/
* SYS_SERVER_ROOT_PATH /var/www/ - This is the physical folder where the system Dokeos has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
* WEB_PATH http://www.mydokeos.com/dokeos/
* SYS_PATH /var/www/dokeos/
* REL_PATH dokeos/
* WEB_COURSE_PATH http://www.mydokeos.com/dokeos/courses/
* SYS_COURSE_PATH /var/www/dokeos/courses/
* REL_COURSE_PATH /dokeos/courses/
* REL_CODE_PATH /dokeos/main/
* WEB_CODE_PATH http://www.mydokeos.com/dokeos/main/
* SYS_CODE_PATH /var/www/dokeos/main/
* SYS_LANG_PATH /var/www/dokeos/main/lang/
* WEB_IMG_PATH http://www.mydokeos.com/dokeos/main/img/
* GARBAGE_PATH
* WEB_PLUGIN_PATH http://www.mydokeos.com/dokeos/plugin/
* SYS_PLUGIN_PATH /var/www/dokeos/plugin/
* WEB_ARCHIVE_PATH http://www.mydokeos.com/dokeos/archive/
* SYS_ARCHIVE_PATH /var/www/dokeos/archive/
* INCLUDE_PATH /var/www/dokeos/main/inc/
* WEB_LIBRARY_PATH http://www.mydokeos.com/dokeos/main/inc/lib/
* LIBRARY_PATH /var/www/dokeos/main/inc/lib/
* CONFIGURATION_PATH /var/www/dokeos/main/inc/conf/
*/
* Returns a full path to a certain Dokeos area, which you specify
* through a parameter.
*
* See $_configuration['course_folder'] in the configuration.php
* to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
*
* @param one of the following constants:
* WEB_SERVER_ROOT_PATH, SYS_SERVER_ROOT_PATH,
* WEB_PATH, SYS_PATH, REL_PATH, WEB_COURSE_PATH, SYS_COURSE_PATH,
* REL_COURSE_PATH, REL_CODE_PATH, WEB_CODE_PATH, SYS_CODE_PATH,
* SYS_LANG_PATH, WEB_IMG_PATH, GARBAGE_PATH, WEB_PLUGIN_PATH, SYS_PLUGIN_PATH, WEB_ARCHIVE_PATH, SYS_ARCHIVE_PATH,
* INCLUDE_PATH, WEB_LIBRARY_PATH, LIBRARY_PATH, CONFIGURATION_PATH
*
* @example assume that your server root is /var/www/ dokeos is installed in a subfolder dokeos/ and the URL of your campus is http://www.mydokeos.com
* The other configuration paramaters have not been changed.
* The different api_get_paths will give
* WEB_SERVER_ROOT_PATH http://www.mydokeos.com/
* SYS_SERVER_ROOT_PATH /var/www/ - This is the physical folder where the system Dokeos has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
* WEB_PATH http://www.mydokeos.com/dokeos/
* SYS_PATH /var/www/dokeos/
* REL_PATH dokeos/
* WEB_COURSE_PATH http://www.mydokeos.com/dokeos/courses/
* SYS_COURSE_PATH /var/www/dokeos/courses/
* REL_COURSE_PATH /dokeos/courses/
* REL_CODE_PATH /dokeos/main/
* WEB_CODE_PATH http://www.mydokeos.com/dokeos/main/
* SYS_CODE_PATH /var/www/dokeos/main/
* SYS_LANG_PATH /var/www/dokeos/main/lang/
* WEB_IMG_PATH http://www.mydokeos.com/dokeos/main/img/
* GARBAGE_PATH
* WEB_PLUGIN_PATH http://www.mydokeos.com/dokeos/plugin/
* SYS_PLUGIN_PATH /var/www/dokeos/plugin/
* WEB_ARCHIVE_PATH http://www.mydokeos.com/dokeos/archive/
* SYS_ARCHIVE_PATH /var/www/dokeos/archive/
* INCLUDE_PATH /var/www/dokeos/main/inc/
* WEB_LIBRARY_PATH http://www.mydokeos.com/dokeos/main/inc/lib/
* LIBRARY_PATH /var/www/dokeos/main/inc/lib/
* CONFIGURATION_PATH /var/www/dokeos/main/inc/conf/
*/
function api_get_path_1_8_6_1($path_type) {
global $_configuration;

Loading…
Cancel
Save