Fixed the file install and added a new parameter for the function load mainCT#191

skala
Arthur Portugal 15 years ago
parent 5c781c0caa
commit 1695a62058
  1. 15
      main/install/install_upgrade.lib.php
  2. 127
      tests/main/install/install_upgrade.lib.test.php

@ -20,7 +20,6 @@
============================================================================== ==============================================================================
*/ */
define("DOKEOS_MAIN_DATABASE_FILE", "dokeos_main.sql"); define("DOKEOS_MAIN_DATABASE_FILE", "dokeos_main.sql");
define("LANGUAGE_DATA_FILENAME", "language_data.csv"); define("LANGUAGE_DATA_FILENAME", "language_data.csv");
define("COUNTRY_DATA_FILENAME", "country_data.csv"); define("COUNTRY_DATA_FILENAME", "country_data.csv");
define("SETTING_OPTION_DATA_FILENAME", "setting_option_data.csv"); define("SETTING_OPTION_DATA_FILENAME", "setting_option_data.csv");
@ -223,11 +222,17 @@ function write_dokeos_config_file($path)
* have to be replaced by the settings entered by the user during installation. * have to be replaced by the settings entered by the user during installation.
* *
* @param array $installation_settings list of settings entered by the user * @param array $installation_settings list of settings entered by the user
* @param string optional path about the script for database
* @return void
*/ */
function load_main_database($installation_settings) function load_main_database($installation_settings,$db_script='')
{ {
$dokeos_main_sql_file_string = file_get_contents(DOKEOS_MAIN_DATABASE_FILE); if (!empty($db_script)) {
$dokeos_main_sql_file_string = file_get_contents($db_script);
} else {
$dokeos_main_sql_file_string = file_get_contents(DOKEOS_MAIN_DATABASE_FILE);
}
//replace symbolic parameters with user-specified values //replace symbolic parameters with user-specified values
foreach ($installation_settings as $key => $value) foreach ($installation_settings as $key => $value)
{ {

@ -8,14 +8,14 @@ class TestInstallUpgrade extends UnitTestCase{
'the install and upgrade scripts'); 'the install and upgrade scripts');
} }
public function testSetFileFolderPermissions(){ public function testSetFileFolderPermissions() {
$res = set_file_folder_permissions(); $res = set_file_folder_permissions();
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
$this->assertNull($res); $this->assertNull($res);
//var_dump($res); //var_dump($res);
} }
public function testFillLanguageTable(){ public function testFillLanguageTable() {
$language_table='en'; $language_table='en';
$res = fill_language_table($language_table); $res = fill_language_table($language_table);
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
@ -33,78 +33,52 @@ class TestInstallUpgrade extends UnitTestCase{
var_dump($res); var_dump($res);
}*/ }*/
public function testFillSettingsTable(){ public function testFillSettingsTable() {
$settings_options_table=''; $settings_options_table='';
$res = fill_settings_options_table($settings_options_table); $res = fill_settings_options_table($settings_options_table);
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
//var_dump($res); //var_dump($res);
} }
public function testFillTrackCountriesTable(){ public function testFillTrackCountriesTable() {
$track_countries_table=''; $track_countries_table='';
$res = fill_track_countries_table($track_countries_table); $res = fill_track_countries_table($track_countries_table);
$this->assertEqual(null,$res); $this->assertEqual(null,$res);
//var_dump($res); //var_dump($res);
} }
public function testWriteCoursesHtaccessFile(){ public function testWriteCoursesHtaccessFile() {
$url_append='/var/www/dokeos1861/main/install/'; $chamilo_path_folder = api_get_path(SYS_PATH);
$url_append=$chamilo_path_folder.'main/install/';
$res = write_courses_htaccess_file($url_append); $res = write_courses_htaccess_file($url_append);
if(is_bool($res)){ if(is_bool($res)){
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
$this->assertTrue($res === true || $res === false); $this->assertTrue($res === true || $res === false);
}else }else
$this->assertEqual('/var/www/dokeos1861/main/install/',$res); $this->assertEqual($chamilo_path_folder.'main/install/',$res);
//var_dump($res); //var_dump($res);
} }
/**
* Call to undefined function trueFalse() in
* /var/www/dokeos1861/main/install/install_upgrade.lib.php on line 192
*/
/* public function testWriteDokeosConfigFile(){
global $dbHostForm;
global $dbUsernameForm;
global $dbPassForm;
global $enableTrackingForm;
global $singleDbForm;
global $dbPrefixForm;
global $dbNameForm;
global $dbStatsForm;
global $dbScormForm;
global $dbUserForm;
global $urlForm;
global $pathForm;
global $urlAppendPath;
global $languageForm;
global $encryptPassForm;
global $installType;
global $updatePath;
global $session_lifetime;
global $new_version;
global $new_version_stable;
$path='';
$res = write_dokeos_config_file($path);
$this->assertTrue($res);
var_dump($res);
}*/ public function testLoadMainDatabase() {
$chamilo_path_folder= api_get_path(SYS_PATH);
public function testLoadMainDatabase(){
$installation_settings=array(); $installation_settings=array();
$res = load_main_database($installation_settings); $db_script = $chamilo_path_folder.'main/install/dokeos_main.sql';
$res = load_main_database($installation_settings,$db_script);
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
$this->assertNull($res); $this->assertNull($res);
//var_dump($res);
} }
public function testLoadDatabaseScript(){ public function testLoadDatabaseScript() {
$db_script='install_db'; $chamilo_path_folder= api_get_path(SYS_PATH);
$db_script= $chamilo_path_folder.'main/install/dokeos_stats.sql';
$res = load_database_script($db_script); $res = load_database_script($db_script);
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
//var_dump($res); //var_dump($res);
} }
public function testSplitSqlFile(){ public function testSplitSqlFile() {
$ret=''; $ret='';
$sql=''; $sql='';
$res = split_sql_file($ret, $sql); $res = split_sql_file($ret, $sql);
@ -114,7 +88,7 @@ class TestInstallUpgrade extends UnitTestCase{
//var_dump($res); //var_dump($res);
} }
public function testGetSqlFileContents(){ public function testGetSqlFileContents() {
ob_start(); ob_start();
$file='txt'; $file='txt';
$section='course'; $section='course';
@ -127,28 +101,53 @@ class TestInstallUpgrade extends UnitTestCase{
//var_dump($res); //var_dump($res);
} }
public function testMyDirectoryToArray(){ public function testMyDirectoryToArray() {
$directory=array('aaa','bbb','ccc'); $chamilo_path_folder= api_get_path(SYS_PATH);
$directory= $chamilo_path_folder.'home';
$res = my_directory_to_array($directory); $res = my_directory_to_array($directory);
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
//var_dump($res);
} }
public function testAddDocument180(){ public function testAddDocument180() {
$_course='testing'; global $_configuration;
$path='http://dokeos186.net/courses/001/?id_session=0';
$filetype='doc'; require_once api_get_path(SYS_PATH).'tests/main/inc/lib/add_course.lib.inc.test.php';
$filesize='10';
$title='testing'; // create a course
$comment=NULL;
$res = add_document_180($res); $course_datos = array(
if(is_bool($res)){ 'wanted_code'=> 'COD21',
$this->assertTrue(is_bool($res)); 'title'=>'metodologia de calculo diferencial',
$this->assertTrue($res === false); 'tutor_name'=>'R. J. Wolfagan',
}else 'category_code'=>'2121',
$this->assertTrue($res); 'course_language'=>'english',
//var_dump($res); 'course_admin_id'=>'1211',
} 'db_prefix'=> $_configuration['db_prefix'].'COD21',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'firstExpirationDelay'=>'112'
);
$res = create_course($course_datos['wanted_code'], $course_datos['title'],
$course_datos['tutor_name'], $course_datos['category_code'],
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
if ($res) {
$_course = 'COD21';
$chamilo_path_folder_web = api_get_path(WEB_PATH);
$path = $chamilo_path_folder_web.'/courses/COD21/?id_session=0';
$filetype='doc';
$filesize='10';
$title='metodologia de calculo diferencial';
$res = add_document_180($_course,$path,$filetype,$filesize,$title);
$resu = CourseManager::delete_course($_course);
}
if(is_bool($res)) {
$this->assertTrue(is_bool($res));
$this->assertTrue($res === false);
} else {
$this->assertTrue($res);
//var_dump($res);
}
}
} }

Loading…
Cancel
Save