jmessa          Tue Mar  4 17:11:10 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/dir     readdir_variation1.phpt 
                                        readdir_variation2.phpt 
                                        readdir_error.phpt 
                                        readdir_variation6.phpt 
                                        readdir_variation5.phpt 
                                        readdir_basic.phpt 
                                        readdir_variation4.phpt 
                                        readdir_variation3.phpt 
  Log:
  - new tests for readdir() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_variation1.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_variation1.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_variation1.phpt      Tue Mar  4 
17:11:10 2008
@@ -0,0 +1,333 @@
+--TEST--
+Test readdir() function : usage variations - different data types as 
$dir_handle arg
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Pass different data types as $dir_handle argument to readdir() to test 
behaviour
+ */
+
+echo "*** Testing readdir() : 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;
+
+// unexpected values to be passed to $dir_handle 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,
+);
+
+// loop through each element of $inputs to check the behavior of readdir()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump( readdir($input) );
+       $iterator++;
+};
+?>
+===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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_variation2.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_variation2.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_variation2.phpt      Tue Mar  4 
17:11:10 2008
@@ -0,0 +1,46 @@
+--TEST--
+Test readdir() function : usage variations - empty directories
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Pass readdir() a directory handle pointing to an empty directory to test 
behaviour
+ */
+
+echo "*** Testing readdir() : usage variations ***\n";
+
+$path = dirname(__FILE__) . '/readdir_variation2';
+mkdir($path);
+$dir_handle = opendir($path);
+
+echo "\n-- Pass an empty directory to readdir() --\n";
+while(FALSE !== ($file = readdir($dir_handle))){
+       var_dump($file);
+}
+
+closedir($dir_handle);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . '/readdir_variation2';
+rmdir($path);
+?>
+--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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_error.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_error.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_error.phpt   Tue Mar  4 17:11:10 2008
@@ -0,0 +1,51 @@
+--TEST--
+Test readdir() function : error conditions - Incorrect number of args
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Pass incorrect number of arguments to readdir() to test behaviour
+ */
+
+echo "*** Testing readdir() : error conditions ***\n";
+
+
+//Test readdir with one more than the expected number of arguments
+echo "\n-- Testing readdir() function with more than expected no. of arguments 
--\n";
+
+$path = dirname(__FILE__) . "/readdir_error";
+mkdir($path);
+$dir_handle = opendir($path);
+$extra_arg = 10;
+
+var_dump( readdir($dir_handle, $extra_arg) );
+
+// close the handle so can remove dir in CLEAN section
+closedir($dir_handle);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . "/readdir_error";
+rmdir($path);
+?> 
+--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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_variation6.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_variation6.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_variation6.phpt      Tue Mar  4 
17:11:10 2008
@@ -0,0 +1,87 @@
+--TEST--
+Test readdir() function : usage variations - operate on previously opened 
directory
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Open two directory handles on the same directory and pass both
+ * to readdir() to test behaviour
+ */
+
+echo "*** Testing readdir() : usage variations ***\n";
+
+
+include( dirname(__FILE__) . "/../file/file.inc");
+
+// create the temporary directory
+$dir_path = dirname(__FILE__) . "/readdir_variation6";
+mkdir($dir_path);
+
+// create files within the temporary directory
[EMAIL PROTECTED]($dir_path, 3, "alphanumeric", 0755, 1, "w", 
"readdir_variation6");
+
+// open the directory
+$dir_handle1 = opendir($dir_path);
+
+// open the same directory again without closing it
+opendir($dir_path);
+
+echo "\n-- Reading Directory Contents with Previous Handle --\n";
+while (FALSE !== ($file = readdir($dir_handle1))) {
+       var_dump($file);
+}
+
+echo "\n-- Reading Directory Contents with Current Handle (no arguments 
supplied) --\n";
+while (FALSE !== ($file = readdir())) {
+       var_dump($file);
+}
+
+// delete temporary files
+delete_files($dir_path, 3, "readdir_variation6");
+closedir($dir_handle1);
+closedir();
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir_path = dirname(__FILE__) . "/readdir_variation6";
+rmdir($dir_path);
+?>
+--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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_variation5.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_variation5.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_variation5.phpt      Tue Mar  4 
17:11:10 2008
@@ -0,0 +1,207 @@
+--TEST--
+Test readdir() function : usage variations - different permissions
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN') {
+  die('skip Not for Windows');
+}
+// Skip if being run by root (files are always readable, writeable and 
executable)
+$filename = dirname(__FILE__)."/readdir_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+        unlink ($filename);
+        die('skip...cannot be run as root\n');
+}
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Open a directory with different premissions then try to read it
+ * to test behaviour of readdir()
+ */
+
+echo "*** Testing readdir() : usage variations ***\n";
+
+// create the temporary directory
+$dir_path = dirname(__FILE__) . "/readdir_variation5";
+mkdir($dir_path);
+
+/* different values for directory permissions */
+$permission_values = array(
+/*1*/  0477,  // owner has read only, other and group has rwx
+       0677,  // owner has rw only, other and group has rwx
+
+/*3*/  0444,  // all have read only
+       0666,  // all have rw only
+
+/*5*/  0400,  // owner has read only, group and others have no permission
+       0600,   // owner has rw only, group and others have no permission
+
+/*7*/  0470,  // owner has read only, group has rwx & others have no permission
+       0407,  // owner has read only, other has rwx & group has no permission
+
+/*9*/  0670,  // owner has rw only, group has rwx & others have no permission
+/*10*/ 0607   // owner has rw only, group has no permission and others have rwx
+);
+
+// Open directory with different permission values, read and close, expected: 
none of them to succeed.
+$iterator = 1;
+foreach($permission_values as $perm) {
+       echo "\n-- Iteration $iterator --\n";
+       
+       if (is_dir($dir_path)) {
+               chmod ($dir_path, 0777); // change dir permission to allow all 
operation
+               rmdir ($dir_path);
+       }
+       mkdir($dir_path);
+
+       // change the dir permisson to test dir on it
+       var_dump( chmod($dir_path, $perm) );
+       var_dump($dh = opendir($dir_path));
+
+       echo "-- Calling readdir() --\n";
+       var_dump(readdir($dh));
+
+       closedir($dh);
+       $iterator++;
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir_path = dirname(__FILE__) . "/readdir_variation5";
+rmdir($dir_path);
+?>
+--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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_basic.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_basic.phpt   Tue Mar  4 17:11:10 2008
@@ -0,0 +1,81 @@
+--TEST--
+Test readdir() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.C
+ */
+
+/*
+ * Test basic functionality of readdir()
+ */
+
+echo "*** Testing readdir() : basic functionality ***\n";
+
+// include the file.inc for Function: function create_files()
+include(dirname(__FILE__) . "/../file/file.inc");
+
+$path = dirname(__FILE__) . '/readdir_basic';
+mkdir($path);
[EMAIL PROTECTED]($path, 3, 'numeric', 0755, 1, 'w', 'readdir_basic');
+
+echo "\n-- Call readdir() with \$path argument --\n";
+var_dump($dh = opendir($path));
+while( FALSE !== ($file = readdir($dh)) ) {
+       var_dump($file);
+}
+
+echo "\n-- Call readdir() without \$path argument --\n";
+var_dump($dh = opendir($path));
+while( FALSE !== ( $file = readdir() ) ) {
+       var_dump($file);
+}
+
+delete_files($path, 3, 'readdir_basic');
+closedir($dh);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . '/readdir_basic';
+rmdir($path);
+?>
+--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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_variation4.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_variation4.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_variation4.phpt      Tue Mar  4 
17:11:10 2008
@@ -0,0 +1,277 @@
+--TEST--
+Test readdir() function : usage variations - different file names
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Pass a directory handle pointing to a directory that contains 
+ * files with different file names to test how readdir() reads them
+ */
+
+echo "*** Testing readdir() : usage variations ***\n";
+
+$dir_path = dirname(__FILE__) . "/readdir_variation4/";
+mkdir($dir_path);
+
+// heredoc string
+$heredoc = <<<EOT
+hd_file
+EOT;
+
+$inputs = array(
+
+       // int data
+/*1*/  0,
+       1,
+       12345,
+       -2345,
+
+       // float data
+/*5*/  10.5,
+       -10.5,
+       12.3456789000e10,
+       12.3456789000E-10,
+       .5,
+       
+       // empty data
+/*10*/ "",
+       array(),
+
+       // string data
+/*12*/ "double_file",
+       'single_file',
+       $heredoc,
+);
+
+$iterator = 1;
+foreach($inputs as $key => $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--
+<?php
+$dir_path = dirname(__FILE__) . "/readdir_variation4/";
+rmdir($dir_path);
+?>
+--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===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/readdir_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/readdir_variation3.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/readdir_variation3.phpt:1.2
--- /dev/null   Tue Mar  4 17:11:10 2008
+++ php-src/ext/standard/tests/dir/readdir_variation3.phpt      Tue Mar  4 
17:11:10 2008
@@ -0,0 +1,82 @@
+--TEST--
+Test readdir() function : usage variations - sub-directories 
+--FILE--
+<?php
+/* Prototype  : string readdir([resource $dir_handle])
+ * Description: Read directory entry from dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Pass a directory handle pointing to a directory that has a sub-directory
+ * to test behaviour of readdir()
+ */
+
+echo "*** Testing readdir() : usage variations ***\n";
+
+// include the file.inc for Function: function create_files()
+include(dirname(__FILE__)."/../file/file.inc");
+
+$path_top = dirname(__FILE__) . '/readdir_variation3';
+$path_sub = $path_top . '/sub_folder';
+mkdir($path_top);
+mkdir($path_sub);
+
[EMAIL PROTECTED]($path_top, 2);
[EMAIL PROTECTED]($path_sub, 2);
+
+$dir_handle = opendir($path_top);
+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;
+}
+
+// more important to check that all contents are present than order they are 
returned in
+sort($contents);
+var_dump($contents);
+
+delete_files($path_top, 2);
+delete_files($path_sub, 2);
+
+closedir($dir_handle);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path_top = dirname(__FILE__) . '/readdir_variation3';
+$path_sub = $path_top . '/sub_folder';
+rmdir($path_sub);
+rmdir($path_top);
+?>
+--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===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to