install.php

  1. 7.x install.php
  2. 7.x tests/install.php
  3. 6.x install.php
  4. 5.x install.php

File

tests/install.php
View source
  1. <?php
  2. if (session_status() !== PHP_SESSION_ACTIVE) {
  3. session_start();
  4. }
  5. $skip_flightpath_settings = TRUE;
  6. $skip_flightpath_modules = TRUE;
  7. include(__DIR__ . "/../bootstrap.inc");
  8. require_once(__DIR__ . "/../modules/system/system.module");
  9. require_once(__DIR__ . "/../modules/system/system.install");
  10. global $user;
  11. $user = new stdClass();
  12. $user->id = 1;
  13. $user->cwid = 1;
  14. $user->name = 'admin';
  15. $skip_table_queries = TRUE;
  16. require_once(__DIR__ . "/test-settings.php");
  17. $GLOBALS["fp_die_mysql_errors"] = TRUE;
  18. // Remove any existing tables from the test database.
  19. $tables = $GLOBALS["pdo"]->query("SHOW TABLES")->fetchAll(PDO::FETCH_COLUMN);
  20. foreach ($tables as $table) {
  21. $GLOBALS["pdo"]->exec("DROP TABLE `" . str_replace("`", "``", $table) . "`");
  22. }
  23. system_install();
  24. $new_pass = user_hash_password("password");
  25. db_query("INSERT INTO users (user_id, user_name, cwid, password, email, is_faculty, f_name, l_name)
  26. VALUES ('1', ?, ?, ?, ?, '1', 'Admin', 'User')",
  27. $user->name, $user->cwid, $new_pass, "test@example.com");
  28. db_query("INSERT INTO faculty (cwid) VALUES ('1')");
  29. system_enable();
  30. // We need to load the bootstrap.inc file again, to make sure important settings
  31. // and modules are loaded.
  32. $skip_flightpath_settings = FALSE;
  33. $skip_flightpath_modules = FALSE;
  34. include(__DIR__ . "/../bootstrap.inc");
  35. $temp_db = new DatabaseHandler();
  36. fp_clear_cache();
  37. ////////////////
  38. // Load some initial data...
  39. $fixture_file = __DIR__ . "/fixtures/sample-data.sql";
  40. $handle = fopen($fixture_file, "r");
  41. if ($handle === FALSE) {
  42. die("Unable to open test fixture: $fixture_file\n");
  43. }
  44. while (($sql = fgets($handle)) !== FALSE) {
  45. $sql = trim($sql);
  46. if ($sql === "") {
  47. continue;
  48. }
  49. db_query($sql);
  50. }
  51. fclose($handle);
  52. variable_set('clean_urls', TRUE);
  53. variable_set('current_catalog_year', 2020);
  54. variable_set('current_draft_catalog_year', 2020);
  55. variable_set('earliest_catalog_year', 2020);
  56. variable_set('term_id_structure', "[Y4]60, Spring, Spring of [Y4], Spr '[Y2], [Y]\n[Y4]40, Fall, Fall of [Y4-1], Fall '[Y2-1], [Y-1]");
  57. variable_set('available_advising_term_ids', "202060,202140");
  58. variable_set('advising_term_id', "202140");
  59. print "FlightPath test database installed successfully.\n";
  60. //

Globals

Namesort descending Description
$user