[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/tests/phpunit/ -> bootstrap.php (source)

   1  <?php
   2  /**
   3   * Bootstraps unit-tests.
   4   *
   5   * @package GlotPress
   6   * @subpackage Tests
   7   */
   8  
   9  if ( ! defined( 'GP_TESTS_DIR' ) ) {
  10      define( 'GP_TESTS_DIR', __DIR__ );
  11  }
  12  
  13  if ( ! defined( 'GP_DIR_TESTDATA' ) ) {
  14      define( 'GP_DIR_TESTDATA', GP_TESTS_DIR . '/data' );
  15  }
  16  
  17  if ( ! defined( 'GP_TESTS_PERMALINK_STRUCTURE' ) ) {
  18      define( 'GP_TESTS_PERMALINK_STRUCTURE', '/%postname%' );
  19  }
  20  
  21  if ( ! defined( 'GP_TESTS_PERMALINK_STRUCTURE_WITH_TRAILING_SLASH' ) ) {
  22      define( 'GP_TESTS_PERMALINK_STRUCTURE_WITH_TRAILING_SLASH', '/%postname%/' );
  23  }
  24  
  25  $_tests_dir = getenv( 'WP_TESTS_DIR' );
  26  
  27  if ( ! $_tests_dir ) {
  28      $_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
  29  }
  30  
  31  if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
  32      echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
  33      exit( 1 );
  34  }
  35  
  36  // Give access to tests_add_filter() function.
  37  require_once "{$_tests_dir}/includes/functions.php";
  38  
  39  /**
  40   * Manually load the plugin being tested.
  41   */
  42  function _manually_load_plugin() {
  43      require dirname( __DIR__, 2 ) . '/glotpress.php';
  44  }
  45  
  46  tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
  47  
  48  global $wp_tests_options;
  49  $wp_tests_options['permalink_structure'] = GP_TESTS_PERMALINK_STRUCTURE;
  50  
  51  // Start up the WP testing environment.
  52  require "{$_tests_dir}/includes/bootstrap.php";
  53  
  54  require_once  GP_TESTS_DIR . '/lib/testcase.php';
  55  require_once  GP_TESTS_DIR . '/lib/testcase-route.php';
  56  require_once  GP_TESTS_DIR . '/lib/testcase-request.php';
  57  
  58  /**
  59   * Installs GlotPress tables.
  60   */
  61  function _install_glotpress() {
  62      require_once ABSPATH . 'wp-admin/includes/upgrade.php';
  63      require_once dirname( __DIR__, 2 ) . '/gp-includes/schema.php';
  64      require_once dirname( __DIR__, 2 ) . '/gp-includes/install-upgrade.php';
  65      gp_upgrade_db();
  66  }
  67  _install_glotpress();


Generated: Sat Nov 23 01:01:06 2024 Cross-referenced by PHPXref 0.7.1