From 40c790c9f61e8fa6a134f92e755682b2f1829e5a Mon Sep 17 00:00:00 2001 From: Josie Messa Date: Tue, 4 Mar 2008 17:11:10 +0000 Subject: [PATCH] - new tests for readdir() function --- ext/standard/tests/dir/readdir_basic.phpt | 81 +++++ ext/standard/tests/dir/readdir_error.phpt | 51 +++ .../tests/dir/readdir_variation1.phpt | 333 ++++++++++++++++++ .../tests/dir/readdir_variation2.phpt | 46 +++ .../tests/dir/readdir_variation3.phpt | 82 +++++ .../tests/dir/readdir_variation4.phpt | 277 +++++++++++++++ .../tests/dir/readdir_variation5.phpt | 207 +++++++++++ .../tests/dir/readdir_variation6.phpt | 87 +++++ 8 files changed, 1164 insertions(+) create mode 100644 ext/standard/tests/dir/readdir_basic.phpt create mode 100644 ext/standard/tests/dir/readdir_error.phpt create mode 100644 ext/standard/tests/dir/readdir_variation1.phpt create mode 100644 ext/standard/tests/dir/readdir_variation2.phpt create mode 100644 ext/standard/tests/dir/readdir_variation3.phpt create mode 100644 ext/standard/tests/dir/readdir_variation4.phpt create mode 100644 ext/standard/tests/dir/readdir_variation5.phpt create mode 100644 ext/standard/tests/dir/readdir_variation6.phpt diff --git a/ext/standard/tests/dir/readdir_basic.phpt b/ext/standard/tests/dir/readdir_basic.phpt new file mode 100644 index 00000000000..c6ea2007dc4 --- /dev/null +++ b/ext/standard/tests/dir/readdir_basic.phpt @@ -0,0 +1,81 @@ +--TEST-- +Test readdir() function : basic functionality +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : basic functionality *** + +-- Call readdir() with $path argument -- +resource(%d) of type (stream) +string(1) "." +string(2) ".." +string(18) "readdir_basic1.tmp" +string(18) "readdir_basic2.tmp" +string(18) "readdir_basic3.tmp" + +-- Call readdir() without $path argument -- +resource(%d) of type (stream) +string(1) "." +string(2) ".." +string(18) "readdir_basic1.tmp" +string(18) "readdir_basic2.tmp" +string(18) "readdir_basic3.tmp" +===DONE=== +--UEXPECTF-- +*** Testing readdir() : basic functionality *** + +-- Call readdir() with $path argument -- +resource(%d) of type (stream) +unicode(1) "." +unicode(2) ".." +unicode(18) "readdir_basic1.tmp" +unicode(18) "readdir_basic2.tmp" +unicode(18) "readdir_basic3.tmp" + +-- Call readdir() without $path argument -- +resource(%d) of type (stream) +unicode(1) "." +unicode(2) ".." +unicode(18) "readdir_basic1.tmp" +unicode(18) "readdir_basic2.tmp" +unicode(18) "readdir_basic3.tmp" +===DONE=== diff --git a/ext/standard/tests/dir/readdir_error.phpt b/ext/standard/tests/dir/readdir_error.phpt new file mode 100644 index 00000000000..24b51cffa62 --- /dev/null +++ b/ext/standard/tests/dir/readdir_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test readdir() function : error conditions - Incorrect number of args +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : error conditions *** + +-- Testing readdir() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for readdir() in %s on line %d +NULL +===DONE=== +--UEXPECTF-- +*** Testing readdir() : error conditions *** + +-- Testing readdir() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for readdir() in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation1.phpt b/ext/standard/tests/dir/readdir_variation1.phpt new file mode 100644 index 00000000000..b70f47bcef1 --- /dev/null +++ b/ext/standard/tests/dir/readdir_variation1.phpt @@ -0,0 +1,333 @@ +--TEST-- +Test readdir() function : usage variations - different data types as $dir_handle arg +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing readdir() : usage variations *** + +-- Iteration 1 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) +===DONE=== +--UEXPECTF-- +*** Testing readdir() : usage variations *** + +-- Iteration 1 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation2.phpt b/ext/standard/tests/dir/readdir_variation2.phpt new file mode 100644 index 00000000000..9b7432f69fd --- /dev/null +++ b/ext/standard/tests/dir/readdir_variation2.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test readdir() function : usage variations - empty directories +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : usage variations *** + +-- Pass an empty directory to readdir() -- +string(1) "." +string(2) ".." +===DONE=== +--UEXPECTF-- +*** Testing readdir() : usage variations *** + +-- Pass an empty directory to readdir() -- +unicode(1) "." +unicode(2) ".." +===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation3.phpt b/ext/standard/tests/dir/readdir_variation3.phpt new file mode 100644 index 00000000000..1eca801ab5c --- /dev/null +++ b/ext/standard/tests/dir/readdir_variation3.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test readdir() function : usage variations - sub-directories +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : usage variations *** +array(5) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(9) "file1.tmp" + [3]=> + string(9) "file2.tmp" + [4]=> + string(10) "sub_folder" +} +===DONE=== +--UEXPECTF-- +*** Testing readdir() : usage variations *** +array(5) { + [0]=> + unicode(1) "." + [1]=> + unicode(2) ".." + [2]=> + unicode(9) "file1.tmp" + [3]=> + unicode(9) "file2.tmp" + [4]=> + unicode(10) "sub_folder" +} +===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation4.phpt b/ext/standard/tests/dir/readdir_variation4.phpt new file mode 100644 index 00000000000..6690e52997d --- /dev/null +++ b/ext/standard/tests/dir/readdir_variation4.phpt @@ -0,0 +1,277 @@ +--TEST-- +Test readdir() function : usage variations - different file names +--FILE-- + $input) { + echo "\n-- Iteration $iterator --\n"; + $handle = "fp{$iterator}"; + var_dump( $$handle = fopen($dir_path . $input . '.tmp', 'w') ); + var_dump( fwrite($$handle, $key)); + fclose($$handle); + $iterator++; +}; + +echo "\n-- Call to readdir() --\n"; +$dir_handle = opendir($dir_path); +while(FALSE !== ($file = readdir($dir_handle))){ + + // different OS order files differently so will + // store file names into an array so can use sorted in expected output + $contents[] = $file; + + // remove files while going through directory + @unlink($dir_path . $file); +} + +// more important to check that all contents are present than order they are returned in +sort($contents); +var_dump($contents); + +closedir($dir_handle); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : usage variations *** + +-- Iteration 1 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 2 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 3 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 4 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 5 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 6 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 7 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 8 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 9 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 10 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d +resource(%d) of type (stream) +int(2) + +-- Iteration 12 -- +resource(%d) of type (stream) +int(2) + +-- Iteration 13 -- +resource(%d) of type (stream) +int(2) + +-- Iteration 14 -- +resource(%d) of type (stream) +int(2) + +-- Call to readdir() -- +array(16) { + [0]=> + string(9) "-10.5.tmp" + [1]=> + string(9) "-2345.tmp" + [2]=> + string(1) "." + [3]=> + string(2) ".." + [4]=> + string(4) ".tmp" + [5]=> + string(7) "0.5.tmp" + [6]=> + string(5) "0.tmp" + [7]=> + string(17) "1.23456789E-9.tmp" + [8]=> + string(5) "1.tmp" + [9]=> + string(8) "10.5.tmp" + [10]=> + string(9) "12345.tmp" + [11]=> + string(16) "123456789000.tmp" + [12]=> + string(9) "Array.tmp" + [13]=> + string(15) "double_file.tmp" + [14]=> + string(11) "hd_file.tmp" + [15]=> + string(15) "single_file.tmp" +} +===DONE=== +--UEXPECTF-- +*** Testing readdir() : usage variations *** + +-- Iteration 1 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 2 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 3 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 4 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 5 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 6 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 7 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 8 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 9 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 10 -- +resource(%d) of type (stream) +int(1) + +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d +resource(%d) of type (stream) +int(2) + +-- Iteration 12 -- +resource(%d) of type (stream) +int(2) + +-- Iteration 13 -- +resource(%d) of type (stream) +int(2) + +-- Iteration 14 -- +resource(%d) of type (stream) +int(2) + +-- Call to readdir() -- +array(16) { + [0]=> + unicode(9) "-10.5.tmp" + [1]=> + unicode(9) "-2345.tmp" + [2]=> + unicode(1) "." + [3]=> + unicode(2) ".." + [4]=> + unicode(4) ".tmp" + [5]=> + unicode(7) "0.5.tmp" + [6]=> + unicode(5) "0.tmp" + [7]=> + unicode(17) "1.23456789E-9.tmp" + [8]=> + unicode(5) "1.tmp" + [9]=> + unicode(8) "10.5.tmp" + [10]=> + unicode(9) "12345.tmp" + [11]=> + unicode(16) "123456789000.tmp" + [12]=> + unicode(9) "Array.tmp" + [13]=> + unicode(15) "double_file.tmp" + [14]=> + unicode(11) "hd_file.tmp" + [15]=> + unicode(15) "single_file.tmp" +} +===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation5.phpt b/ext/standard/tests/dir/readdir_variation5.phpt new file mode 100644 index 00000000000..784c3ce8d56 --- /dev/null +++ b/ext/standard/tests/dir/readdir_variation5.phpt @@ -0,0 +1,207 @@ +--TEST-- +Test readdir() function : usage variations - different permissions +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : usage variations *** + +-- Iteration 1 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 2 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 3 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 4 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 5 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 6 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 7 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 8 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 9 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" + +-- Iteration 10 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +string(%d) "%s" +===DONE=== +--UEXPECTF-- +*** Testing readdir() : usage variations *** + +-- Iteration 1 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 2 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 3 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 4 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 5 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 6 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 7 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 8 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 9 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" + +-- Iteration 10 -- +bool(true) +resource(%d) of type (stream) +-- Calling readdir() -- +unicode(%d) "%s" +===DONE=== diff --git a/ext/standard/tests/dir/readdir_variation6.phpt b/ext/standard/tests/dir/readdir_variation6.phpt new file mode 100644 index 00000000000..3e70fb14798 --- /dev/null +++ b/ext/standard/tests/dir/readdir_variation6.phpt @@ -0,0 +1,87 @@ +--TEST-- +Test readdir() function : usage variations - operate on previously opened directory +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +*** Testing readdir() : usage variations *** + +-- Reading Directory Contents with Previous Handle -- +string(1) "." +string(2) ".." +string(23) "readdir_variation61.tmp" +string(23) "readdir_variation62.tmp" +string(23) "readdir_variation63.tmp" + +-- Reading Directory Contents with Current Handle (no arguments supplied) -- +string(1) "." +string(2) ".." +string(23) "readdir_variation61.tmp" +string(23) "readdir_variation62.tmp" +string(23) "readdir_variation63.tmp" +===DONE=== +--UEXPECTF-- +*** Testing readdir() : usage variations *** + +-- Reading Directory Contents with Previous Handle -- +unicode(1) "." +unicode(2) ".." +unicode(23) "readdir_variation61.tmp" +unicode(23) "readdir_variation62.tmp" +unicode(23) "readdir_variation63.tmp" + +-- Reading Directory Contents with Current Handle (no arguments supplied) -- +unicode(1) "." +unicode(2) ".." +unicode(23) "readdir_variation61.tmp" +unicode(23) "readdir_variation62.tmp" +unicode(23) "readdir_variation63.tmp" +===DONE===