Translated using Weblate (French)
[phpmyadmin.git] / test / bootstrap-dist.php
blobbfee49e95255c3360688214446ad79b8ad068aba
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Bootstrap for phpMyAdmin tests
6 * @package PhpMyAdmin-test
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Config;
11 use PhpMyAdmin\DatabaseInterface;
12 use PhpMyAdmin\LanguageManager;
13 use PhpMyAdmin\MoTranslator\Loader;
14 use PhpMyAdmin\Theme;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
20 /**
21 * Set precision to sane value, with higher values
22 * things behave slightly unexpectedly, for example
23 * round(1.2, 2) returns 1.199999999999999956.
25 ini_set('precision', '14');
27 // Let PHP complain about all errors
28 error_reporting(E_ALL);
30 // Ensure PHP has set timezone
31 date_default_timezone_set('UTC');
33 // Adding phpMyAdmin sources to include path
34 set_include_path(
35 get_include_path() . PATH_SEPARATOR . dirname((string) realpath("../index.php"))
38 // Setting constants for testing
39 define('PHPMYADMIN', 1);
40 define('TESTSUITE', 1);
42 // Selenium tests setup
43 $test_defaults = [
44 'TESTSUITE_SERVER' => 'localhost',
45 'TESTSUITE_USER' => 'root',
46 'TESTSUITE_PASSWORD' => '',
47 'TESTSUITE_DATABASE' => 'test',
48 'TESTSUITE_PORT' => 3306,
49 'TESTSUITE_URL' => 'http://localhost/phpmyadmin/',
50 'TESTSUITE_SELENIUM_HOST' => '',
51 'TESTSUITE_SELENIUM_PORT' => '4444',
52 'TESTSUITE_SELENIUM_BROWSER' => 'firefox',
53 'TESTSUITE_SELENIUM_COVERAGE' => '',
54 'TESTSUITE_BROWSERSTACK_USER' => '',
55 'TESTSUITE_BROWSERSTACK_KEY' => '',
56 'TESTSUITE_FULL' => '',
57 'CI_MODE' => ''
59 if (PHP_SAPI == 'cli') {
60 foreach ($test_defaults as $varname => $defvalue) {
61 $envvar = getenv($varname);
62 if ($envvar) {
63 $GLOBALS[$varname] = $envvar;
64 } else {
65 $GLOBALS[$varname] = $defvalue;
70 require_once ROOT_PATH . 'libraries/vendor_config.php';
71 require_once AUTOLOAD_FILE;
72 Loader::loadFunctions();
73 $GLOBALS['PMA_Config'] = new Config();
74 // Initialize PMA_VERSION variable
75 define('PMA_VERSION', $GLOBALS['PMA_Config']->get('PMA_VERSION'));
76 define('PMA_MAJOR_VERSION', $GLOBALS['PMA_Config']->get('PMA_MAJOR_VERSION'));
78 /* Ensure default language is active */
79 LanguageManager::getInstance()->getLanguage('en')->activate();
81 /* Load Database interface */
82 DatabaseInterface::load();
84 // Set proxy information from env, if available
85 $http_proxy = getenv('http_proxy');
86 if (PHP_SAPI == 'cli' && $http_proxy && ($url_info = parse_url($http_proxy))) {
87 define('PROXY_URL', $url_info['host'] . ':' . $url_info['port']);
88 define('PROXY_USER', empty($url_info['user']) ? '' : $url_info['user']);
89 define('PROXY_PASS', empty($url_info['pass']) ? '' : $url_info['pass']);
90 } else {
91 define('PROXY_URL', '');
92 define('PROXY_USER', '');
93 define('PROXY_PASS', '');
96 // Ensure we have session started
97 session_start();
99 // Standard environment for tests
100 $_SESSION[' PMA_token '] = 'token';
101 $GLOBALS['PMA_Theme'] = Theme::load(ROOT_PATH . 'themes/pmahomme');
102 $_SESSION['tmpval']['pftext'] = 'F';
103 $GLOBALS['lang'] = 'en';