buddypress/tests/includes/define-constants.php
Boone B Gorges c60fae9065 In test suite, break constant definitions into separate file
BP's test installation routine is generally run from bootstrap.php. But in
certain cases, as when the suite is being invoked from a BP-dependent plugin's
tests, loader.php can be called directly, skipping bootstrap.php. For this
reason, it makes sense to define constants in a separate file and then include
that file as needed when the tests are first loaded, via either path.


git-svn-id: https://buddypress.svn.wordpress.org/trunk@7665 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
2013-12-12 20:48:46 +00:00

43 lines
1.5 KiB
PHP

<?php
/**
* Define constants needed by test suite.
*/
define( 'BP_PLUGIN_DIR', dirname( dirname( dirname( __FILE__ ) ) ) . '/' );
if ( ! defined( 'BP_TESTS_DIR' ) ) {
define( 'BP_TESTS_DIR', dirname( 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( 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" );
}