-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbootstrap.php
57 lines (48 loc) · 1.74 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
<?php
/**
* Bootstraps the Rocket Lazyload Plugin integration tests
*
* @package RocketlazyloadPlugin\Tests\Integration
*/
if (version_compare(phpversion(), '7.3.0', '<')) {
die('Rocket Lazyload Plugin Integration Tests require PHP 7.3 or higher.');
}
// Define testing constants.
define('RLL_PLUGIN_TESTS_ROOT', __DIR__);
define('RLL_PLUGIN_ROOT', dirname(dirname(__DIR__)));
/**
* Gets the WP tests suite directory
*
* @return string
*/
function rllPluginGetWPTestsDir()
{
$tests_dir = getenv('WP_TESTS_DIR');
// Travis CI & Vagrant SSH tests directory.
if (empty($tests_dir)) {
$tests_dir = '/tmp/wordpress-tests-lib';
}
// If the tests' includes directory does not exist, try a relative path to 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, as the WordPress test suite could not be located.', E_USER_ERROR); // @codingStandardsIgnoreLine.
}
// Strip off the trailing directory separator, if it exists.
return rtrim($tests_dir, DIRECTORY_SEPARATOR);
}
$rocket_ll_tests_dir = rllPluginGetWPTestsDir();
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
/**
* Manually load the plugin being tested.
*/
function rocket_lazyload_manually_load_plugin()
{
require RLL_PLUGIN_ROOT . '/rocket-lazy-load.php';
}
tests_add_filter('muplugins_loaded', 'rocket_lazyload_manually_load_plugin');
require_once $rocket_ll_tests_dir . '/includes/bootstrap.php';
unset($rocket_ll_tests_dir);