-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
67 lines (56 loc) · 1.57 KB
/
bootstrap.php
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
<?php
/**
* PHPUnit bootstrap file
*
* @package WPPS
*/
// Require composer dependencies.
require_once 'vendor/autoload.php';
// If we're running in WP's build directory, ensure that WP knows that, too.
if ( 'build' === getenv( 'LOCAL_DIR' ) ) {
define( 'WP_RUN_CORE_TESTS', true );
}
// Determine the tests directory (from a WP dev checkout).
// Try the WP_TESTS_DIR environment variable first.
$_tests_dir = getenv( 'WP_TESTS_DIR' );
// Next, try the WP_PHPUNIT composer package.
if ( ! $_tests_dir ) {
$_tests_dir = getenv( 'WP_PHPUNIT__DIR' );
}
// See if we're installed inside an existing WP dev instance.
if ( ! $_tests_dir ) {
$_try_tests_dir = __DIR__ . 'tests/phpunit';
if ( file_exists( $_try_tests_dir . '/includes/functions.php' ) ) {
$_tests_dir = $_try_tests_dir;
}
}
// Fallback.
if ( ! $_tests_dir ) {
$_tests_dir = '/tmp/wordpress-tests-lib';
}
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
/**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
$plugins = glob( '/var/www/html/wp-content/plugins/*' );
echo 'Included plugins:';
foreach ( $plugins as $plugin ) {
$plugin_name = basename( $plugin );
$filename = $plugin_name . '.php';
$filepath = $plugin . '/' . $filename;
if ( is_readable( $filepath ) ) {
require $filepath;
}
}
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
tests_add_filter(
'wp_die_handler',
function () {
exit( 1 );
}
);
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';