diff options
author | Pierre Joye <pajoye@php.net> | 2011-09-16 10:45:04 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2011-09-16 10:45:04 +0000 |
commit | c6b74fe20913a7e30c8b9642a17a75c716091ef6 (patch) | |
tree | 89755c89ffc071a047e5898e013e5c4f7d1f8c03 /ext/standard/tests/dir | |
parent | c3741ad9739d6bba7041f7fb9562e0ff388110a0 (diff) | |
download | php-git-c6b74fe20913a7e30c8b9642a17a75c716091ef6.tar.gz |
- add -win32 versions and skipif
Diffstat (limited to 'ext/standard/tests/dir')
22 files changed, 1321 insertions, 0 deletions
diff --git a/ext/standard/tests/dir/dir_variation1-win32.phpt b/ext/standard/tests/dir/dir_variation1-win32.phpt new file mode 100644 index 0000000000..1f7f4a2cf3 --- /dev/null +++ b/ext/standard/tests/dir/dir_variation1-win32.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test dir() function : usage variations - unexpected value for 'dir' argument +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* + * Prototype : object dir(string $directory[, resource $context]) + * Description: Directory class with properties, handle and class and methods read, rewind and close + * Source code: ext/standard/dir.c + */ + +/* + * Passing non string values to 'directory' argument of dir() and see + * that the function outputs proper warning messages wherever expected. + */ + +echo "*** Testing dir() : unexpected values for \$directory argument ***\n"; + +// get an unset variable +$unset_var = 10; +unset($unset_var); + +class A +{ + public $var; + public function init() { + $this->var = 10; + } +} + +// get a resource variable +$fp = fopen(__FILE__, "r"); // get a file handle +$dfp = opendir( dirname(__FILE__) ); // get a dir handle + +// unexpected values to be passed to $directory argument +$unexpected_values = array ( + + // array data +/*1*/ array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data +/*6*/ NULL, + null, + + // boolean data +/*8*/ true, + false, + TRUE, + FALSE, + + // empty data +/*12*/ "", + '', + + // undefined data +/*14*/ @$undefined_var, + + // unset data +/*15*/ @$unset_var, + + // resource variable(dir and file handle) +/*16*/ $fp, + $dfp, + + // object data +/*18*/ new A() +); + +// loop through various elements of $unexpected_values to check the behavior of dir() +$iterator = 1; +foreach( $unexpected_values as $unexpected_value ) { + echo "\n-- Iteration $iterator --\n"; + var_dump( dir($unexpected_value) ); + $iterator++; +} + +fclose($fp); +closedir($dfp); +echo "Done"; +?> +--EXPECTF-- +*** Testing dir() : unexpected values for $directory argument *** + +-- Iteration 1 -- + +Warning: dir() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: dir() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: dir() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: dir() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: dir() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- + +Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: dir(1): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 9 -- +bool(false) + +-- Iteration 10 -- + +Warning: dir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: dir(1): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- + +Warning: dir() expects parameter 1 to be string, resource given in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: dir() expects parameter 1 to be string, resource given in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: dir() expects parameter 1 to be string, object given in %s on line %d +NULL +Done
\ No newline at end of file diff --git a/ext/standard/tests/dir/dir_variation1.phpt b/ext/standard/tests/dir/dir_variation1.phpt index ad912c008f..abb4719504 100644 --- a/ext/standard/tests/dir/dir_variation1.phpt +++ b/ext/standard/tests/dir/dir_variation1.phpt @@ -1,5 +1,11 @@ --TEST-- Test dir() function : usage variations - unexpected value for 'dir' argument +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* diff --git a/ext/standard/tests/dir/dir_variation5-win32.phpt b/ext/standard/tests/dir/dir_variation5-win32.phpt new file mode 100644 index 0000000000..e70b9d3533 --- /dev/null +++ b/ext/standard/tests/dir/dir_variation5-win32.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test dir() function : usage variations - open a file instead of directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* + * Prototype : object dir(string $directory[, resource $context]) + * Description: Directory class with properties, handle and class and methods read, rewind and close + * Source code: ext/standard/dir.c + */ + +/* + * Passing a file as argument to dir() function instead of a directory + * and checking if proper warning message is generated. + */ + +echo "*** Testing dir() : open a file instead of a directory ***\n"; + +// open the file instead of directory +$d = dir(__FILE__); +var_dump( $d ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing dir() : open a file instead of a directory *** + +Warning: dir(%s): The directory name is invalid. (code: %d) in %s on line %d + +Warning: dir(%s): failed to open dir: %s in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/dir/dir_variation5.phpt b/ext/standard/tests/dir/dir_variation5.phpt index 2399c634c5..c7450eafc0 100644 --- a/ext/standard/tests/dir/dir_variation5.phpt +++ b/ext/standard/tests/dir/dir_variation5.phpt @@ -1,5 +1,11 @@ --TEST-- Test dir() function : usage variations - open a file instead of directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* diff --git a/ext/standard/tests/dir/dir_variation6-win32.phpt b/ext/standard/tests/dir/dir_variation6-win32.phpt new file mode 100644 index 0000000000..e0e4749809 --- /dev/null +++ b/ext/standard/tests/dir/dir_variation6-win32.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test dir() function : usage variations - non-existent directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* + * Prototype : object dir(string $directory[, resource $context]) + * Description: Directory class with properties, handle and class and methods read, rewind and close + * Source code: ext/standard/dir.c + */ + +/* + * Passing a non-existent directory as argument to dir() function + * and checking to see if proper warning message is output. + */ +echo "*** Testing dir() : open a non-existent directory ***\n"; + +// create the temporary directory +$file_path = dirname(__FILE__); +$dir_path = $file_path."/dir_variation6"; +@mkdir($dir_path); + +// open existent directory +$d = dir($dir_path); +$d->close(); //close the dir + +// remove directory and try to open the same(non-existent) directory again +rmdir($dir_path); +clearstatcache(); + +echo "-- opening previously removed directory --\n"; +var_dump( dir($dir_path) ); + +// point to a non-existent directory +$non_existent_dir = $file_path."/non_existent_dir"; +echo "-- opening non-existent directory --\n"; +$d = dir($non_existent_dir); +var_dump( $d ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing dir() : open a non-existent directory *** +-- opening previously removed directory -- + +Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d + +Warning: dir(%s): failed to open dir: %s in %s on line %d +bool(false) +-- opening non-existent directory -- + +Warning: dir(%s): The system cannot find the file specified. (code: %d) in %s on line %d + +Warning: dir(%s): failed to open dir: %s in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/dir/dir_variation6.phpt b/ext/standard/tests/dir/dir_variation6.phpt index e42057ed15..71cbf1fa17 100644 --- a/ext/standard/tests/dir/dir_variation6.phpt +++ b/ext/standard/tests/dir/dir_variation6.phpt @@ -1,5 +1,11 @@ --TEST-- Test dir() function : usage variations - non-existent directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* diff --git a/ext/standard/tests/dir/dir_variation8-win32.phpt b/ext/standard/tests/dir/dir_variation8-win32.phpt new file mode 100644 index 0000000000..2202fb0487 --- /dev/null +++ b/ext/standard/tests/dir/dir_variation8-win32.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test dir() function : usage variations - checking with wildcard characters +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* + * Prototype : object dir(string $directory[, resource $context]) + * Description: Directory class with properties, handle and class and methods read, rewind and close + * Source code: ext/standard/dir.c + */ + +/* + * Create more than one temporary directory & subdirectory and check if dir() function can open + * those directories when wildcard characters are used to refer to them. + */ + +echo "*** Testing dir() : checking with wildcard characters ***\n"; + +// create the temporary directories +$file_path = dirname(__FILE__); +$dir_path = $file_path."/dir_variation81"; +$sub_dir_path = $dir_path."/sub_dir1"; + +@mkdir($dir_path1); +@mkdir($sub_dir_path); + +/* with different wildcard characters */ + +echo "-- wildcard = '*' --\n"; +var_dump( dir($file_path."/dir_var*") ); +var_dump( dir($file_path."/*") ); + +echo "-- wildcard = '?' --\n"; +var_dump( dir($dir_path."/sub_dir?") ); +var_dump( dir($dir_path."/sub?dir1") ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing dir() : checking with wildcard characters *** +-- wildcard = '*' -- + +Warning: dir(%s/dir_var*,%s/dir_var*): No such file or directory in %s on line %d + +Warning: dir(%s/dir_var*): failed to open dir: %s in %s on line %d +bool(false) + +Warning: dir(%s/*,%s/*): No such file or directory in %s on line %d + +Warning: dir(%s/*): failed to open dir: %s in %s on line %d +bool(false) +-- wildcard = '?' -- + +Warning: dir(%s/dir_variation81/sub_dir?,%s/dir_variation81/sub_dir?): No such file or directory in %s on line %d + +Warning: dir(%s/dir_variation81/sub_dir?): failed to open dir: %s in %s on line %d +bool(false) + +Warning: dir(%s/dir_variation81/sub?dir1,%s/dir_variation81/sub?dir1): No such file or directory in %s on line %d + +Warning: dir(%s/dir_variation81/sub?dir1): failed to open dir: %s in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/dir/dir_variation8.phpt b/ext/standard/tests/dir/dir_variation8.phpt index a0b74a3f61..5ecf449923 100644 --- a/ext/standard/tests/dir/dir_variation8.phpt +++ b/ext/standard/tests/dir/dir_variation8.phpt @@ -1,5 +1,11 @@ --TEST-- Test dir() function : usage variations - checking with wildcard characters +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* diff --git a/ext/standard/tests/dir/dir_variation9-win32.phpt b/ext/standard/tests/dir/dir_variation9-win32.phpt new file mode 100644 index 0000000000..32b0bd946b --- /dev/null +++ b/ext/standard/tests/dir/dir_variation9-win32.phpt @@ -0,0 +1,125 @@ +--TEST-- +Test dir() function : usage variations - relative valid and invalid paths +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* + * Prototype : object dir(string $directory[, resource $context]) + * Description: Directory class with properties, handle and class and methods read, rewind and close + * Source code: ext/standard/dir.c + */ + +/* + * Checking the behavior of dir() function by passing directories which + * have valid and invalid relative path. + */ + +echo "*** Testing dir() : checking with valid and invalid paths ***\n"; + +/* create the temporary directories */ + +$file_path = dirname(__FILE__); + +// directory dir_variation91 with one sub-directory sub_dir11 and sub-sub-directory sub_dir111 +$dir_path1 = $file_path."/dir_variation91"; +$sub_dir11 = $dir_path1."/sub_dir11"; +$sub_dir111 = $sub_dir11."/sub_dir111"; + +// directory dir_variation92 with one sub-directory sub_dir21 +$dir_path2 = $file_path."/dir_variation92"; +$sub_dir21 = $dir_path2."/sub_dir21"; + +@mkdir($dir_path1); +@mkdir($dir_path2); +@mkdir($sub_dir11); +@mkdir($sub_dir111); +@mkdir($sub_dir21); + +// open the directory with valid paths +echo "\n-- With valid paths --\n"; +var_dump( dir("$dir_path1/sub_dir11/sub_dir111/..") ); +var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91") ); +var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir11/..") ); +var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/..") ); + +// open the directory with invalid path +echo "\n-- With invalid paths --\n"; +var_dump( dir("$dir_path1/sub_dir12/sub_dir111/..") ); +var_dump( dir("$dir_path2/sub_dir21/../dir_variation91") ); +var_dump( dir("$dir_path2/sub_dir21/../../dir_variation91/sub_dir12/..") ); +var_dump( dir("$dir_path1/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..") ); + +echo "Done"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); + +$dir_path1 = $file_path."/dir_variation91"; +$sub_dir11 = $dir_path1."/sub_dir11"; +$sub_dir111 = $sub_dir11."/sub_dir111"; +$dir_path2 = $file_path."/dir_variation92"; +$sub_dir21 = $dir_path2."/sub_dir21"; + +rmdir($sub_dir21); +rmdir($sub_dir111); +rmdir($sub_dir11); +rmdir($dir_path1); +rmdir($dir_path2); +?> +--EXPECTF-- +*** Testing dir() : checking with valid and invalid paths *** + +-- With valid paths -- +object(Directory)#%d (2) { + ["path"]=> + string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/.." + ["handle"]=> + resource(%d) of type (stream) +} +object(Directory)#%d (2) { + ["path"]=> + string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91" + ["handle"]=> + resource(%d) of type (stream) +} +object(Directory)#%d (2) { + ["path"]=> + string(%d) "%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir11/.." + ["handle"]=> + resource(%d) of type (stream) +} +object(Directory)#%d (2) { + ["path"]=> + string(%d) "%s/dir_variation91/sub_dir11/sub_dir111/../../../dir_variation92/sub_dir21/.." + ["handle"]=> + resource(%d) of type (stream) +} + +-- With invalid paths -- + +Warning: dir(%sdir_variation91/sub_dir12/sub_dir111/..,%sdir_variation91/sub_dir12/sub_dir111/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d + +Warning: dir(%s/dir_variation91/sub_dir12/sub_dir111/..): failed to open dir: %s in %s on line %d +bool(false) + +Warning: dir(%sdir_variation92/sub_dir21/../dir_variation91,%sdir_variation92/sub_dir21/../dir_variation91): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d + +Warning: dir(%s/dir_variation92/sub_dir21/../dir_variation91): failed to open dir: %s in %s on line %d +bool(false) + +Warning: dir(%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..,%sdir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): The system cannot find the file specified. (code: 2) in %sdir_variation9-win32.php on line %d + +Warning: dir(%s/dir_variation92/sub_dir21/../../dir_variation91/sub_dir12/..): failed to open dir: %s in %s on line %d +bool(false) + +Warning: dir(%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..,%sdir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): The system cannot find the path specified. (code: 3) in %sdir_variation9-win32.php on line %d + +Warning: dir(%s/dir_variation91/sub_dir11/sub_dir111/../../dir_variation92/sub_dir21/..): failed to open dir: %s in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/dir/dir_variation9.phpt b/ext/standard/tests/dir/dir_variation9.phpt index 22f3d5baab..458d0b896f 100644 --- a/ext/standard/tests/dir/dir_variation9.phpt +++ b/ext/standard/tests/dir/dir_variation9.phpt @@ -1,5 +1,11 @@ --TEST-- Test dir() function : usage variations - relative valid and invalid paths +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* diff --git a/ext/standard/tests/dir/opendir_error2-win32.phpt b/ext/standard/tests/dir/opendir_error2-win32.phpt new file mode 100644 index 0000000000..c3ecd35349 --- /dev/null +++ b/ext/standard/tests/dir/opendir_error2-win32.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test opendir() function : error conditions - Non-existent directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* Prototype : mixed opendir(string $path[, resource $context]) + * Description: Open a directory and return a dir_handle + * Source code: ext/standard/dir.c + */ + +/* + * Pass a non-existent directory as $path argument to opendir() to test behaviour + */ + +echo "*** Testing opendir() : error conditions ***\n"; + +echo "\n-- Pass a non-existent absolute path: --\n"; +$path = dirname(__FILE__) . "/idonotexist"; +var_dump(opendir($path)); + +echo "\n-- Pass a non-existent relative path: --\n"; +chdir(dirname(__FILE__)); +var_dump(opendir('idonotexist')); +?> +===DONE=== +--EXPECTF-- +*** Testing opendir() : error conditions *** + +-- Pass a non-existent absolute path: -- + +Warning: opendir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d + +Warning: opendir(%s/idonotexist): failed to open dir: %s in %s on line %d +bool(false) + +-- Pass a non-existent relative path: -- + +Warning: opendir(idonotexist,idonotexist): The system cannot find the file specified. (code: %d) in %s on line %d + +Warning: opendir(idonotexist): failed to open dir: %s in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/dir/opendir_error2.phpt b/ext/standard/tests/dir/opendir_error2.phpt index 0762be2ad3..1c724097b0 100644 --- a/ext/standard/tests/dir/opendir_error2.phpt +++ b/ext/standard/tests/dir/opendir_error2.phpt @@ -1,5 +1,11 @@ --TEST-- Test opendir() function : error conditions - Non-existent directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* Prototype : mixed opendir(string $path[, resource $context]) diff --git a/ext/standard/tests/dir/opendir_variation1-win32.phpt b/ext/standard/tests/dir/opendir_variation1-win32.phpt new file mode 100644 index 0000000000..9a75a5b6a7 --- /dev/null +++ b/ext/standard/tests/dir/opendir_variation1-win32.phpt @@ -0,0 +1,248 @@ +--TEST-- +Test opendir() function : usage variations - different data types as $path arg +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* Prototype : mixed opendir(string $path[, resource $context]) + * Description: Open a directory and return a dir_handle + * Source code: ext/standard/dir.c + */ + +/* + * Pass different data types as $path argument to opendir() to test behaviour + * Where possible, an existing directory has been entered as a string value + */ + +echo "*** Testing opendir() : usage variations ***\n"; + +// create directory to be passed as string value where possible +$path = dirname(__FILE__) . "/opendir_variation1"; +mkdir($path); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA { + + var $path; + function __construct($path) { + $this->path = $path; + } + public function __toString() { + return $this->path; + } +} + +// heredoc string +$heredoc = <<<EOT +$path +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $path argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "$path", + 'string', + $heredoc, + + // object data +/*22*/ new classA($path), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of opendir() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( $dh = opendir($input) ); + if ($dh) { + closedir($dh); + } + $iterator++; +}; + +fclose($fp); +?> +===DONE=== +--CLEAN-- +<?php +$path = dirname(__FILE__) . "/opendir_variation1"; +rmdir($path); +?> +--EXPECTF-- +*** Testing opendir() : usage variations *** + +-- Iteration 1 -- + +Warning: opendir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(0): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(1): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: opendir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(12345): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: opendir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(-2345): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: opendir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(10.5): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: opendir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(-10.5): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: opendir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(123456789000): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: opendir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(1.23456789E-9): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: opendir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(0.5): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +bool(false) + +-- Iteration 12 -- + +Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(1): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- + +Warning: opendir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(1): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +bool(false) + +-- Iteration 18 -- + +Warning: opendir() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 19 -- +resource(%d) of type (stream) + +-- Iteration 20 -- + +Warning: opendir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: opendir(string): failed to open dir: %s in %s on line %d +bool(false) + +-- Iteration 21 -- +resource(%d) of type (stream) + +-- Iteration 22 -- +resource(%d) of type (stream) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- +bool(false) + +-- Iteration 25 -- + +Warning: opendir() expects parameter 1 to be string, resource given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/dir/opendir_variation1.phpt b/ext/standard/tests/dir/opendir_variation1.phpt index dc10356f56..8d195e1e62 100644 --- a/ext/standard/tests/dir/opendir_variation1.phpt +++ b/ext/standard/tests/dir/opendir_variation1.phpt @@ -1,5 +1,11 @@ --TEST-- Test opendir() function : usage variations - different data types as $path arg +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* Prototype : mixed opendir(string $path[, resource $context]) diff --git a/ext/standard/tests/dir/opendir_variation6-win32.phpt b/ext/standard/tests/dir/opendir_variation6-win32.phpt new file mode 100644 index 0000000000..b5a4aa466a --- /dev/null +++ b/ext/standard/tests/dir/opendir_variation6-win32.phpt @@ -0,0 +1,75 @@ +--TEST-- +Test opendir() function : usage variations - Different wildcards +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* Prototype : mixed opendir(string $path[, resource $context]) + * Description: Open a directory and return a dir_handle + * Source code: ext/standard/dir.c + */ + +/* + * Pass paths containing wildcards to test if opendir() recognises them + */ + +echo "*** Testing opendir() : usage variations ***\n"; +// create the temporary directories +$file_path = dirname(__FILE__); +$dir_path = $file_path . "/opendir_variation6"; +$sub_dir_path = $dir_path . "/sub_dir1"; + +mkdir($dir_path); +mkdir($sub_dir_path); + +// with different wildcard characters + +echo "\n-- Wildcard = '*' --\n"; +var_dump( opendir($file_path . "/opendir_var*") ); +var_dump( opendir($file_path . "/*") ); + +echo "\n-- Wildcard = '?' --\n"; +var_dump( opendir($dir_path . "/sub_dir?") ); +var_dump( opendir($dir_path . "/sub?dir1") ); + +?> +===DONE=== +--CLEAN-- +<?php +$dir_path = dirname(__FILE__) . "/opendir_variation6"; +$sub_dir_path = $dir_path . "/sub_dir1"; + +rmdir($sub_dir_path); +rmdir($dir_path); +?> +--EXPECTF-- +*** Testing opendir() : usage variations *** + +-- Wildcard = '*' -- + +Warning: opendir(%s/opendir_var*,%s/opendir_var*): No such file or directory in %s on line %d + +Warning: opendir(%s/opendir_var*): failed to open dir: %s in %s on line %d +bool(false) + +Warning: opendir(%s/*,%s/*): No such file or directory in %s on line %d + +Warning: opendir(%s/*): failed to open dir: %s in %s on line %d +bool(false) + +-- Wildcard = '?' -- + +Warning: opendir(%s/opendir_variation6/sub_dir?,%s/opendir_variation6/sub_dir?): No such file or directory in %s on line %d + +Warning: opendir(%s/opendir_variation6/sub_dir?): failed to open dir: %s in %s on line %d +bool(false) + +Warning: opendir(%s/opendir_variation6/sub?dir1,%s/opendir_variation6/sub?dir1): No such file or directory in %s on line %d + +Warning: opendir(%s/opendir_variation6/sub?dir1): failed to open dir: %s in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/dir/opendir_variation6.phpt b/ext/standard/tests/dir/opendir_variation6.phpt index 01e8225d59..f3fc0bd6df 100644 --- a/ext/standard/tests/dir/opendir_variation6.phpt +++ b/ext/standard/tests/dir/opendir_variation6.phpt @@ -1,5 +1,11 @@ --TEST-- Test opendir() function : usage variations - Different wildcards +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* Prototype : mixed opendir(string $path[, resource $context]) diff --git a/ext/standard/tests/dir/scandir_error2-win32.phpt b/ext/standard/tests/dir/scandir_error2-win32.phpt new file mode 100644 index 0000000000..9920be747d --- /dev/null +++ b/ext/standard/tests/dir/scandir_error2-win32.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test scandir() function : error conditions - Non-existent directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) + * Description: List files & directories inside the specified path + * Source code: ext/standard/dir.c + */ + +/* + * Pass a directory that does not exist to scandir() to test error messages + */ + +echo "*** Testing scandir() : error conditions ***\n"; + +$directory = dirname(__FILE__) . '/idonotexist'; + +echo "\n-- Pass scandir() an absolute path that does not exist --\n"; +var_dump(scandir($directory)); + +echo "\n-- Pass scandir() a relative path that does not exist --\n"; +var_dump(scandir('/idonotexist')); +?> +===DONE=== +--EXPECTF-- +*** Testing scandir() : error conditions *** + +-- Pass scandir() an absolute path that does not exist -- + +Warning: scandir(%s/idonotexist,%s/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(%s/idonotexist): failed to open dir: %s in %s on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Pass scandir() a relative path that does not exist -- + +Warning: scandir(/idonotexist,/idonotexist): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(/idonotexist): failed to open dir: %s in %s on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/dir/scandir_error2.phpt b/ext/standard/tests/dir/scandir_error2.phpt index 1e99a578ac..b5bfc28c8e 100644 --- a/ext/standard/tests/dir/scandir_error2.phpt +++ b/ext/standard/tests/dir/scandir_error2.phpt @@ -1,5 +1,11 @@ --TEST-- Test scandir() function : error conditions - Non-existent directory +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) diff --git a/ext/standard/tests/dir/scandir_variation1-win32.phpt b/ext/standard/tests/dir/scandir_variation1-win32.phpt new file mode 100644 index 0000000000..a2b5bd4672 --- /dev/null +++ b/ext/standard/tests/dir/scandir_variation1-win32.phpt @@ -0,0 +1,289 @@ +--TEST-- +Test scandir() function : usage variations - different data types as $dir arg +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) + * Description: List files & directories inside the specified path + * Source code: ext/standard/dir.c + */ + +/* + * Pass different data types as $dir argument to test behaviour of scandir() + */ + +echo "*** Testing scandir() : usage variations ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +// get a class +class classA +{ + public function __toString() { + return "Class A object"; + } +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// get a resource variable +$fp = fopen(__FILE__, "r"); + +// unexpected values to be passed to $dir argument +$inputs = array( + + // int data +/*1*/ 0, + 1, + 12345, + -2345, + + // float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // null data +/*10*/ NULL, + null, + + // boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // empty data +/*16*/ "", + '', + array(), + + // string data +/*19*/ "string", + 'string', + $heredoc, + + // object data +/*22*/ new classA(), + + // undefined data +/*23*/ @$undefined_var, + + // unset data +/*24*/ @$unset_var, + + // resource variable +/*25*/ $fp +); + +// loop through each element of $inputs to check the behavior of scandir() +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump( scandir($input) ); + $iterator++; +}; + +fclose($fp); +?> +===DONE=== +--EXPECTF-- +*** Testing scandir() : usage variations *** + +-- Iteration 1 -- + +Warning: scandir(0,0): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(0): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: scandir(12345,12345): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(12345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: scandir(-2345,-2345): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(-2345): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: scandir(10.5,10.5): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: scandir(-10.5,-10.5): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(-10.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: scandir(123456789000,123456789000): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(123456789000): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: scandir(1.23456789E-9,1.23456789E-9): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(1.23456789E-9): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: scandir(0.5,0.5): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(0.5): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: scandir(1,1): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(1): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: scandir() expects parameter 1 to be a valid path, array given in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: scandir(string,string): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(string): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: scandir(hello world,hello world): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(hello world): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: scandir(Class A object,Class A object): The system cannot find the file specified. (code: 2) in %s on line %d + +Warning: scandir(Class A object): failed to open dir: No such file or directory in %sscandir_variation1-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: scandir(): Directory name cannot be empty in %s on line %d +bool(false) + +-- Iteration 25 -- + +Warning: scandir() expects parameter 1 to be a valid path, resource given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation1.phpt b/ext/standard/tests/dir/scandir_variation1.phpt index 0b35413ada..ccd5bb967a 100644 --- a/ext/standard/tests/dir/scandir_variation1.phpt +++ b/ext/standard/tests/dir/scandir_variation1.phpt @@ -1,5 +1,11 @@ --TEST-- Test scandir() function : usage variations - different data types as $dir arg +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) diff --git a/ext/standard/tests/dir/scandir_variation6-win32.phpt b/ext/standard/tests/dir/scandir_variation6-win32.phpt new file mode 100644 index 0000000000..040dc787cc --- /dev/null +++ b/ext/standard/tests/dir/scandir_variation6-win32.phpt @@ -0,0 +1,84 @@ +--TEST-- +Test scandir() function : usage variations - Wildcards in directory path +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die("skip Valid only on Windows"); +} +?> +--FILE-- +<?php +/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) + * Description: List files & directories inside the specified path + * Source code: ext/standard/dir.c + */ + +/* + * Pass a directory path using wildcards as $dir argument to test how scandir() behaves + */ + +echo "*** Testing scandir() : usage variations ***\n"; + +// create the temporary directories +$file_path = dirname(__FILE__); +$dir_path = $file_path . "/scandir_variation6"; +$sub_dir_path = $dir_path . "/sub_dir1"; + +mkdir($dir_path); +mkdir($sub_dir_path); + +// with different wildcard characters + +echo "\n-- Wildcard = '*' --\n"; +var_dump( scandir($file_path . "/scandir_var*") ); +var_dump( scandir($file_path . "/*") ); + +echo "\n-- Wildcard = '?' --\n"; +var_dump( scandir($dir_path . "/sub_dir?") ); +var_dump( scandir($dir_path . "/sub?dir1") ); + +?> +===DONE=== +--CLEAN-- +<?php +$dir_path = dirname(__FILE__) . "/scandir_variation6"; +$sub_dir_path = $dir_path . "/sub_dir1"; + +rmdir($sub_dir_path); +rmdir($dir_path); +?> +--EXPECTF-- +*** Testing scandir() : usage variations *** + +-- Wildcard = '*' -- + +Warning: scandir(%s/scandir_var*,%s/scandir_var*): No such file or directory in %s on line %d + +Warning: scandir(%s/scandir_var*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +Warning: scandir(%s/*,%s/*): No such file or directory in %s on line %d + +Warning: scandir(%s/*): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +-- Wildcard = '?' -- + +Warning: scandir(%s/scandir_variation6/sub_dir?,%s/scandir_variation6/sub_dir?): No such file or directory in %s on line %d + +Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) + +Warning: scandir(%s/scandir_variation6/sub?dir1,%s/scandir_variation6/sub?dir1): No such file or directory in %s on line %d + +Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: No such file or directory in %sscandir_variation6-win32.php on line %d + +Warning: scandir(): (errno %d): %s in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/dir/scandir_variation6.phpt b/ext/standard/tests/dir/scandir_variation6.phpt index 5cb595fe75..754c615290 100644 --- a/ext/standard/tests/dir/scandir_variation6.phpt +++ b/ext/standard/tests/dir/scandir_variation6.phpt @@ -1,5 +1,11 @@ --TEST-- Test scandir() function : usage variations - Wildcards in directory path +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. Not valid for Windows'); +} +?> --FILE-- <?php /* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]]) |