Upgrade to KH 3.1.3.1
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
/**
|
||||
* PHPUnit Kohana web based test runner
|
||||
*
|
||||
* @package Kohana/Unittest
|
||||
* @package Kohana/UnitTest
|
||||
* @author Kohana Team
|
||||
* @author BRMatt <matthew@sigswitch.com>
|
||||
* @author Paul Banks
|
||||
* @author Paul Banks
|
||||
* @copyright (c) 2008-2009 Kohana Team
|
||||
* @license http://kohanaphp.com/license
|
||||
*/
|
||||
|
||||
Class Controller_UnitTest extends Controller_Template
|
||||
class Controller_UnitTest extends Controller_Template
|
||||
{
|
||||
/**
|
||||
* Whether the archive module is available
|
||||
@@ -20,7 +20,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
|
||||
/**
|
||||
* Unittest config
|
||||
* @var Kohana_Config
|
||||
* @var Config
|
||||
*/
|
||||
protected $config = NULL;
|
||||
|
||||
@@ -55,28 +55,28 @@ Class Controller_UnitTest extends Controller_Template
|
||||
{
|
||||
parent::before();
|
||||
|
||||
if ( ! Kohana_Tests::enabled())
|
||||
if ( ! Unittest_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));
|
||||
array(':uri' => $this->request->uri()));
|
||||
}
|
||||
|
||||
// Prevent the whitelist from being autoloaded, but allow the blacklist
|
||||
// to be loaded
|
||||
Kohana_Tests::configure_environment(FALSE);
|
||||
Unittest_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'));
|
||||
$this->run_uri = $route->uri(array('action' => 'run'));
|
||||
|
||||
// Switch used to disable cc settings
|
||||
$this->xdebug_loaded = extension_loaded('xdebug');
|
||||
$this->xdebug_loaded = extension_loaded('xdebug');
|
||||
$this->cc_archive_enabled = class_exists('Archive');
|
||||
|
||||
Kohana_View::set_global('xdebug_enabled', $this->xdebug_loaded);
|
||||
@@ -92,7 +92,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
->set('run_uri', $this->run_uri)
|
||||
->set('report_uri', $this->report_uri)
|
||||
->set('whitelistable_items', $this->get_whitelistable_items())
|
||||
->set('groups', $this->get_groups_list(Kohana_Tests::suite()));
|
||||
->set('groups', $this->get_groups_list(Unittest_tests::suite()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,16 +102,14 @@ Class Controller_UnitTest extends Controller_Template
|
||||
{
|
||||
// Fairly foolproof
|
||||
if ( ! $this->config->cc_report_path AND ! class_exists('Archive'))
|
||||
{
|
||||
throw new Kohana_Exception('Cannot generate report');
|
||||
}
|
||||
|
||||
// We don't want to use the HTML layout, we're sending the user 100111011100110010101100
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$suite = Kohana_Tests::suite();
|
||||
$suite = Unittest_tests::suite();
|
||||
$temp_path = rtrim($this->config->temp_path, '/').'/';
|
||||
$group = (array) Arr::get($_GET, 'group', array());
|
||||
$group = (array) Arr::get($_GET, 'group', array());
|
||||
|
||||
// Stop unittest from interpretting "all groups" as "no groups"
|
||||
if (empty($group) OR empty($group[0]))
|
||||
@@ -150,21 +148,17 @@ Class Controller_UnitTest extends Controller_Template
|
||||
else
|
||||
{
|
||||
$folder = trim($this->config->cc_report_path, '/').'/';
|
||||
$path = DOCROOT.$folder;
|
||||
$path = DOCROOT.$folder;
|
||||
|
||||
if ( ! file_exists($path))
|
||||
{
|
||||
throw new Kohana_Exception('Report directory :dir does not exist', array(':dir' => $path));
|
||||
}
|
||||
|
||||
if ( ! is_writable($path))
|
||||
{
|
||||
throw new Kohana_Exception('Script doesn\'t have permission to write to report dir :dir ', array(':dir' => $path));
|
||||
}
|
||||
|
||||
$runner->generate_report($group, $path, FALSE);
|
||||
|
||||
$this->request->redirect(URL::base(FALSE, TRUE).$folder.'index.html');
|
||||
$this->request->redirect(URL::site($folder.'index.html', $this->request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +170,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
$this->template->body = View::factory('unittest/results');
|
||||
|
||||
// Get the test suite and work out which groups we're testing
|
||||
$suite = Kohana_Tests::suite();
|
||||
$suite = Unittest_tests::suite();
|
||||
$group = (array) Arr::get($_GET, 'group', array());
|
||||
|
||||
|
||||
@@ -220,19 +214,20 @@ Class Controller_UnitTest extends Controller_Template
|
||||
// Show some results
|
||||
$this->template->body
|
||||
->set('results', $runner->results)
|
||||
->set('totals', $runner->totals)
|
||||
->set('time', $this->nice_time($runner->time))
|
||||
->set('totals', $runner->totals)
|
||||
->set('time', $this->nice_time($runner->time))
|
||||
|
||||
// Sets group to the currently selected group, or default all groups
|
||||
->set('group', Arr::get($this->get_groups_list($suite), reset($group), 'All groups'))
|
||||
->set('group', Arr::get($this->get_groups_list($suite), reset($group), 'All groups'))
|
||||
->set('groups', $this->get_groups_list($suite))
|
||||
|
||||
->set('report_uri', $this->report_uri.url::query())
|
||||
->set('run_uri', $this->request->uri())
|
||||
->set('report_uri', $this->report_uri.url::query())
|
||||
|
||||
// Whitelist related stuff
|
||||
->set('whitelistable_items', $this->get_whitelistable_items())
|
||||
->set('whitelisted_items', isset($whitelist) ? array_keys($whitelist) : array())
|
||||
->set('whitelist', ! empty($whitelist));
|
||||
->set('whitelisted_items', isset($whitelist) ? array_keys($whitelist) : array())
|
||||
->set('whitelist', ! empty($whitelist));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,9 +257,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
static $whitelist;
|
||||
|
||||
if (count($whitelist))
|
||||
{
|
||||
return $whitelist;
|
||||
}
|
||||
|
||||
$whitelist = array();
|
||||
|
||||
@@ -308,7 +301,7 @@ Class Controller_UnitTest extends Controller_Template
|
||||
|
||||
if (count($whitelist))
|
||||
{
|
||||
Kohana_Tests::whitelist($whitelist);
|
||||
Unittest_tests::whitelist($whitelist);
|
||||
}
|
||||
|
||||
return $whitelist;
|
||||
|
Reference in New Issue
Block a user