xref: /php-src/sapi/cli/tests/024.phpt (revision f16b34f1)
1--TEST--
2multiple files syntax check
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8function run_and_output($cmd) {
9    exec($cmd, $output, $exit_code);
10    print_r($output);
11    var_dump($exit_code);
12}
13
14$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
15
16$filename_good = __DIR__."/024_good.test.php";
17$filename_good_escaped = escapeshellarg($filename_good);
18$filename_bad = __DIR__."/024_bad.test.php";
19$filename_bad_escaped = escapeshellarg($filename_bad);
20
21$code = '
22<?php
23
24echo "hi";
25';
26
27file_put_contents($filename_good, $code);
28
29$code = '
30<?php
31
32class test
33    private $var;
34}
35
36?>
37';
38
39file_put_contents($filename_bad, $code);
40
41run_and_output("$php -n -l $filename_good_escaped $filename_good_escaped 2>&1");
42run_and_output("$php -n -l $filename_good_escaped some.unknown $filename_good_escaped 2>&1");
43run_and_output("$php -n -l $filename_good_escaped $filename_bad_escaped $filename_good_escaped 2>&1");
44run_and_output("$php -n -l $filename_bad_escaped $filename_bad_escaped 2>&1");
45run_and_output("$php -n -l $filename_bad_escaped some.unknown $filename_bad_escaped 2>&1");
46run_and_output("$php -n -l $filename_bad_escaped $filename_bad_escaped some.unknown 2>&1");
47
48echo "Done\n";
49?>
50--CLEAN--
51<?php
52@unlink($filename_good);
53@unlink($filename_bad);
54?>
55--EXPECTF--
56Array
57(
58    [0] => No syntax errors detected in %s024_good.test.php
59    [1] => No syntax errors detected in %s024_good.test.php
60)
61int(0)
62Array
63(
64    [0] => No syntax errors detected in %s024_good.test.php
65    [1] => Could not open input file: some.unknown
66    [2] => No syntax errors detected in %s024_good.test.php
67)
68int(1)
69Array
70(
71    [0] => No syntax errors detected in %s024_good.test.php
72    [1] =>
73    [2] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
74    [3] => Errors parsing %s024_bad.test.php
75    [4] => No syntax errors detected in %s024_good.test.php
76)
77int(255)
78Array
79(
80    [0] =>
81    [1] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
82    [2] => Errors parsing %s024_bad.test.php
83    [3] =>
84    [4] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
85    [5] => Errors parsing %s024_bad.test.php
86)
87int(255)
88Array
89(
90    [0] =>
91    [1] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
92    [2] => Errors parsing %s024_bad.test.php
93    [3] => Could not open input file: some.unknown
94    [4] =>
95    [5] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
96    [6] => Errors parsing %s024_bad.test.php
97)
98int(255)
99Array
100(
101    [0] =>
102    [1] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
103    [2] => Errors parsing %s024_bad.test.php
104    [3] =>
105    [4] => Parse error: syntax error, unexpected token "private", expecting "{" in %s on line %d
106    [5] => Errors parsing %s024_bad.test.php
107    [6] => Could not open input file: some.unknown
108)
109int(1)
110Done
111