Skip to content
Permalink
Browse files

Adding a filter GET parameter which allows you filter which test meth…

…ods get run. It accepts preg_match() compatible patterns.
  • Loading branch information...
markstory committed May 27, 2010
1 parent 8ac46c3 commit e4ccaba3e06fbc83fe5f9db1a3a617cbbd67e776
Showing with 22 additions and 8 deletions.
  1. +3 −2 cake/tests/lib/cake_test_suite_dispatcher.php
  2. +19 −6 cake/tests/lib/test_manager.php
@@ -37,7 +37,8 @@ class CakeTestSuiteDispatcher {
'plugin' => null,
'output' => 'html',
'show' => 'groups',
'show_passes' => false
'show_passes' => false,
'filter' => false
);
/**
@@ -191,7 +192,7 @@ function _groupTestList() {
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;
}
@@ -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 @@ protected function run($reporter, $codeCoverage = false) {
$reporter->paintHeader();
$testSuite = $this->getTestSuite();
$testSuite->setFixtureManager($this->getFixtureManager());
$testSuite->run($result);
$testSuite->run($result, $this->filter);
$reporter->paintResult($result);
return $result;
}

0 comments on commit e4ccaba

Please sign in to comment.
You can’t perform that action at this time.