[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

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

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


Generated: Sun Oct 24 01:00:49 2021 Cross-referenced by PHPXref 0.7.1