/** * @Given /^test downloaded files against them as well$/ */ public function testDownloadedFilesAgainstThemAsWell() { // $files = glob($this->downloadedFilesDir . DIRECTORY_SEPARATOR . '*.html'); foreach ($this->testFiles as $row) { $file = $row['source-filename']; $expectedFileSize = filesize($this->unpackedFilesDir . DIRECTORY_SEPARATOR . $file); $testFileSize = filesize($this->testFilesDir . DIRECTORY_SEPARATOR . $file); if ($expectedFileSize != $testFileSize) { echo "File sizes doesn't match for \"{$file}\"! Documentation might not match the tested sample.\n"; } // $actual = $this->parser->processFile($this->testFilesDir . DIRECTORY_SEPARATOR . $file); } $this->package->cleanup(); }
/** * @Given /^Cleanup files when it\'s all done$/ */ public function cleanupFilesWhenItSAllDone() { $this->package->cleanup(); assertFileNotExists($this->pagesDir, 'Directory "' . $this->pagesDir . '" wasn\'t removed.'); }
private function parse(Package $package, $outDir, $includeExamples) { $parser = new Parser(); $bar = $this->createProgressBar(count($parser->getFilesToProcess($package->getUnpackedDir()))); $bar->setRedrawFrequency(100); $bar->start(); $results = $parser->processDir($package->getUnpackedDir(), $includeExamples, function ($filename, $total, $processed) use($bar) { $bar->setMessage('Processing: ' . $filename); $bar->advance(); }); $bar->finish(); $functions = []; $examples = []; foreach ($results->getFuncNames() as $funcName) { $arrayRes = $results->getResult($funcName); $examplesRes = $results->getExamples($funcName); if ($examplesRes && is_array($arrayRes)) { if ($includeExamples == Parser::INCLUDE_EXAMPLES) { $arrayRes = array_merge($arrayRes, ['examples' => $examplesRes]); } elseif ($includeExamples == Parser::EXPORT_EXAMPLES) { $examples[$funcName] = $examplesRes; } } $functions[$funcName] = $arrayRes; } $this->output->writeln(''); $this->output->writeln("Warnings: <comment>" . $results->countAllWarnings() . "</comment> (malformed UTF8 in examples)"); $this->output->writeln("Skipped files: <comment>" . count($results->getSkipped()) . "</comment> (no function definition found)"); $basePath = $outDir . DIRECTORY_SEPARATOR . $package->getLang() . '_' . str_replace('.', '_', $package->getMirror()); $this->saveOutput($basePath, $functions); $this->output->writeln("Total functions: <info>" . count($functions) . "</info>"); $this->saveFunctionsList($basePath, $functions); if ($includeExamples == Parser::EXPORT_EXAMPLES) { $this->saveExamples($basePath, $examples); $this->output->writeln("Total examples: <info>" . $results->countAllExamples() . "</info>"); } if ($this->output->isVerbose()) { foreach ($results->getWarnings() as $funcName => $warnings) { $this->output->writeln("<comment>Warning in {$funcName}</comment>"); foreach ($warnings as $warning) { $this->output->writeln($warning); } } } if ($this->output->isVeryVerbose()) { foreach (array_keys($results->getSkipped()) as $filename) { $this->output->writeln("<comment>Skipped {$filename}</comment>"); } } // $this->output->writeln("Total: <comment>${count}</comment> examples"); }