Beispiel #1
0
 public function bootstrap($indexPath = __DIR__ . '../../../index.php')
 {
     $indexPath = realpath($indexPath);
     if ($indexPath === false) {
         throw new PHPUnit_Framework_Exception('App path not found. Check the first parameter passed to Bunsen::bootstrap() points to the directory containing index.php.');
     }
     /**
      * Hook show_error to throw an exception PHPUnit can catch
      */
     silence(redefine('\\show_error', function ($message, $status_code = 500, $heading = 'An Error Was Encountered') {
         relay();
         throw new PHPUnit_Framework_Exception("{$heading} - {$message}", $status_code);
     }));
     /**
      * Hook show_404 to throw an exception PHPUnit can catch
      */
     silence(redefine('\\show_404', function ($page = '', $log_error = true) {
         relay();
         throw new PHPUnit_Framework_Exception($page, 404);
     }));
     /**
      * Hook CI_Utf8::__construct to load the the Config class
      * into the $CFG superglobal.
      */
     silence(redefine('\\CI_Utf8::__construct', function () {
         $GLOBALS['CFG'] = load_class('Config', 'core');
         relay();
     }));
     /**
      * Hook CI_Output::_display to load the Benchmark class
      * into the $BM superglobal.
      */
     silence(redefine('\\CI_Output::_display', function () {
         $GLOBALS['BM'] = load_class('Benchmark', 'core');
         relay();
     }));
     /**
      * Bootstrap CodeIgniter
      *
      * Wrap the execution in a buffer to catch the initial request, then discard any output.
      * We can then trigger requests from tests.
      */
     ob_start();
     require_once $indexPath;
     ob_clean();
     /**
      * Autoload controllers
      */
     spl_autoload_register(function ($class) {
         $class = strtolower($class);
         $files = new \RecursiveDirectoryIterator(APPPATH . 'controllers');
         $files = new \RecursiveIteratorIterator($files, \RecursiveIteratorIterator::SELF_FIRST);
         $files = new \RegexIterator($files, "/{$class}\\.php\$/");
         foreach ($files as $file) {
             require_once $file;
         }
     });
 }
}*/
drupal_override_server_variables();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $test_setting_variable;
$test_setting_variable = parse_ini_file(DRUPAL_ROOT . "/tests/configuration.ini", TRUE);
Patchwork\redefine('drupal_goto', function ($path = '', array $options = array(), $http_response_code = 302) {
    // A destination in $_GET always overrides the function arguments.
    // We do not allow absolute URLs to be passed via $_GET, as this can be an attack vector.
    if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
        $destination = drupal_parse_url($_GET['destination']);
        $path = $destination['path'];
        $options['query'] = $destination['query'];
        $options['fragment'] = $destination['fragment'];
    }
    // In some cases modules call drupal_goto(current_path()). We need to ensure
    // that such a redirect is not to an external URL.
    if ($path === current_path() && empty($options['external']) && url_is_external($path)) {
        // Force url() to generate a non-external URL.
        $options['external'] = FALSE;
    }
    drupal_alter('drupal_goto', $path, $options, $http_response_code);
    global $drupal_goto;
    $drupal_goto['path'] = $path;
    $drupal_goto['options'] = $options;
    $drupal_goto['http_response_code'] = $http_response_code;
});
/**
 * Class RedTest_Framework_TestCase
 *
 * @package RedTest\core
 */