[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/includes/ -> boot.php (source)

   1  <?php
   2  
   3  /**
   4   * Boot YOURLS the way the test suite needs it.
   5   *
   6   * Used by tests/bootstrap.php (which installs the DB and runs unit tests) and by
   7   * tests/data/scripts/run-scenario.php (which runs tests in a NEW process, to allow testing
   8   * specific scenarios with constants).
   9   */
  10  
  11  require_once  __DIR__ . '/install.php';
  12  
  13  /**
  14   * Load the test config file and boot YOURLS core
  15   *
  16   * Bootstrap steps that need a web context, or a YOURLS that's already installed, are skipped.
  17   * Callers can turn any other step on or off with $init_overrides.
  18   *
  19   * @param array $init_overrides  Properties of \YOURLS\Config\InitDefaults to override, as $name => $bool
  20   * @return string                The config file that was loaded
  21   */
  22  function yut_boot_yourls( $init_overrides = array() ) {
  23      // Globalize YOURLS variables: this is a function, and PHPUnit loads tests/bootstrap.php
  24      // inside one too. See https://github.com/sebastianbergmann/phpunit/issues/325
  25      // This has to be done before including any file
  26      global $yourls_user_passwords, $yourls_reserved_URL,          // main object & config file
  27             $yourls_filters, $yourls_actions,                      // used by plugin API
  28             $yourls_locale, $yourls_l10n, $yourls_locale_formats,  // used by L10N API
  29             $yourls_allowedentitynames, $yourls_allowedprotocols;  // used by KSES
  30  
  31      // Include relevant config file
  32      if( !defined( 'YOURLS_CONFIGFILE' ) ) {
  33          define( 'YOURLS_CONFIGFILE', yut_find_config() );
  34      }
  35      require_once YOURLS_CONFIGFILE;
  36  
  37      // Bootstrap YOURLS, with test data instead of the user directory
  38      require_once  YOURLS_ABSPATH . '/includes/vendor/autoload.php';
  39      define( 'YOURLS_TESTDATA_DIR', dirname( __DIR__ ) . '/data' );
  40      define( 'YOURLS_LANG_DIR', YOURLS_TESTDATA_DIR . '/pomo' );
  41      define( 'YOURLS_PLUGINDIR', YOURLS_TESTDATA_DIR . '/plugins' );
  42      define( 'YOURLS_PAGEDIR', YOURLS_TESTDATA_DIR . '/pages' );
  43      $config = new \YOURLS\Config\Config( YOURLS_CONFIGFILE );
  44      $config->define_core_constants();
  45  
  46      // Define YOURLS actions upon new instance
  47      $init = new \YOURLS\Config\InitDefaults;
  48      $init->check_maintenance_mode  = false;
  49      $init->fix_request_uri         = false;
  50      $init->redirect_ssl            = false;
  51      $init->check_new_version       = false;
  52      $init->redirect_to_install     = false;
  53      $init->check_if_upgrade_needed = false;
  54      // Do not attempt to load (no DB yet to store data), but do send the 'plugins_loaded' action (some code depend on it)
  55      $init->load_plugins            = false;
  56  
  57      foreach( $init_overrides as $step => $value ) {
  58          $init->$step = $value;
  59      }
  60  
  61      new \YOURLS\Config\Init( $init );
  62  
  63      return YOURLS_CONFIGFILE;
  64  }


Generated: Mon Sep 28 05:10:19 2026 Cross-referenced by PHPXref 0.7.1