3 * Bootstrap for phpMyAdmin tests
5 declare(strict_types
=1);
8 use PhpMyAdmin\DatabaseInterface
;
9 use PhpMyAdmin\LanguageManager
;
10 use PhpMyAdmin\MoTranslator\Loader
;
11 use PhpMyAdmin\Tests\Stubs\DbiDummy
;
14 if (! defined('ROOT_PATH')) {
15 // phpcs:disable PSR1.Files.SideEffects
16 define('ROOT_PATH', dirname(__DIR__
) . DIRECTORY_SEPARATOR
);
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
35 get_include_path() . PATH_SEPARATOR
. dirname((string) realpath('../index.php'))
38 // Setting constants for testing
39 // phpcs:disable PSR1.Files.SideEffects
40 define('PHPMYADMIN', 1);
41 define('TESTSUITE', 1);
44 // Selenium tests setup
46 'TESTSUITE_SERVER' => 'localhost',
47 'TESTSUITE_USER' => 'root',
48 'TESTSUITE_PASSWORD' => '',
49 'TESTSUITE_DATABASE' => 'test',
50 'TESTSUITE_PORT' => 3306,
51 'TESTSUITE_URL' => 'http://localhost/phpmyadmin/',
52 'TESTSUITE_SELENIUM_HOST' => '',
53 'TESTSUITE_SELENIUM_PORT' => '4444',
54 'TESTSUITE_SELENIUM_BROWSER' => 'firefox',
55 'TESTSUITE_SELENIUM_COVERAGE' => '',
56 'TESTSUITE_BROWSERSTACK_USER' => '',
57 'TESTSUITE_BROWSERSTACK_KEY' => '',
58 'TESTSUITE_FULL' => '',
61 if (PHP_SAPI
== 'cli') {
62 foreach ($test_defaults as $varname => $defvalue) {
63 $envvar = getenv($varname);
65 $GLOBALS[$varname] = $envvar;
67 $GLOBALS[$varname] = $defvalue;
72 require_once ROOT_PATH
. 'libraries/vendor_config.php';
73 require_once AUTOLOAD_FILE
;
74 Loader
::loadFunctions();
75 $GLOBALS['PMA_Config'] = new Config();
76 $GLOBALS['PMA_Config']->set('environment', 'development');
77 $GLOBALS['cfg']['environment'] = 'development';
79 // Initialize PMA_VERSION variable
80 // phpcs:disable PSR1.Files.SideEffects
81 define('PMA_VERSION', $GLOBALS['PMA_Config']->get('PMA_VERSION'));
82 define('PMA_MAJOR_VERSION', $GLOBALS['PMA_Config']->get('PMA_MAJOR_VERSION'));
85 /* Ensure default language is active */
86 LanguageManager
::getInstance()->getLanguage('en')->activate();
88 /* Load Database interface */
89 $GLOBALS['dbi'] = DatabaseInterface
::load(new DbiDummy());
91 // Set proxy information from env, if available
92 $http_proxy = getenv('http_proxy');
93 if (PHP_SAPI
== 'cli' && $http_proxy && ($url_info = parse_url($http_proxy))) {
94 // phpcs:disable PSR1.Files.SideEffects
95 define('PROXY_URL', $url_info['host'] . ':' . $url_info['port']);
96 define('PROXY_USER', empty($url_info['user']) ?
'' : $url_info['user']);
97 define('PROXY_PASS', empty($url_info['pass']) ?
'' : $url_info['pass']);
100 // phpcs:disable PSR1.Files.SideEffects
101 define('PROXY_URL', '');
102 define('PROXY_USER', '');
103 define('PROXY_PASS', '');
107 // Ensure we have session started
110 // Standard environment for tests
111 $_SESSION[' PMA_token '] = 'token';
112 $GLOBALS['PMA_Theme'] = Theme
::load(ROOT_PATH
. 'themes/pmahomme');
113 $_SESSION['tmpval']['pftext'] = 'F';
114 $GLOBALS['lang'] = 'en';