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);
|
$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)
|
list ($classFilter, $methodFilter) = explode('::', $filter);
|
||||||
{
|
|
||||||
return stripos($className, $filter) !== false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($classFilter)
|
||||||
|
$testClasses = array_filter($testClasses, function($className) use ($classFilter)
|
||||||
|
{
|
||||||
|
return stripos($className, $classFilter) !== false;
|
||||||
|
});
|
||||||
|
|
||||||
$testFixtures = [];
|
$testFixtures = [];
|
||||||
|
|
||||||
foreach ($testClasses as $class)
|
foreach ($testClasses as $class)
|
||||||
|
@ -119,6 +124,9 @@ class TestRunner
|
||||||
$testFixture->methods = [];
|
$testFixture->methods = [];
|
||||||
foreach ($reflectionClass->getMethods() as $method)
|
foreach ($reflectionClass->getMethods() as $method)
|
||||||
{
|
{
|
||||||
|
if ($methodFilter and stripos($method->name, $methodFilter) === false)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (preg_match('/test/i', $method->name)
|
if (preg_match('/test/i', $method->name)
|
||||||
and $method->isPublic()
|
and $method->isPublic()
|
||||||
and $method->getNumberOfParameters() == 0)
|
and $method->getNumberOfParameters() == 0)
|
||||||
|
@ -126,7 +134,9 @@ class TestRunner
|
||||||
$testFixture->methods []= $method;
|
$testFixture->methods []= $method;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$testFixtures []= $testFixture;
|
|
||||||
|
if (!empty($testFixture->methods))
|
||||||
|
$testFixtures []= $testFixture;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $testFixtures;
|
return $testFixtures;
|
||||||
|
|
Loading…
Reference in a new issue