buddypress/tests/bootstrap.php
Boone B Gorges e903f38688 Better backward compatibility for tests configuration
Improved support for the old WP_TESTS_DIR environment variable, in particular
when pointing this environment variable toward the new develop.svn.wordpress.org
configuration.

See #5200

git-svn-id: https://buddypress.svn.wordpress.org/trunk@7424 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2013-10-14 23:28:38 +00:00

55 lines
1.9 KiB
PHP

<?php
define( 'BP_PLUGIN_DIR', dirname( dirname( __FILE__ ) ) . '/' );
if ( ! defined( 'BP_TESTS_DIR' ) ) {
define( 'BP_TESTS_DIR', dirname( __FILE__ ) . '/' );
}
/**
* In the pre-develop.svn WP development environment, an environmental bash
* variable would be set to run PHP Unit tests. However, this has been done
* away with in a post-develop.svn world. We'll still check if this variable
* is set for backwards compat.
*/
if ( getenv( 'WP_TESTS_DIR' ) ) {
define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
define( 'WP_ROOT_DIR', WP_TESTS_DIR );
} else {
define( 'WP_ROOT_DIR', dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) );
define( 'WP_TESTS_DIR', WP_ROOT_DIR . '/tests/phpunit' );
}
// Based on the tests directory, look for a config file
if ( file_exists( WP_ROOT_DIR . '/wp-tests-config.php' ) ) {
// Standard develop.svn.wordpress.org setup
define( 'WP_TESTS_CONFIG_PATH', WP_ROOT_DIR . '/wp-tests-config.php' );
} else if ( file_exists( WP_TESTS_DIR . '/wp-tests-config.php' ) ) {
// Legacy unit-test.svn.wordpress.org setup
define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_DIR . '/wp-tests-config.php' );
} else if ( file_exists( dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' ) ) {
// Environment variable exists and points to tests/phpunit of
// develop.svn.wordpress.org setup
define( 'WP_TESTS_CONFIG_PATH', dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' );
} else {
die( "wp-tests-config.php could not be found.\n" );
}
if ( ! file_exists( WP_TESTS_DIR . '/includes/functions.php' ) ) {
die( "The WordPress PHPUnit test suite could not be found.\n" );
}
require_once WP_TESTS_DIR . '/includes/functions.php';
function _install_and_load_buddypress() {
require BP_TESTS_DIR . '/includes/loader.php';
}
tests_add_filter( 'muplugins_loaded', '_install_and_load_buddypress' );
require WP_TESTS_DIR . '/includes/bootstrap.php';
// Load the BP-specific testing tools
require BP_TESTS_DIR . '/includes/testcase.php';