Skip to content

Commit ff731f6

Browse files
committed
Add KnownEnphpBugsException test
1 parent 76cd4c7 commit ff731f6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/test.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
$filenames = array_values(array_diff($filenames, ['.', '..']));
1010

1111
foreach ($filenames as $key => $filename) {
12-
echo $filename, PHP_EOL;
13-
$code = file_get_contents(SAMPLE_DIR . '/' . $filename);
12+
$path = SAMPLE_DIR . '/' . $filename;
13+
echo $path, PHP_EOL;
14+
$code = file_get_contents($path);
1415
try {
1516
$code = \Ganlv\EnphpDecoder\AutoDecoder::decode($code);
1617
echo $code, PHP_EOL;
@@ -19,3 +20,23 @@
1920
exit(1);
2021
}
2122
}
23+
24+
define('BUG_SAMPLE_DIR', __DIR__ . '/bug_samples');
25+
$filenames = scandir(BUG_SAMPLE_DIR);
26+
$filenames = array_values(array_diff($filenames, ['.', '..']));
27+
28+
foreach ($filenames as $key => $filename) {
29+
$path = BUG_SAMPLE_DIR . '/' . $filename;
30+
echo $path, PHP_EOL;
31+
$code = file_get_contents($path);
32+
try {
33+
$code = \Ganlv\EnphpDecoder\AutoDecoder::decode($code);
34+
echo $code, PHP_EOL;
35+
exit(3);
36+
} catch (\Ganlv\EnphpDecoder\KnownEnphpBugs\KnownEnphpBugsException $e) {
37+
echo 'KnownEnphpBugsException: ', $e->getMessage(), PHP_EOL;
38+
} catch (Exception $e) {
39+
echo $e->getTraceAsString();
40+
exit(2);
41+
}
42+
}

0 commit comments

Comments
 (0)