Modified - changed the variable $dokeos_path_file by $system_path_file and added a condition in the test

skala
Ricardo Rodriguez 16 years ago
parent 7ad5cb6eb0
commit 30f2d55f94
  1. 20
      main/admin/sub_language.class.php
  2. 19
      tests/main/admin/sub_language.class.test.php

@ -75,12 +75,12 @@ class SubLanguageManager {
return $all_information;
}
/**
* Get all information of dokeos file
* @param String The dokeos path file (/var/www/my_dokeos/main/lang/spanish/gradebook.inc.php)
* @return Array Contains all information of dokeos file
* Get all information of chamilo file
* @param String The dokeos path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php)
* @return Array Contains all information of chamilo file
*/
public static function get_all_language_variable_in_file ($dokeos_path_file) {
$info_file=file($dokeos_path_file);
public static function get_all_language_variable_in_file ($system_path_file) {
$info_file=file($system_path_file);
foreach ($info_file as $line) {
if (substr($line,0,1)!='$') { continue; }
list($var,$val) = split('=',$line,2);
@ -92,15 +92,15 @@ class SubLanguageManager {
/**
* Add file in sub-language directory and add header(tag php)
* @param String The dokeos path file (/var/www/my_dokeos/main/lang/spanish/gradebook.inc.php)
* @param String The chamilo path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php)
* @return void()
*/
public static function add_file_in_language_directory ($dokeos_path_file) {
file_put_contents($dokeos_path_file,'<?php'.PHP_EOL);
public static function add_file_in_language_directory ($system_path_file) {
file_put_contents($system_path_file,'<?php'.PHP_EOL);
}
/**
* Write in file of sub-language
* @param String The path file (/var/www/my_dokeos/main/lang/spanish/gradebook.inc.php)
* @param String The path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php)
* @param String The new sub-language
* @param String The language variable
* @return void()
@ -115,7 +115,7 @@ class SubLanguageManager {
}
/**
* Add directory for sub-language
* @param String The sub-language path directory ( /var/www/my_dokeos/main/lang/spanish_corporate )
* @param String The sub-language path directory ( /var/www/chamilo/main/lang/spanish_corporate )
* @return boolean
*/
public static function add_directory_of_sub_language($path_sub_language) {

@ -51,11 +51,14 @@ class TestSubLanguageManager extends UnitTestCase {
*
*/
public function testget_all_language_variable_in_file(){
$dokeos_path_folder = api_get_path(SYS_LANG_PATH);
$dokeos_path_file = $dokeos_path_folder.'spanish/link.inc.php';
$res = SubLanguageManager::get_all_language_variable_in_file($dokeos_path_file);
$this->assertTrue(is_array($res));
$this->assertTrue($res);
$system_path_folder = api_get_path(SYS_LANG_PATH);
$system_path_file = $system_path_folder.'spanish/link.inc.php';
$res = SubLanguageManager::get_all_language_variable_in_file($system_path_file);
if(is_array($res)) {
$this->assertTrue($res);
}
$this->assertFalse($res);
var_dump($res);
}
/**
@ -69,9 +72,9 @@ class TestSubLanguageManager extends UnitTestCase {
$msg = "Error";
$this->assertTrue(is_string($msg));
} else {
$dokeos_path_file = $dirname.'spanish.inc.php';
$res = SubLanguageManager::add_file_in_language_directory($dokeos_path_file);
unlink($dokeos_path_file);
$system_path_file = $dirname.'spanish.inc.php';
$res = SubLanguageManager::add_file_in_language_directory($system_path_file);
unlink($system_path_file);
$this->assertNull($res);
$this->assertTrue(is_null($res));
}

Loading…
Cancel
Save