diff --git a/tests/test.php b/tests/test.php index 90c2f84..6eead46 100644 --- a/tests/test.php +++ b/tests/test.php @@ -9,8 +9,9 @@ $filenames = array_values(array_diff($filenames, ['.', '..'])); foreach ($filenames as $key => $filename) { - echo $filename, PHP_EOL; - $code = file_get_contents(SAMPLE_DIR . '/' . $filename); + $path = SAMPLE_DIR . '/' . $filename; + echo $path, PHP_EOL; + $code = file_get_contents($path); try { $code = \Ganlv\EnphpDecoder\AutoDecoder::decode($code); echo $code, PHP_EOL; @@ -19,3 +20,23 @@ exit(1); } } + +define('BUG_SAMPLE_DIR', __DIR__ . '/bug_samples'); +$filenames = scandir(BUG_SAMPLE_DIR); +$filenames = array_values(array_diff($filenames, ['.', '..'])); + +foreach ($filenames as $key => $filename) { + $path = BUG_SAMPLE_DIR . '/' . $filename; + echo $path, PHP_EOL; + $code = file_get_contents($path); + try { + $code = \Ganlv\EnphpDecoder\AutoDecoder::decode($code); + echo $code, PHP_EOL; + exit(3); + } catch (\Ganlv\EnphpDecoder\KnownEnphpBugs\KnownEnphpBugsException $e) { + echo 'KnownEnphpBugsException: ', $e->getMessage(), PHP_EOL; + } catch (Exception $e) { + echo $e->getTraceAsString(); + exit(2); + } +}