xref: /php-src/sapi/cli/tests/016.phpt (revision dcc3255b)
1--TEST--
2CLI -a and readline
3--EXTENSIONS--
4readline
5--SKIPIF--
6<?php
7include "skipif.inc";
8if (readline_info('done') === NULL) {
9    die ("skip need readline support");
10}
11?>
12--FILE--
13<?php
14$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
15
16// disallow console escape sequences that may break the output
17putenv('TERM=VT100');
18
19$codes = array();
20
21$codes[1] = <<<EOT
22echo 'Hello world';
23exit
24EOT;
25
26$codes[] = <<<EOT
27echo 'multine
28single
29quote';
30exit
31EOT;
32
33$codes[] = <<<EOT
34echo <<<HEREDOC
35Here
36comes
37the
38doc
39HEREDOC;
40EOT;
41
42$codes[] = <<<EOT
43if (0) {
44    echo "I'm not there";
45}
46echo "Done";
47EOT;
48
49$codes[] = <<<EOT
50function a_function_with_some_name() {
51    echo "I was called!";
52}
53a_function_w	);
54EOT;
55
56foreach ($codes as $key => $code) {
57    echo "\n--------------\nSnippet no. $key:\n--------------\n";
58    $code = escapeshellarg($code);
59    echo `echo $code | $php -a`, "\n";
60}
61
62echo "\nDone\n";
63?>
64--EXPECT--
65--------------
66Snippet no. 1:
67--------------
68Interactive shell
69
70php > echo 'Hello world';
71Hello world
72php > exit
73
74
75--------------
76Snippet no. 2:
77--------------
78Interactive shell
79
80php > echo 'multine
81php ' single
82php ' quote';
83multine
84single
85quote
86php > exit
87
88
89--------------
90Snippet no. 3:
91--------------
92Interactive shell
93
94php > echo <<<HEREDOC
95<<< > Here
96<<< > comes
97<<< > the
98<<< > doc
99<<< > HEREDOC;
100Here
101comes
102the
103doc
104php >
105
106--------------
107Snippet no. 4:
108--------------
109Interactive shell
110
111php > if (0) {
112php {     echo "I'm not there";
113php { }
114php > echo "Done";
115Done
116php >
117
118--------------
119Snippet no. 5:
120--------------
121Interactive shell
122
123php > function a_function_with_some_name() {
124php {     echo "I was called!";
125php { }
126php > a_function_with_some_name();
127I was called!
128php >
129
130Done
131