// Cycle over all ExtractionGroups $testResult = "Logfile for DBpedia Data Extraction (" . date("D M j Y G:i:s T") . ")\n"; // Cycle over all ExtractionGroups foreach ($job->getExtractionGroups() as $currentGroup) { // Cycle over all extractors foreach ($currentGroup->getExtractors() as $extractor) { $testResult .= "\nResults for: " . $extractor->getExtractorID() . "\n"; foreach ($sourceFiles as $key => $page) { // Only get files, which are available for the extractor if (!isset($resultFiles[$extractor->getExtractorID()][$key])) { continue; } $currentResult = trim($currentGroup->getDestination()->getExtractionResult($page)); $expectedResult = trim(file_get_contents($resultFiles[$extractor->getExtractorID()][$key])); $testUnit = new TestUnit($currentResult, $expectedResult); $testResult .= "\n{$page}: "; if ($testUnit->compare()) { $testResult .= "PASSED."; } else { $testResult .= "FAILED.\nErrors: " . $testUnit->getErrorCount() . "\n" . $testUnit->getErrors(); } } } } echo $testResult; $testResultHTML = "<html>\n" . "<head>\n<style>\n" . "body { font-family:sans-serif; font-size:13px; }\n" . ".passed {color:green;}\n" . ".failed {color:red;}\n" . "</style>\n" . "<title>DBpedia Extraction Test" . date("D M j Y G:i:s T") . "</title>\n</head>\n<body>"; $testResultHTML .= str_replace("\n", "<br />", htmlspecialchars($testResult)); $testResultHTML = str_replace("PASSED", "<span class=\"passed\">PASSED</span>", $testResultHTML); $testResultHTML = str_replace("FAILED", "<span class=\"failed\">FAILED</span>", $testResultHTML); $testResultHTML .= "\n</body>\n</html>"; file_put_contents(dirname(__FILE__) . "/testlog.html", $testResultHTML);