install_upgrade.lib.test.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  3. class TestInstallUpgrade extends UnitTestCase{
  4. public function TestInstallUpgrade() {
  5. $this->UnitTestCase('testing the function used by '.
  6. 'the install and upgrade scripts');
  7. }
  8. public function testSetFileFolderPermissions() {
  9. $res = set_file_folder_permissions();
  10. $this->assertTrue(is_null($res));
  11. $this->assertNull($res);
  12. //var_dump($res);
  13. }
  14. public function testFillLanguageTable() {
  15. $language_table='english';
  16. $res = fill_language_table($language_table);
  17. $this->assertTrue(is_null($res));
  18. //var_dump($res);
  19. }
  20. /**
  21. * Fatal error: Call to undefined function trueFalse() in
  22. * /var/www/dokeos1861/main/install/install_upgrade.lib.php on line 114
  23. */
  24. /*public function testFillCurrentSettingsTable(){
  25. $current_settings_table='';
  26. $installation_settings='';
  27. $res = fill_current_settings_table($current_settings_table, $installation_settings);
  28. $this->assertTrue($res);
  29. var_dump($res);
  30. }*/
  31. public function testFillSettingsTable() {
  32. $settings_options_table='';
  33. $res = fill_settings_options_table($settings_options_table);
  34. $this->assertTrue(is_null($res));
  35. //var_dump($res);
  36. }
  37. public function testFillTrackCountriesTable() {
  38. $track_countries_table='';
  39. $res = fill_track_countries_table($track_countries_table);
  40. $this->assertEqual(null,$res);
  41. //var_dump($res);
  42. }
  43. public function testWriteCoursesHtaccessFile() {
  44. $chamilo_path_folder = api_get_path(SYS_PATH);
  45. $url_append=$chamilo_path_folder.'main/install/';
  46. $res = write_courses_htaccess_file($url_append);
  47. if(is_bool($res)){
  48. $this->assertTrue(is_bool($res));
  49. $this->assertTrue($res === true || $res === false);
  50. }else
  51. $this->assertEqual($chamilo_path_folder.'main/install/',$res);
  52. //var_dump($res);
  53. }
  54. public function testLoadMainDatabase() {
  55. $chamilo_path_folder= api_get_path(SYS_PATH);
  56. $installation_settings=array();
  57. $db_script = $chamilo_path_folder.'main/install/dokeos_main.sql';
  58. $res = load_main_database($installation_settings,$db_script);
  59. $this->assertTrue(is_null($res));
  60. $this->assertNull($res);
  61. }
  62. public function testLoadDatabaseScript() {
  63. $chamilo_path_folder= api_get_path(SYS_PATH);
  64. $db_script= $chamilo_path_folder.'main/install/dokeos_stats.sql';
  65. $res = load_database_script($db_script);
  66. $this->assertTrue(is_null($res));
  67. //var_dump($res);
  68. }
  69. public function testSplitSqlFile() {
  70. $ret='';
  71. $sql='';
  72. $res = split_sql_file($ret, $sql);
  73. $this->assertTrue($res);
  74. $this->assertTrue(is_bool($res));
  75. $this->assertTrue($res===true);
  76. //var_dump($res);
  77. }
  78. public function testGetSqlFileContents() {
  79. ob_start();
  80. $file='txt';
  81. $section='course';
  82. $print_errors=true;
  83. $res = get_sql_file_contents($file,$section,$print_errors);
  84. ob_end_clean();
  85. if(is_bool($res));
  86. $this->assertTrue(is_bool($res));
  87. $this->assertTrue($res===true || $res === false);
  88. //var_dump($res);
  89. }
  90. public function testMyDirectoryToArray() {
  91. $chamilo_path_folder= api_get_path(SYS_PATH);
  92. $directory= $chamilo_path_folder.'home';
  93. $res = my_directory_to_array($directory);
  94. $this->assertTrue(is_array($res));
  95. }
  96. public function testAddDocument180() {
  97. }
  98. /**
  99. * This functon only is added to the end of the test and the end of the files in the all test.
  100. */
  101. public function testDeleteCourse() {
  102. global $cidReq;
  103. $resu = CourseManager::delete_course($cidReq);
  104. }
  105. }
  106. ?>