This repository has been archived by the owner on Mar 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because Travis isn't initializing the plugin tests correctly, copy in…
… the boilerplate from the 'wp scaffold plugin' command, without removing existing bootstrap.php functionality.
- Loading branch information
Showing
1 changed file
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
<?php | ||
/** | ||
* PHPUnit bootstrap file | ||
*/ | ||
|
||
$wp_tests_dir = getenv('WP_TESTS_DIR'); | ||
if ( ! $wp_tests_dir ) { | ||
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; | ||
} | ||
|
||
if ( ! file_exists( $wp_tests_dir . '/includes/functions.php' ) ) { | ||
echo "Could not find $wp_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; | ||
exit( 1 ); | ||
} | ||
|
||
// Give access to tests_add_filter() function. | ||
require_once $wp_tests_dir . '/includes/functions.php'; | ||
|
||
/** | ||
* Make sure WordPress knows the plugin should be active | ||
*/ | ||
function _manually_load_environment() { | ||
$plugins_to_active = array("WP-DS-NPR-API/ds-npr-api.php"); | ||
update_option('active_plugins', $plugins_to_active); | ||
update_option( 'active_plugins', $plugins_to_active ); | ||
} | ||
tests_add_filter( 'muplugins_loaded', '_manually_load_environment' ); | ||
|
||
/** | ||
* Manually load the plugin being tested. | ||
*/ | ||
function _manually_load_plugin() { | ||
require dirname( dirname( __FILE__ ) ) . '/sample-plugin.php'; | ||
} | ||
tests_add_filter('muplugins_loaded', '_manually_load_environment'); | ||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | ||
|
||
// Start up the WP testing environment. | ||
require $wp_tests_dir . '/includes/bootstrap.php'; |