Added method filter support to test runner
This commit is contained in:
parent
95e37e55eb
commit
700f2bc8ae
1 changed files with 16 additions and 6 deletions
|
@ -98,14 +98,19 @@ class TestRunner
|
|||
|
||||
$testClasses = \Chibi\Util\Reflection::loadClasses($testFiles);
|
||||
|
||||
if ($filter !== null)
|
||||
$classFilter = $filter;
|
||||
$methodFilter = null;
|
||||
if ($filter !== null and strpos($filter, '::') !== false)
|
||||
{
|
||||
$testClasses = array_filter($testClasses, function($className) use ($filter)
|
||||
{
|
||||
return stripos($className, $filter) !== false;
|
||||
});
|
||||
list ($classFilter, $methodFilter) = explode('::', $filter);
|
||||
}
|
||||
|
||||
if ($classFilter)
|
||||
$testClasses = array_filter($testClasses, function($className) use ($classFilter)
|
||||
{
|
||||
return stripos($className, $classFilter) !== false;
|
||||
});
|
||||
|
||||
$testFixtures = [];
|
||||
|
||||
foreach ($testClasses as $class)
|
||||
|
@ -119,6 +124,9 @@ class TestRunner
|
|||
$testFixture->methods = [];
|
||||
foreach ($reflectionClass->getMethods() as $method)
|
||||
{
|
||||
if ($methodFilter and stripos($method->name, $methodFilter) === false)
|
||||
continue;
|
||||
|
||||
if (preg_match('/test/i', $method->name)
|
||||
and $method->isPublic()
|
||||
and $method->getNumberOfParameters() == 0)
|
||||
|
@ -126,7 +134,9 @@ class TestRunner
|
|||
$testFixture->methods []= $method;
|
||||
}
|
||||
}
|
||||
$testFixtures []= $testFixture;
|
||||
|
||||
if (!empty($testFixture->methods))
|
||||
$testFixtures []= $testFixture;
|
||||
}
|
||||
|
||||
return $testFixtures;
|
||||
|
|
Loading…
Reference in a new issue