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
<?php
define('WP_DISABLE_FATAL_ERROR_HANDLER', true);
if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
$GLOBALS['test_root'] = getenv( 'WP_DEVELOP_DIR' ). '/tests/phpunit';
} elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
$GLOBALS['test_root'] = getenv( 'WP_TESTS_DIR' );
} elseif ( file_exists( '../../../../tests/phpunit/includes/bootstrap.php' ) ) {
$GLOBALS['test_root'] = '../../../../tests/phpunit';
} elseif ( file_exists( '/tmp/wordpress-tests-lib/includes/bootstrap.php' ) ) {
$GLOBALS['test_root'] = '/tmp/wordpress-tests-lib';
}
$plugin = dirname( dirname( __FILE__ ) );
define( 'CMB2_TEST_PLUGIN', $plugin );
define( 'CMB2_WP_CONTENT', dirname( dirname( $plugin ) ) );
require_once $plugin . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
require_once $GLOBALS['test_root'] . '/includes/functions.php';
function _tests_cmb2_manually_load_plugin() {
global $test_root;
define( 'CMB2_TESTDATA', dirname( __FILE__ ) . '/data' );
if ( ! defined( 'WP_ADMIN' ) ) {
define( 'WP_ADMIN', true );
}
if (
( $rest_api = '/tmp/wordpress/wp-content/plugins/rest-api/plugin.php' )
&& file_exists( $rest_api )
) {
require_once $rest_api;
} elseif (
( $rest_api = CMB2_WP_CONTENT . '/plugins/rest-api/plugin.php' )
&& file_exists( $rest_api )
) {
require_once $rest_api;
} elseif (
( $rest_api = CMB2_WP_CONTENT . '/plugins/WP-API/plugin.php' )
&& file_exists( $rest_api )
) {
require_once $rest_api;
}
require_once CMB2_TEST_PLUGIN . '/init.php';
}
tests_add_filter( 'muplugins_loaded', '_tests_cmb2_manually_load_plugin' );
require $GLOBALS['test_root'] . '/includes/bootstrap.php';