listLanguages(); $hl->setAutodetectLanguages($lngs); $failed = Array(); foreach($lngs as $language) { $path = __DIR__ . DIRECTORY_SEPARATOR . "detect" . DIRECTORY_SEPARATOR . $language; $this->assertTrue(file_exists($path)); $d = dir($path); while (false !== ($entry = $d->read())) { if ($entry[0] !== ".") { $filePath = $path . DIRECTORY_SEPARATOR . $entry; $content = file_get_contents($filePath); $expected = $language; $r = $hl->highlightAuto($content); $actual = $r->language; if ($expected !== $actual) { $failed[] = "$expected was detected as $actual"; } } } $d->close(); } $this->assertEquals(Array(), $failed); } }