xref: /PHP-5.3/sapi/cli/tests/022.phpt (revision 263ab7e2)
1--TEST--
2STDIN/OUT/ERR stream type
3--SKIPIF--
4<?php
5if (!getenv("TEST_PHP_EXECUTABLE")) die("skip TEST_PHP_EXECUTABLE not set");
6if (substr(PHP_OS, 0, 3) == "WIN") die("skip non windows test");
7?>
8--FILE--
9<?php
10$php = getenv("TEST_PHP_EXECUTABLE");
11$socket_file = tempnam(sys_get_temp_dir(), pathinfo(__FILE__, PATHINFO_FILENAME) . '.sock');
12$test_file = dirname(__FILE__) . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc';
13if (file_exists($socket_file)) {
14	unlink($socket_file);
15}
16$socket = stream_socket_server('unix://' . $socket_file);
17var_dump($socket);
18if (!$socket) {
19	exit(1);
20}
21$desc = array(
22	0 => $socket,
23	1 => STDOUT,
24	2 => STDERR,
25);
26$pipes = array();
27$proc = proc_open("$php -n " . escapeshellarg($test_file), $desc, $pipes);
28var_dump($proc);
29if (!$proc) {
30	exit(1);
31}
32
33$client_socket = stream_socket_client('unix://' . $socket_file);
34var_dump($client_socket);
35echo stream_get_contents($client_socket);
36fclose($client_socket);
37
38proc_terminate($proc);
39proc_close($proc);
40unlink($socket_file);
41?>
42--EXPECTF--
43resource(%d) of type (stream)
44resource(%d) of type (process)
45resource(%d) of type (stream)
46resource(%d) of type (stream)
47resource(%d) of type (stream)
48