install_upgrade.lib.test.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. class TestInstallUpgrade extends UnitTestCase{
  3. public function TestInstallUpgrade() {
  4. $this->UnitTestCase('testing the function used by '.
  5. 'the install and upgrade scripts');
  6. }
  7. public function testSetFileFolderPermissions() {
  8. $res = set_file_folder_permissions();
  9. $this->assertTrue(is_null($res));
  10. $this->assertNull($res);
  11. //var_dump($res);
  12. }
  13. public function testFillTrackCountriesTable() {
  14. $track_countries_table='';
  15. $res = fill_track_countries_table($track_countries_table);
  16. $this->assertEqual(null,$res);
  17. //var_dump($res);
  18. }
  19. public function testWriteCoursesHtaccessFile() {
  20. $chamilo_path_folder = api_get_path(SYS_PATH);
  21. $url_append=$chamilo_path_folder.'main/install/';
  22. $res = write_courses_htaccess_file($url_append);
  23. if(is_bool($res)){
  24. $this->assertTrue(is_bool($res));
  25. $this->assertTrue($res === true || $res === false);
  26. }else
  27. $this->assertEqual($chamilo_path_folder.'main/install/',$res);
  28. //var_dump($res);
  29. }
  30. //This function is ok but the problem is than create course with other code
  31. /*
  32. public function testLoadMainDatabase() {
  33. $chamilo_path_folder= api_get_path(SYS_CODE_PATH);
  34. $installation_settings['{ORGANISATIONNAME}'] = 'My Organisation';
  35. $installation_settings['{ORGANISATIONURL}'] = 'http://www.chamilo.org';
  36. $installation_settings['{CAMPUSNAME}'] = 'My campus';
  37. $installation_settings['{PLATFORMLANGUAGE}'] = 'spanish';
  38. $installation_settings['{ALLOWSELFREGISTRATION}'] = 1;
  39. $installation_settings['{ALLOWTEACHERSELFREGISTRATION}'] = 1;
  40. $installation_settings['{ADMINLASTNAME}'] = 'Doe';
  41. $installation_settings['{ADMINFIRSTNAME}'] = 'John';
  42. $installation_settings['{ADMINLOGIN}'] = 'admin';
  43. $installation_settings['{ADMINPASSWORD}'] = md5('admin');
  44. $installation_settings['{ADMINEMAIL}'] = '.localdomain';
  45. $installation_settings['{ADMINPHONE}'] = '(000) 001 02 03';
  46. $installation_settings['{PLATFORM_AUTH_SOURCE}'] = PLATFORM_AUTH_SOURCE;
  47. $installation_settings['{ADMINLANGUAGE}'] = 'spanish';
  48. $installation_settings['{HASHFUNCTIONMODE}'] = 'md5';
  49. $db_script = $chamilo_path_folder.'install/db_main.sql';
  50. $res = load_main_database($installation_settings,$db_script);
  51. $this->assertFalse($res);
  52. }
  53. */
  54. public function testLoadDatabaseScript() {
  55. $chamilo_path_folder= api_get_path(SYS_PATH);
  56. $db_script= $chamilo_path_folder.'main/install/db_stats.sql';
  57. $res = load_database_script($db_script);
  58. $this->assertTrue(is_null($res));
  59. }
  60. public function testSplitSqlFile() {
  61. $ret='';
  62. $sql='';
  63. $res = split_sql_file($ret, $sql);
  64. $this->assertTrue($res);
  65. $this->assertTrue(is_bool($res));
  66. $this->assertTrue($res===true);
  67. }
  68. public function testGetSqlFileContents() {
  69. ob_start();
  70. $file='txt';
  71. $section='course';
  72. $print_errors=true;
  73. $res = get_sql_file_contents($file,$section,$print_errors);
  74. ob_end_clean();
  75. if(is_bool($res));
  76. $this->assertTrue(is_bool($res));
  77. $this->assertTrue($res===true || $res === false);
  78. //var_dump($res);
  79. }
  80. public function testMyDirectoryToArray() {
  81. $chamilo_path_folder= api_get_path(SYS_PATH);
  82. $directory= $chamilo_path_folder.'home';
  83. $res = my_directory_to_array($directory);
  84. $this->assertTrue(is_array($res));
  85. }
  86. /*
  87. public function testDeleteCourse() {
  88. global $cidReq;
  89. $resu = CourseManager::delete_course($cidReq);
  90. session_destroy();
  91. }*/
  92. }
  93. ?>