Beispiel #1
0
 /**
  * Loads test suite
  */
 public function before()
 {
     parent::before();
     if (!Kohana_Tests::enabled()) {
         // Pretend this is a normal 404 error...
         $this->status = 404;
         throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri', array(':uri' => $this->request->uri));
     }
     // Prevent the whitelist from being autoloaded, but allow the blacklist
     // to be loaded
     Kohana_Tests::configure_environment(FALSE);
     $this->config = Kohana::config('unittest');
     // This just stops some very very long lines
     $route = Route::get('unittest');
     $this->report_uri = $route->uri(array('action' => 'report'));
     $this->run_uri = $route->uri(array('action' => 'run'));
     // Switch used to disable cc settings
     $this->xdebug_loaded = extension_loaded('xdebug');
     $this->cc_archive_enabled = class_exists('Archive');
     Kohana_View::set_global('xdebug_enabled', $this->xdebug_loaded);
     Kohana_View::set_global('cc_archive_enabled', $this->cc_archive_enabled);
 }
<?php

// If we're on the CLI then PHPUnit will already be loaded
if (class_exists('PHP_CodeCoverage_Filter', FALSE)) {
    Kohana_Tests::configure_environment();
    // Stop kohana from processing the request
    define('SUPPRESS_REQUEST', TRUE);
} elseif (Kohana_Tests::enabled()) {
    // People shouldn't be running unit tests on their production server
    // so we assume that this _could_ be a web ui request on the dev server
    // and include phpunit so that modules realise that this could be a testing request
    require_once 'PHPUnit/Autoload.php';
    Route::set('unittest', 'unittest(/<action>)')->defaults(array('controller' => 'unittest', 'action' => 'index'));
}