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);
         }
     }
 }
Пример #2
0
 function testBadExample()
 {
     $this->needFile('example_bad.php');
     $test = new DocTest('example_bad.php');
     $this->assertTrue($test->failed());
     $this->assertEquals(10, $test->getLineNumber());
     $this->assertEquals('42', $test->getExpected());
     $this->assertEquals('440', $test->getResult());
 }