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