mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
8ac46c3b63
commit
e4ccaba3e0
2 changed files with 22 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue