Annotation of embedaddon/php/ext/standard/tests/file/popen_pclose_basic-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test popen() and pclose function: basic functionality
                      3: 
                      4: --SKIPIF--
                      5: <?php
                      6: if(substr(PHP_OS, 0, 3) != 'WIN' )
                      7:   die("skip Not Valid for Linux");
                      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: 
                     20: echo "*** Testing popen(): reading from the pipe ***\n";
                     21: 
                     22: $file_path = dirname(__FILE__);
                     23: 
                     24: $string = "Sample String";
                     25: $file_handle = popen(" echo $string", "r");
                     26: fpassthru($file_handle);
                     27: pclose($file_handle);
                     28: 
                     29: echo "*** Testing popen(): writing to the pipe ***\n";
                     30: $arr = array("ggg", "ddd", "aaa", "sss");
                     31: $file_handle = popen("sort", "w");
                     32: $newline = "\n";
                     33: foreach($arr as $str) {
                     34:   fwrite($file_handle, (binary)$str);
                     35:   fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline);
                     36: }
                     37: pclose($file_handle);
                     38: 
                     39: echo "*** Testing popen() and pclose(): return type ***\n";
                     40: $return_value_popen = popen("echo $string", "r");
                     41: fpassthru($return_value_popen);
                     42: var_dump( is_resource($return_value_popen) );
                     43: $return_value_pclose = pclose($return_value_popen);
                     44: var_dump( is_int($return_value_pclose) );
                     45: 
                     46: echo "\n--- Done ---";
                     47: ?>
                     48: --EXPECTF--
                     49: *** Testing popen(): reading from the pipe ***
                     50: Sample String
                     51: *** Testing popen(): writing to the pipe ***
                     52: aaa
                     53: ddd
                     54: ggg
                     55: sss
                     56: *** Testing popen() and pclose(): return type ***
                     57: Sample String
                     58: bool(true)
                     59: bool(true)
                     60: 
                     61: --- Done ---

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>