-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbootstrap.php
executable file
·70 lines (52 loc) · 1.77 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
68
69
70
<?php
/**
* PHPUnit bootstrap file
*
* @package Newspack_Newsletters
*/
$_tests_dir = getenv( 'WP_TESTS_DIR' );
if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
}
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit( 1 );
}
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
/**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( __DIR__ ) . '/newspack-newsletters.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
// Load the composer autoloader.
require_once __DIR__ . '/../vendor/autoload.php';
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';
// Trait used to test Subscription Lists.
require_once 'trait-lists-setup.php';
// Trait used to test Send Lists.
require_once 'trait-send-lists-setup.php';
// Trait used to test WC Memberships.
require_once 'trait-wc-memberships-setup.php';
// MailChimp mock.
require_once 'mocks/class-mailchimp-mock.php';
// WC Memberships mock.
require_once 'mocks/wc-memberships.php';
// WC CLI mock.
require_once 'mocks/wp-cli.php';
// Abstract ESP tests.
require_once 'abstract-esp-tests.php';
ini_set( 'error_log', 'php://stdout' ); // phpcs:ignore WordPress.PHP.IniSet.Risky
/**
* Exception to be thrown when wp_die is called.
*
* @param string $message The error message.
* @throws WPDieException The exception.
*/
function handle_wpdie_in_tests( $message ) {
throw new WPDieException( $message ); // phpcs:ignore
}
define( 'IS_TEST_ENV', 1 );