forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpbench-bootstrap.php
More file actions
74 lines (58 loc) · 1.93 KB
/
phpbench-bootstrap.php
File metadata and controls
74 lines (58 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Bootstrap file for phpbench benchmarks.
*
* Loads WordPress for running benchmarks.
*/
define( 'PHPBENCH_ROOT', __DIR__ );
if ( defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) {
$config_file_path = WP_TESTS_CONFIG_FILE_PATH;
} else {
$config_file_path = __DIR__ . '/wp-tests-config.php';
}
/*
* Globalize some WordPress variables.
*/
global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories;
if ( ! is_readable( $config_file_path ) ) {
exit( 1 );
}
require_once $config_file_path;
if ( ! is_dir( ABSPATH ) ) {
exit( 1 );
}
function tests_reset__SERVER() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '';
$_SERVER['SERVER_NAME'] = WP_TESTS_DOMAIN;
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
unset( $_SERVER['HTTP_REFERER'] );
unset( $_SERVER['HTTPS'] );
}
tests_reset__SERVER();
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
define( 'DIR_BENCHMARKDATA', __DIR__ . '/tests/benchmarks/data' );
define( 'DIR_TESTDATA', __DIR__ . '/tests/phpunit/data' );
define( 'WP_LANG_DIR', realpath( DIR_TESTDATA . '/languages' ) );
/*
* Cron tries to make an HTTP request to the site, 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 = '/index.php';
$GLOBALS['PHP_SELF'] = '/index.php';
$_SERVER['PHP_SELF'] = '/index.php';
if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
define( 'WP_DEFAULT_THEME', 'default' );
}
$wp_theme_directories = array();
if ( file_exists( DIR_TESTDATA . '/themedir1' ) ) {
$wp_theme_directories[] = DIR_TESTDATA . '/themedir1';
}
// Load WordPress.
require_once ABSPATH . 'wp-settings.php';