You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
<?php |
|
/** |
|
* PHPUnit bootstrap file |
|
* |
|
* @package Pressbooks_Aldine |
|
*/ |
|
|
|
$_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' ) ) { |
|
throw new Exception( "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" ); |
|
} |
|
|
|
// Give access to tests_add_filter() function. |
|
require_once $_tests_dir . '/includes/functions.php'; |
|
|
|
function _manually_load_plugin() { |
|
$_pressbooks = '/tmp/wordpress/wp-content/plugins/pressbooks/pressbooks.php'; |
|
if ( file_exists( $_pressbooks ) ) { |
|
require_once( $_pressbooks ); |
|
} else { |
|
require_once( __DIR__ . '/../../../plugins/pressbooks/pressbooks.php' ); |
|
} |
|
} |
|
|
|
/** |
|
* Registers theme |
|
*/ |
|
function _register_theme() { |
|
|
|
$theme_dir = dirname( __DIR__ ); |
|
$current_theme = basename( $theme_dir ); |
|
$theme_root = dirname( $theme_dir ); |
|
|
|
add_filter( 'theme_root', function() use ( $theme_root ) { |
|
return $theme_root; |
|
} ); |
|
|
|
register_theme_directory( $theme_root ); |
|
|
|
add_filter( 'pre_option_template', function() use ( $current_theme ) { |
|
return $current_theme; |
|
}); |
|
add_filter( 'pre_option_stylesheet', function() use ( $current_theme ) { |
|
return $current_theme; |
|
}); |
|
} |
|
tests_add_filter( 'muplugins_loaded', '_register_theme' ); |
|
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
|
|
|
|
|
// Start up the WP testing environment. |
|
require $_tests_dir . '/includes/bootstrap.php';
|
|
|