1--TEST--
2Test popen() and pclose function: error conditions
3--SKIPIF--
4<?php
5if(substr(PHP_OS, 0, 3) != 'WIN' && PHP_DEBUG) die("skip Valid only on Windows");
6if(!PHP_DEBUG) die("skip Not Valid for release builds");
7
8ob_start();phpinfo(INFO_GENERAL);$inf=ob_get_contents(); ob_end_clean();
9if (!(strpos($inf, 'MSVC9') || strpos($inf, 'MSVC8'))) die("skip Not Valid for build done with VC < 8");
10?>
11--FILE--
12<?php
13/*
14 * Prototype: resource popen ( string command, string mode )
15 * Description: Opens process file pointer.
16
17 * Prototype: int pclose ( resource handle );
18 * Description: Closes process file pointer.
19 */
20$file_path = dirname(__FILE__);
21echo "*** Testing for error conditions ***\n";
22var_dump( popen() );  // Zero Arguments
23var_dump( popen("abc.txt") );   // Single Argument
24var_dump( popen("abc.txt", "rw") );   // Invalid mode Argument
25var_dump( pclose() );
26$file_handle = fopen($file_path."/popen.tmp", "w");
27var_dump( pclose($file_handle, $file_handle) );
28pclose($file_handle);
29var_dump( pclose(1) );
30echo "\n--- Done ---";
31?>
32--CLEAN--
33<?php
34$file_path = dirname(__FILE__);
35unlink($file_path."/popen.tmp");
36?>
37--EXPECTF--
38*** Testing for error conditions ***
39
40Warning: popen() expects exactly 2 parameters, 0 given in %s on line %d
41NULL
42
43Warning: popen() expects exactly 2 parameters, 1 given in %s on line %d
44NULL
45
46Warning: Invalid parameter detected in CRT function '_fdopen' (%s:%d) in %s on line %d
47
48Warning: popen(abc.txt,rw): Invalid argument in %s on line %d
49bool(false)
50
51Warning: pclose() expects exactly 1 parameter, 0 given in %s on line %d
52bool(false)
53
54Warning: pclose() expects exactly 1 parameter, 2 given in %s on line %d
55bool(false)
56
57Warning: pclose() expects parameter 1 to be resource, integer given in %s on line %d
58bool(false)
59
60--- Done ---'abc.txt' is not recognized as an internal or external command,
61operable program or batch file.
62