Adding a filter GET parameter which allows you filter which test methods get run. It accepts preg_match() compatible patterns.

This commit is contained in:
mark_story 2010-05-26 22:21:34 -04:00
parent 8ac46c3b63
commit e4ccaba3e0
2 changed files with 22 additions and 8 deletions

View file

@ -37,7 +37,8 @@ class CakeTestSuiteDispatcher {
'plugin' => null,
'output' => 'html',
'show' => 'groups',
'show_passes' => false
'show_passes' => false,
'filter' => false
);
/**
@ -191,7 +192,7 @@ class CakeTestSuiteDispatcher {
function &getManager() {
if (empty($this->Manager)) {
require_once CAKE_TESTS_LIB . 'test_manager.php';
$this->Manager = new $this->_managerClass();
$this->Manager = new $this->_managerClass($this->params);
}
return $this->Manager;
}

View file

@ -61,6 +61,13 @@ class TestManager {
*/
public $pluginTest = false;
/**
* String to filter test case method names by.
*
* @var string
*/
public $filter = false;
/**
* TestSuite container for single or grouped test files
*
@ -80,14 +87,20 @@ class TestManager {
*
* @return void
*/
public function __construct() {
//require_once(CAKE_TESTS_LIB . 'cake_web_test_case.php');
public function __construct($params) {
require_once(CAKE_TESTS_LIB . 'cake_test_case.php');
if (isset($_GET['app'])) {
if (isset($params['app'])) {
$this->appTest = true;
}
if (isset($_GET['plugin'])) {
$this->pluginTest = htmlentities($_GET['plugin']);
if (isset($params['plugin'])) {
$this->pluginTest = htmlentities($params['plugin']);
}
if (
isset($params['filter']) &&
$params['filter'] !== false &&
preg_match('/^[a-zA-Z0-9_]/', $params['filter'])
) {
$this->filter = '/' . $params['filter'] . '/';
}
}
@ -180,7 +193,7 @@ class TestManager {
$reporter->paintHeader();
$testSuite = $this->getTestSuite();
$testSuite->setFixtureManager($this->getFixtureManager());
$testSuite->run($result);
$testSuite->run($result, $this->filter);
$reporter->paintResult($result);
return $result;
}