Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
Because Travis isn't initializing the plugin tests correctly, copy in…
Browse files Browse the repository at this point in the history
… the boilerplate from the 'wp scaffold plugin' command, without removing existing bootstrap.php functionality.
  • Loading branch information
benlk committed Sep 19, 2018
1 parent dfd8fbc commit 7db701d
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/bootstrap.php
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';

0 comments on commit 7db701d

Please sign in to comment.