jmessa          Tue Mar  4 10:45:40 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/dir     opendir_variation1.phpt 
                                        opendir_error2.phpt 
                                        opendir_variation7.phpt 
                                        opendir_variation4.phpt 
                                        opendir_error1.phpt 
                                        opendir_variation6.phpt 
                                        opendir_variation3.phpt 
                                        opendir_variation5.phpt 
                                        opendir_basic.phpt 
                                        opendir_variation2.phpt 
  Log:
  - new tests for opendir() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation1.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation1.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation1.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,328 @@
+--TEST--
+Test opendir() function : usage variations - different data types as $path arg
+--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): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: opendir(1): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: opendir(12345): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: opendir(-2345): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: opendir(10.5): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: opendir(-10.5): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: opendir(123456789000): failed to open dir: No such file or directory 
in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: opendir(1.23456789E-9): failed to open dir: No such file or directory 
in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: opendir(0.5): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 10 --
+bool(false)
+
+-- Iteration 11 --
+bool(false)
+
+-- Iteration 12 --
+
+Warning: opendir(1): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 13 --
+bool(false)
+
+-- Iteration 14 --
+
+Warning: opendir(1): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 15 --
+bool(false)
+
+-- Iteration 16 --
+bool(false)
+
+-- Iteration 17 --
+bool(false)
+
+-- Iteration 18 --
+
+Notice: Array to string conversion in %s on line %d
+
+Warning: opendir(Array): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 19 --
+resource(%d) of type (stream)
+
+-- Iteration 20 --
+
+Warning: opendir(string): failed to open dir: No such file or directory 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(Resource id #%d): failed to open dir: No such file or 
directory in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: opendir(0): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: opendir(1): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: opendir(12345): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: opendir(-2345): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: opendir(10.5): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: opendir(-10.5): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: opendir(123456789000): failed to open dir: No such file or directory 
in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: opendir(1.23456789E-9): failed to open dir: No such file or directory 
in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: opendir(0.5): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 10 --
+bool(false)
+
+-- Iteration 11 --
+bool(false)
+
+-- Iteration 12 --
+
+Warning: opendir(1): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 13 --
+bool(false)
+
+-- Iteration 14 --
+
+Warning: opendir(1): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Iteration 15 --
+bool(false)
+
+-- Iteration 16 --
+bool(false)
+
+-- Iteration 17 --
+bool(false)
+
+-- Iteration 18 --
+
+Notice: Array to string conversion in %s on line %d
+
+Warning: opendir(Array): failed to open dir: No such file or directory in %s 
on line %d
+bool(false)
+
+-- Iteration 19 --
+resource(%d) of type (stream)
+
+-- Iteration 20 --
+
+Warning: opendir(string): failed to open dir: No such file or directory 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(Resource id #%d): failed to open dir: No such file or 
directory in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_error2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_error2.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_error2.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_error2.phpt  Tue Mar  4 10:45:40 2008
@@ -0,0 +1,50 @@
+--TEST--
+Test opendir() function : error conditions - Non-existent directory
+--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): failed to open dir: No such file or 
directory in %s on line %d
+bool(false)
+
+-- Pass a non-existent relative path: --
+
+Warning: opendir(idonotexist): failed to open dir: No such file or directory 
in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : error conditions ***
+
+-- Pass a non-existent absolute path: --
+
+Warning: opendir(%s/idonotexist): failed to open dir: No such file or 
directory in %s on line %d
+bool(false)
+
+-- Pass a non-existent relative path: --
+
+Warning: opendir(idonotexist): failed to open dir: No such file or directory 
in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation7.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation7.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation7.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation7.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,170 @@
+--TEST--
+Test opendir() function : usage variations - different directory 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__) . "/opendir_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  : mixed opendir(string $path[, resource $context])
+ * Description: Open a directory and return a dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Open a directory using opendir() with different directory permissions
+ */
+
+echo "*** Testing opendir() : usage variations ***\n";
+
+// create the temporary directory
+$file_path = dirname(__FILE__);
+$dir_path = $file_path . "/opendir_variation7";
+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";
+       // try to remove the dir if exists  & create
+       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));
+       
+       if (is_resource($dh)) {
+               closedir($dh);
+       }
+       $iterator++;
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+// deleting temporary directory
+$dir_path = dirname(__FILE__) . "/opendir_variation7";
+rmdir($dir_path);
+?>
+--EXPECTF--
+*** Testing opendir() : usage variations ***
+
+-- Iteration 1 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 2 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 3 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 4 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 5 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 6 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 7 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 8 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 9 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 10 --
+bool(true)
+resource(%d) of type (stream)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : usage variations ***
+
+-- Iteration 1 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 2 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 3 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 4 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 5 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 6 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 7 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 8 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 9 --
+bool(true)
+resource(%d) of type (stream)
+
+-- Iteration 10 --
+bool(true)
+resource(%d) of type (stream)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation4.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation4.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation4.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,136 @@
+--TEST--
+Test opendir() function : usage variations - different relative paths
+--FILE--
+<?php
+/* Prototype  : mixed opendir(string $path[, resource $context])
+ * Description: Open a directory and return a dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Test opendir() with different relative paths as $path argument
+ */
+
+echo "*** Testing opendir() : usage variation ***\n";
+
+$base_dir_path = dirname(__FILE__);
+
+$level_one_dir_name = "level_one";
+$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
+
+$level_two_dir_name = "level_two";
+$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
+
+// create directories
+mkdir($level_one_dir_path);
+mkdir($level_two_dir_path);
+
+echo "\n-- \$path = './level_one': --\n";
+var_dump(chdir($base_dir_path));
+var_dump($dh = opendir("./$level_one_dir_name"));
+clean_dh($dh);
+
+echo "\n-- \$path = 'level_one/level_two': --\n";
+var_dump(chdir($base_dir_path));
+var_dump($dh = opendir("$level_one_dir_name/$level_two_dir_name"));
+clean_dh($dh);
+
+echo "\n-- \$path = '..': --\n";
+var_dump($dh = opendir('..'));
+clean_dh($dh);
+
+echo "\n-- \$path = 'level_two', '.': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump($dh = opendir('.'));
+clean_dh($dh);
+
+echo "\n-- \$path = '../': --\n";
+var_dump($dh = opendir('../'));
+clean_dh($dh);
+
+echo "\n-- \$path = './': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump($dh = opendir('./'));
+clean_dh($dh);
+
+echo "\n-- \$path = '../../'level_one': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump($dh = opendir("../../$level_one_dir_name"));
+clean_dh($dh);
+
+/*
+ * function to remove directory handle before re-using variable name in test
+ * and to ensure directory is not in use at CLEAN section so can me removed
+ */
+function clean_dh($dh){
+       if (is_resource($dh)) {
+               closedir($dh);
+       }
+       unset($dh);
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/level_one/level_two");
+rmdir("$file_path/level_one");
+?>
+--EXPECTF--
+*** Testing opendir() : usage variation ***
+
+-- $path = './level_one': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = 'level_one/level_two': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = '..': --
+resource(%d) of type (stream)
+
+-- $path = 'level_two', '.': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = '../': --
+resource(%d) of type (stream)
+
+-- $path = './': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = '../../'level_one': --
+bool(true)
+resource(%d) of type (stream)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : usage variation ***
+
+-- $path = './level_one': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = 'level_one/level_two': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = '..': --
+resource(%d) of type (stream)
+
+-- $path = 'level_two', '.': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = '../': --
+resource(%d) of type (stream)
+
+-- $path = './': --
+bool(true)
+resource(%d) of type (stream)
+
+-- $path = '../../'level_one': --
+bool(true)
+resource(%d) of type (stream)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_error1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_error1.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_error1.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_error1.phpt  Tue Mar  4 10:45:40 2008
@@ -0,0 +1,60 @@
+--TEST--
+Test opendir() function : error conditions - Incorrect number of args
+--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 incorrect number of arguments to opendir() to test behaviour
+ */
+
+echo "*** Testing opendir() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing opendir() function with Zero arguments --\n";
+var_dump( opendir() );
+
+//Test opendir with one more than the expected number of arguments
+echo "\n-- Testing opendir() function with more than expected no. of arguments 
--\n";
+$path = dirname(__FILE__) . "/opendir_error";
+mkdir($path);
+$context = stream_context_create();
+
+$extra_arg = 10;
+var_dump( opendir($path, $context, $extra_arg) );
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . "/opendir_error";
+rmdir($path);
+?>
+--EXPECTF--
+*** Testing opendir() : error conditions ***
+
+-- Testing opendir() function with Zero arguments --
+
+Warning: opendir() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing opendir() function with more than expected no. of arguments --
+
+Warning: opendir() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : error conditions ***
+
+-- Testing opendir() function with Zero arguments --
+
+Warning: opendir() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing opendir() function with more than expected no. of arguments --
+
+Warning: opendir() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation6.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation6.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation6.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,80 @@
+--TEST--
+Test opendir() function : usage variations - Different wildcards
+--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*): failed to open dir: No such file or 
directory in %s on line %d
+bool(false)
+
+Warning: opendir(%s/*): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Wildcard = '?' --
+
+Warning: opendir(%s/opendir_variation6/sub_dir?): failed to open dir: No such 
file or directory in %s on line %d
+bool(false)
+
+Warning: opendir(%s/opendir_variation6/sub?dir1): failed to open dir: No such 
file or directory in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : usage variations ***
+
+-- Wildcard = '*' --
+
+Warning: opendir(%s/opendir_var*): failed to open dir: No such file or 
directory in %s on line %d
+bool(false)
+
+Warning: opendir(%s/*): failed to open dir: No such file or directory in %s on 
line %d
+bool(false)
+
+-- Wildcard = '?' --
+
+Warning: opendir(%s/opendir_variation6/sub_dir?): failed to open dir: No such 
file or directory in %s on line %d
+bool(false)
+
+Warning: opendir(%s/opendir_variation6/sub?dir1): failed to open dir: No such 
file or directory in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation3.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation3.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation3.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,61 @@
+--TEST--
+Test opendir() function : usage variations - open a directory twice
+--FILE--
+<?php
+/* Prototype  : mixed opendir(string $path[, resource $context])
+ * Description: Open a directory and return a dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Call opendir() twice with the same directory as $path argument
+ */
+
+echo "*** Testing opendir() : usage variation ***\n";
+
+$path = dirname(__FILE__) . "/opendir_variation3";
+mkdir($path);
+
+echo "\n-- Open directory first time: --\n";
+var_dump($dh1 = opendir($path));
+
+echo "\n-- Open directory second time: --\n";
+var_dump($dh2 = opendir($path));
+
+if ($dh1 !== $dh2) {
+       echo "\nNew resource created\n";
+} else {
+       echo "\nNo new resource created\n";
+}
+
+closedir($dh1);
+closedir($dh2);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . "/opendir_variation3";
+rmdir($path);
+?>
+--EXPECTF--
+*** Testing opendir() : usage variation ***
+
+-- Open directory first time: --
+resource(%d) of type (stream)
+
+-- Open directory second time: --
+resource(%d) of type (stream)
+
+New resource created
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : usage variation ***
+
+-- Open directory first time: --
+resource(%d) of type (stream)
+
+-- Open directory second time: --
+resource(%d) of type (stream)
+
+New resource created
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation5.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation5.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation5.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,116 @@
+--TEST--
+Test opendir() function : usage variations - directories with restricted 
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__)."/dir_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  : mixed opendir(string $path[, resource $context])
+ * Description: Open a directory and return a dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * remove the execute permission from the parent dir and test opendir() on 
child dir
+ *   1) remove write & execute permission from the 1st parent and test 
opendir()
+ *   2) remove execute permission from 2nd parent and test opendir()
+ */
+
+echo "*** Testing opendir() : usage variations ***\n";
+
+/* create the temporary directory :
+ * opendir_variation5  ( parent )
+ *  |-> sub_dir    ( sub parent )
+ *      |-> child_dir  ( child dir)
+ */
+
+$parent_dir_path = dirname(__FILE__) . "/opendir_variation5";
+mkdir($parent_dir_path);
+chmod($parent_dir_path, 0777);
+
+// create sub_dir
+$sub_dir_path = $parent_dir_path . "/sub_dir";
+mkdir($sub_dir_path);
+chmod($sub_dir_path, 0777);
+
+//create sub_sub_dir
+$child_dir_path = $sub_dir_path."/child_dir";
+mkdir($child_dir_path);
+
+// remove the write and execute permisson from sub parent
+chmod($sub_dir_path, 0444);
+
+echo "\n-- After restricting 1st level parent directory --\n";
+$dir_handle1 = opendir($child_dir_path);
+var_dump( $dir_handle1 );
+
+// remove the execute permisson from parent dir, allowing all permission for 
sub dir
+chmod($sub_dir_path, 0777); // all permisson to sub dir
+chmod($parent_dir_path, 0666); // restricting parent directory
+
+echo "\n-- After restricting parent directory --\n";
+$dir_handle2 = opendir($child_dir_path); // try to open, expected failure
+var_dump( $dir_handle2 ); // dump it
+
+if (is_resource($dir_handle1)) {
+       closedir($dir_handle1);
+}
+if (is_resource($dir_handle2)) {
+       closedir($dir_handle2);
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+$parent_dir_path = dirname(__FILE__) . "/opendir_variation5";
+$sub_dir_path = $parent_dir_path."/sub_dir";
+$child_dir_path = $sub_dir_path."/child_dir";
+
+// changing permissions for each temporary directory to delete them
+chmod($parent_dir_path, 0777);
+chmod($sub_dir_path, 0777);
+chmod($child_dir_path, 0777);
+
+rmdir($child_dir_path);
+rmdir($sub_dir_path);
+rmdir($parent_dir_path);
+?>
+
+--EXPECTF--
+"*** Testing opendir() : usage variations ***
+
+-- After restricting 1st level parent directory --
+
+Warning: opendir(%s/opendir_variation5/sub_dir/child_dir): failed to open dir: 
Permission denied in %s on line %d
+bool(false)
+
+-- After restricting parent directory --
+
+Warning: opendir(%s/opendir_variation5/sub_dir/child_dir): failed to open dir: 
Permission denied in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+"*** Testing opendir() : usage variations ***
+
+-- After restricting 1st level parent directory --
+
+Warning: opendir(%s/opendir_variation5/sub_dir/child_dir): failed to open dir: 
Permission denied in %s on line %d
+bool(false)
+
+-- After restricting parent directory --
+
+Warning: opendir(%s/opendir_variation5/sub_dir/child_dir): failed to open dir: 
Permission denied in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_basic.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_basic.phpt   Tue Mar  4 10:45:40 2008
@@ -0,0 +1,76 @@
+--TEST--
+Test opendir() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : mixed opendir(string $path[, resource $context])
+ * Description: Open a directory and return a dir_handle 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Test basic functionality of opendir() with absolute and relative paths as 
$path argument
+ */
+
+echo "*** Testing opendir() : basic functionality ***\n";
+
+$base_dir_path = dirname(__FILE__);
+
+$level_one_dir_name = "level_one";
+$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
+
+$level_two_dir_name = "level_two";
+$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
+
+// create temporary directories - will remove in CLEAN section
+mkdir($level_one_dir_path);
+mkdir($level_two_dir_path);
+
+echo "\n-- Testing opendir() with absolute path: --\n";
+var_dump($dh1 = opendir($level_one_dir_path));
+
+
+echo "\n-- Testing opendir() with relative paths: --\n";
+var_dump(chdir($level_one_dir_path));
+var_dump($dh2 = opendir($level_two_dir_name));
+
+echo "\n-- Close directory handles: --\n";
+closedir($dh1);
+var_dump($dh1);
+closedir($dh2);
+var_dump($dh2);
+?>
+===DONE===
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/level_one/level_two");
+rmdir("$file_path/level_one");
+?>
+--EXPECTF--
+*** Testing opendir() : basic functionality ***
+
+-- Testing opendir() with absolute path: --
+resource(%d) of type (stream)
+
+-- Testing opendir() with relative paths: --
+bool(true)
+resource(%d) of type (stream)
+
+-- Close directory handles: --
+resource(%d) of type (Unknown)
+resource(%d) of type (Unknown)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : basic functionality ***
+
+-- Testing opendir() with absolute path: --
+resource(%d) of type (stream)
+
+-- Testing opendir() with relative paths: --
+bool(true)
+resource(%d) of type (stream)
+
+-- Close directory handles: --
+resource(%d) of type (Unknown)
+resource(%d) of type (Unknown)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/opendir_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/opendir_variation2.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/opendir_variation2.phpt:1.2
--- /dev/null   Tue Mar  4 10:45:40 2008
+++ php-src/ext/standard/tests/dir/opendir_variation2.phpt      Tue Mar  4 
10:45:40 2008
@@ -0,0 +1,367 @@
+--TEST--
+Test opendir() function : usage variations - different data types as $context 
arg
+--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 $context argument to opendir() to test 
behaviour
+ */
+
+echo "*** Testing opendir() : usage variation ***\n";
+
+
+// Initialise function arguments not being substituted (if any)
+// create temporary directory for test, removed in CLEAN section
+$path = dirname(__FILE__) . "/opendir_variation2";
+mkdir($path);
+
+
+//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 $context 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 opendir()
+$iterator = 1;
+foreach($inputs as $input) {
+       echo "\n-- Iteration $iterator --\n";
+       var_dump($dh = opendir($path, $input) );#
+       if ($dh) {
+               closedir($dh);
+       }
+       $iterator++;
+};
+
+fclose($fp);
+?>
+===DONE===
+--CLEAN--
+<?php
+$path = dirname(__FILE__) . "/opendir_variation2";
+rmdir($path);
+?>
+--EXPECTF--
+*** Testing opendir() : usage variation ***
+
+-- Iteration 1 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 2 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 3 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 4 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 5 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 6 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 13 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 14 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 15 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 16 --
+
+Warning: opendir() expects parameter 2 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: opendir() expects parameter 2 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: opendir() expects parameter 2 to be resource, array given in %s on 
line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: opendir() expects parameter 2 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: opendir() expects parameter 2 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: opendir() expects parameter 2 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: opendir() expects parameter 2 to be resource, object given in %s on 
line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 25 --
+
+Warning: opendir(): supplied resource is not a valid Stream-Context resource 
in %s on line %d
+resource(%d) of type (stream)
+===DONE===
+--UEXPECTF--
+*** Testing opendir() : usage variation ***
+
+-- Iteration 1 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 2 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 3 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 4 --
+
+Warning: opendir() expects parameter 2 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 5 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 6 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: opendir() expects parameter 2 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 13 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 14 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 15 --
+
+Warning: opendir() expects parameter 2 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 16 --
+
+Warning: opendir() expects parameter 2 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: opendir() expects parameter 2 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: opendir() expects parameter 2 to be resource, array given in %s on 
line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: opendir() expects parameter 2 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: opendir() expects parameter 2 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: opendir() expects parameter 2 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: opendir() expects parameter 2 to be resource, object given in %s on 
line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: opendir() expects parameter 2 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 25 --
+
+Warning: opendir(): supplied resource is not a valid Stream-Context resource 
in %s on line %d
+resource(%d) of type (stream)
+===DONE===

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

Reply via email to