function executeDir($directory) { $iterator = new DirectoryIterator($directory); while ($iterator->valid()) { $entry = $iterator->getFilename(); $path = $directory . '/' . $entry; $iterator->next(); if ($entry[0] == '.') { continue; } if (is_file($path)) { if (substr($entry, -4) != '.php') { continue; } if (ctype_upper($entry[0])) { $test = new DocTest($path); if ($test->failed()) { echo $test->toString(); $this->fail('Doc test failed.'); } else { if ($test->numOfPassed()) { echo ','; } else { echo ' '; } } } } elseif (is_dir($path)) { $this->executeDir($path); } } }
function testGoodExample() { $file = 'example_good.php'; $this->needFile($file); $test = new DocTest($file); $this->assertFalse($test->failed()); $expected = 3; $result = $test->numOfPassed(); $this->assertEquals($expected, $result); }