[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/ -> bootstrap.php (source)

   1  <?php
   2  /**
   3   * YOURLS Unit Test. No, I don't know what I'm doing.
   4   */
   5  
   6  // Globalize some YOURLS variables because PHPUnit loads this inside a function
   7  // See https://github.com/sebastianbergmann/phpunit/issues/325
   8  // This has to be done before including any file
   9  global $yourls_user_passwords, $yourls_reserved_URL,          // main object & config file
  10         $yourls_filters, $yourls_actions,                      // used by plugin API
  11         $yourls_locale, $yourls_l10n, $yourls_locale_formats,  // used by L10N API
  12         $yourls_allowedentitynames, $yourls_allowedprotocols;  // used by KSES
  13  
  14  require_once  __DIR__ . '/includes/utils.php';
  15  require_once  __DIR__ . '/includes/install.php';
  16  require_once  __DIR__ . '/includes/boot.php';
  17  require_once  __DIR__ . '/includes/new-process.php';
  18  
  19  // Load config & bootstrap YOURLS. There's no database yet, so don't read from it: options and
  20  // plugins are loaded further below, once installed.
  21  echo "Using config file: " . yut_boot_yourls( array( 'get_all_options' => false ) ) . "\n";
  22  
  23  // Mark as 'installing' to avoid flood checks
  24  yourls_add_filter( 'is_installing', 'yourls_return_true' );
  25  
  26  // All set -- install
  27  yut_install_yourls();
  28  
  29  // Unmark as 'installing' to allow normal execution of code
  30  yourls_remove_filter( 'is_installing', 'yourls_return_true' );
  31  
  32  // All set -- instantiate the rest
  33  yourls_get_all_options();
  34  yourls_load_plugins();
  35  
  36  // At this point, tests will start
  37  
  38  // Simplify yourls_die() when running unit tests
  39  yourls_add_action( 'pre_yourls_die', function($params) {
  40      printf("\n\nCalling yourls_die(). %s : %s (%s)\n\n", $params[1], $params[0], $params[2]);
  41      echo "Last 10 Backtrace:\n";
  42      $trace = debug_backtrace();
  43      foreach( array_slice($trace, 0, 10) as $t ) {
  44          printf("** %s:%d %s() with args\n%s\n", $t['file'], $t['line'], $t['function'], var_export($t['args'], true));
  45      }
  46  
  47      die(1);
  48  } );
  49  
  50  echo "YOURLS installed, starting PHPUnit\n\n";
  51  
  52  require_once  __DIR__ . "/tests/auth/AbstractLoginTestCase.php";
  53  require_once  __DIR__ . "/tests/auth/LoginAssertionTrait.php";


Generated: Sat Aug 8 05:10:51 2026 Cross-referenced by PHPXref 0.7.1