Added method filter support to test runner

This commit is contained in:
Marcin Kurczewski 2014-05-14 19:06:27 +02:00
parent 95e37e55eb
commit 700f2bc8ae

View file

@ -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,6 +134,8 @@ class TestRunner
$testFixture->methods []= $method;
}
}
if (!empty($testFixture->methods))
$testFixtures []= $testFixture;
}