[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/tests/phpunit/includes/ -> define-constants.php (source)

   1  <?php
   2  
   3  /**
   4   * Define constants needed by test suite.
   5   */
   6  
   7  define( 'BP_PLUGIN_DIR', dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/src/' );
   8  
   9  if ( ! defined( 'BP_TESTS_DIR' ) ) {
  10      define( 'BP_TESTS_DIR', dirname( dirname( __FILE__ ) ) . '/' );
  11  }
  12  
  13  /**
  14   * Determine where the WP test suite lives. Three options are supported:
  15   *
  16   * - Define a WP_DEVELOP_DIR environment variable, which points to a checkout
  17   *   of the develop.svn.wordpress.org repository (this is recommended)
  18   * - Define a WP_TESTS_DIR environment variable, which points to a checkout of
  19   *   WordPress test suite
  20   * - Assume that we are inside of a develop.svn.wordpress.org setup, and walk
  21   *   up the directory tree
  22   */
  23  if ( false !== getenv( 'WP_PHPUNIT__DIR' ) && defined( 'BP_USE_WP_ENV_TESTS' ) ) {
  24      define( 'WP_TESTS_DIR', getenv( 'WP_PHPUNIT__DIR' ) );
  25      define( 'WP_ROOT_DIR', '/var/www/html' );
  26  } elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
  27      define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
  28      define( 'WP_ROOT_DIR', WP_TESTS_DIR );
  29  } else {
  30      // Support WP_DEVELOP_DIR, as used by some plugins
  31      if ( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
  32          define( 'WP_ROOT_DIR', getenv( 'WP_DEVELOP_DIR' ) );
  33      } else {
  34          define( 'WP_ROOT_DIR', dirname( dirname( dirname( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) ) ) ) );
  35      }
  36  
  37      define( 'WP_TESTS_DIR', WP_ROOT_DIR . '/tests/phpunit' );
  38  }
  39  
  40  if ( ! defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) {
  41      // Based on the tests directory, look for a config file
  42      if ( file_exists( WP_ROOT_DIR . '/wp-tests-config.php' ) ) {
  43          // Standard develop.svn.wordpress.org setup
  44          define( 'WP_TESTS_CONFIG_PATH', WP_ROOT_DIR . '/wp-tests-config.php' );
  45  
  46      } elseif ( file_exists( WP_TESTS_DIR . '/wp-tests-config.php' ) ) {
  47          // Legacy unit-test.svn.wordpress.org setup
  48          define( 'WP_TESTS_CONFIG_PATH', WP_TESTS_DIR . '/wp-tests-config.php' );
  49  
  50      } elseif ( file_exists( dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' ) ) {
  51          // Environment variable exists and points to tests/phpunit of
  52          // develop.svn.wordpress.org setup
  53          define( 'WP_TESTS_CONFIG_PATH', dirname( dirname( WP_TESTS_DIR ) ) . '/wp-tests-config.php' );
  54  
  55      } else {
  56          die( "wp-tests-config.php could not be found.\n" );
  57      }
  58  }


Generated: Sun Dec 22 01:00:54 2024 Cross-referenced by PHPXref 0.7.1