forked from WordPress/wordcamp.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpunit-bootstrap.php
54 lines (44 loc) · 2.49 KB
/
phpunit-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
<?php
define( 'WP_PLUGIN_DIR', __DIR__ . '/public_html/wp-content/plugins' );
define( 'SUT_WPMU_PLUGIN_DIR', __DIR__ . '/public_html/wp-content/mu-plugins' ); // WPMU_PLUGIN_DIR will be in `WP_TESTS_DIR`.
$core_tests_directory = getenv( 'WP_TESTS_DIR' );
if ( ! $core_tests_directory ) {
$core_tests_directory = rtrim( sys_get_temp_dir(), '/\\' ) . '/wp/wordpress-tests-lib';
// Necessary for the CampTix tests.
putenv( "WP_TESTS_DIR=$core_tests_directory" );
}
if ( ! $core_tests_directory ) {
echo "Could not find $core_tests_directory/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}
// Give access to tests_add_filter() function.
require_once( $core_tests_directory . '/includes/functions.php' );
/*
* Load individual plugin bootstrappers
*
* There may eventually be cases where these conflict with one another (e.g., some need to run in context of
* wp-admin while others need to run in front-end context), but it works for now. If they ever do conflict, then
* that's probably a smell that we shouldn't be using PHPUnit for integration tests, though.
*
* If we don't want to migrate to Selenium etc, then another option might be using a PHPUnit listener to load the
* bootstrap for a particular suite before the suite loads (see https://stackoverflow.com/a/30170762/450127). It's
* not clear if that would properly isolate them from each other, and allow multiple independent contexts, though.
*/
require_once( WP_PLUGIN_DIR . '/wordcamp-organizer-reminders/tests/bootstrap.php' );
require_once WP_PLUGIN_DIR . '/wcpt/tests/bootstrap.php';
require_once( WP_PLUGIN_DIR . '/wordcamp-remote-css/tests/bootstrap.php' );
require_once WP_PLUGIN_DIR . '/wordcamp-speaker-feedback/tests/bootstrap.php';
require_once SUT_WPMU_PLUGIN_DIR . '/tests/bootstrap.php';
/*
* This has to be the last plugin bootstrapper, because it includes the Core test bootstrapper, which would
* short-circuits any other plugin bootstrappers than run after it. We can remove that when we remove CampTix
* from the w.org directory and make it a wordcamp.org-only plugin.
*/
require_once( WP_PLUGIN_DIR . '/camptix/tests/bootstrap.php' );
require_once( $core_tests_directory . '/includes/bootstrap.php' );
/*
* Include any custom TestCase classes or other PHPUnit utilities.
*
* This has to be done after Core's bootstrapper finished, so that PHPUnit classes will be available.
*/
require_once( __DIR__ . '/phpunit-database-testcase.php' );