-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbootstrap.php
More file actions
93 lines (77 loc) · 2.34 KB
/
bootstrap.php
File metadata and controls
93 lines (77 loc) · 2.34 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Bootstraps the Plugin's Integration Tests.
*
* @package KnowTheCode\GitContributing\Tests\PHP\Integration
* @since 1.0.0
* @link https://github.com/KnowTheCode/git-contributing
* @license GNU-2.0+
*/
namespace KnowTheCode\GitContributing\Tests\PHP\Integration;
use function KnowTheCode\GitContributing\Tests\PHP\get_plugin_root_dir;
use function KnowTheCode\GitContributing\Tests\PHP\load_composer_autoloader;
/**
* Gets the integration test's root directory.
*
* @since 1.0.0
*
* @return string
*/
function get_test_root_dir() {
return __DIR__;
}
/**
* Gets the WordPress' tests suite directory.
*
* @since 1.0.0
*
* @return string
*/
function get_wp_tests_dir() {
$tests_dir = getenv( 'WP_TESTS_DIR' );
// Travis CI & Vagrant SSH tests directory.
if ( empty( $tests_dir ) ) {
$tests_dir = '/tmp/wordpress-tests';
}
// If the tests' includes directory does not exist, try a relative path to the Core tests directory.
if ( ! file_exists( $tests_dir . '/includes/' ) ) {
$tests_dir = '../../../../tests/phpunit';
}
// Check it again. If it doesn't exist, stop here and post a message as to why we stopped.
if ( ! file_exists( $tests_dir . '/includes/' ) ) {
trigger_error( 'Unable to run the integration tests, because the WordPress test suite could not be located.', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error -- Valid use case for our testing suite.
}
// Strip off the trailing directory separator, if it exists.
return rtrim( $tests_dir, DIRECTORY_SEPARATOR );
}
/**
* Starts up the WordPress Test Suite.
*
* @since 1.0.0
*
* @return void
*/
function startup_wp_test_suite() {
$wp_tests_dir = get_wp_tests_dir();
// Gives access to tests_add_filter() function.
require_once $wp_tests_dir . '/includes/functions.php';
// Start up the WP testing environment.
require_once $wp_tests_dir . '/includes/bootstrap.php';
}
/**
* Load the test suite's dependencies.
*
* @since 1.0.0
*
* @return void
*/
function load_dependencies() {
require_once dirname( __DIR__ ) . '/functions.php';
load_composer_autoloader();
startup_wp_test_suite();
require_once dirname( __DIR__ ) . '/test-case-trait.php';
require_once get_test_root_dir() . '/class-test-case.php';
// Load the plugin.
require get_plugin_root_dir() . 'bootstrap.php';
}
load_dependencies();