Skip to content

Commit

Permalink
Add KnownEnphpBugsException test
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlvtech committed May 23, 2019
1 parent 76cd4c7 commit ff731f6
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

0 comments on commit ff731f6

Please sign in to comment.