Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
working on runAllTests. we can clarify findTests by explicitly passin…
…g in the class to investigate, instead of relying on get_called_class.
  • Loading branch information
Jared Hirsch committed Oct 15, 2009
1 parent 161de3b commit e4c8460
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 16 additions & 4 deletions TestRunner.php
Expand Up @@ -2,12 +2,10 @@

class TestRunner
{
public function findTests()
public function findTests(UnitTest $testClass)
{
$tests = array();
// have to change this for move to parent
// $className = get_class($this);
$className = get_called_class();
$className = get_class($testClass);
$metaClass = new ReflectionClass($className);

foreach ($metaClass->getMethods() as $metaMethod) {
Expand Down Expand Up @@ -44,5 +42,19 @@ public function runTest($test, UnitTest $testClass, TestResult $result = null)
return $result;
}

public function runAllTests(TestClassResult $allResults = null,
UnitTest $testClass)
{
if ($allResults === null) {
$allResults = new TestClassResult;
}
$tests = $testClass->findTests();
$allResults->setClass(get_class($testClass));
foreach ($tests as $test) {
$result = $this->runTest($test);
$allResults->addResult($result);
}
return $allResults;
}

}
3 changes: 3 additions & 0 deletions UnitTest.php
Expand Up @@ -71,6 +71,8 @@ public function runTest($test, TestResult $result = null)

public function runAllTests(TestClassResult $allResults = null)
{
return parent::runAllTests($allResults, $this);
/*
if ($allResults === null) {
$allResults = new TestClassResult;
}
Expand All @@ -81,6 +83,7 @@ public function runAllTests(TestClassResult $allResults = null)
$allResults->addResult($result);
}
return $allResults;
*/
}

public function runAndReport(Reporter $reporter = null)
Expand Down

0 comments on commit e4c8460

Please sign in to comment.