| @@ -1,31 +1,38 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | +namespace cybot\cookiebot\tests; | |
| 4 | + | |
| 2 | 5 | /** |
| 3 | - * PHPUnit bootstrap file | |
| 6 | + * PHPUnit bootstrap file. | |
| 4 | 7 | * |
| 5 | 8 | * @package Cookiebot |
| 6 | 9 | */ |
| 7 | 10 | |
| 8 | -$_tests_dir = getenv( 'WP_TESTS_DIR' ); | |
| 11 | +require_once __DIR__ . '/../vendor/autoload.php'; | |
| 12 | +require_once __DIR__ . '/./helpers.php'; | |
| 13 | +require_once __DIR__ . '/../src/addons/addons.php'; | |
| 14 | +require_once __DIR__ . '/../src/lib/helper.php'; | |
| 9 | 15 | |
| 10 | -if ( ! $_tests_dir ) { | |
| 11 | - $_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; | |
| 16 | +$cybot_cookiebot_tests_dir = getenv( 'WP_TESTS_DIR' ); | |
| 17 | + | |
| 18 | +if ( ! $cybot_cookiebot_tests_dir ) { | |
| 19 | + $cybot_cookiebot_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; | |
| 12 | 20 | } |
| 13 | 21 | |
| 14 | -if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) { | |
| 15 | - echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // WPCS: XSS ok. | |
| 22 | +if ( ! file_exists( "{$cybot_cookiebot_tests_dir}/includes/functions.php" ) ) { | |
| 23 | + echo "Could not find {$cybot_cookiebot_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 16 | 24 | exit( 1 ); |
| 17 | 25 | } |
| 18 | 26 | |
| 19 | 27 | // Give access to tests_add_filter() function. |
| 20 | -require_once $_tests_dir . '/includes/functions.php'; | |
| 28 | +require_once "{$cybot_cookiebot_tests_dir}/includes/functions.php"; | |
| 21 | 29 | |
| 22 | -/** | |
| 23 | - * Manually load the plugin being tested. | |
| 24 | - */ | |
| 25 | -function _manually_load_plugin() { | |
| 26 | - require dirname( dirname( __FILE__ ) ) . '/cookiebot.php'; | |
| 27 | -} | |
| 28 | -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | |
| 30 | +tests_add_filter( | |
| 31 | + 'muplugins_loaded', | |
| 32 | + function () { | |
| 33 | + require_once dirname( dirname( __FILE__ ) ) . '/cookiebot.php'; | |
| 34 | + } | |
| 35 | +); | |
| 29 | 36 | |
| 30 | 37 | // Start up the WP testing environment. |
| 31 | -require $_tests_dir . '/includes/bootstrap.php'; | |
| 38 | +require_once "{$cybot_cookiebot_tests_dir}/includes/bootstrap.php"; | |