if (basename($config_file_path) === 'phpunit' && basename(dirname($config_file_path)) === 'tests') { $config_file_path = dirname(dirname($config_file_path)); } } $config_file_path .= '/wp-tests-config.php'; /* * Globalize some WordPress variables, because PHPUnit loads this file inside a function * See: https://github.com/sebastianbergmann/phpunit/issues/325 */ global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer; if (!is_readable($config_file_path)) { die("ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n"); } require_once $config_file_path; require_once dirname(__FILE__) . '/functions.php'; tests_reset__SERVER(); define('WP_TESTS_TABLE_PREFIX', $table_prefix); define('DIR_TESTDATA', dirname(__FILE__) . '/../data'); define('WP_LANG_DIR', DIR_TESTDATA . '/languages'); if (!defined('WP_TESTS_FORCE_KNOWN_BUGS')) { define('WP_TESTS_FORCE_KNOWN_BUGS', false); } // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only define('DISABLE_WP_CRON', true); define('WP_MEMORY_LIMIT', -1); define('WP_MAX_MEMORY_LIMIT', -1); $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php'; if ("1" == getenv('WP_MULTISITE') || defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE) { $multisite = true; } else { $multisite = false;
/** * Reset `$_SERVER` variables */ protected function reset__SERVER() { tests_reset__SERVER(); }