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