jmessa          Mon Mar 10 14:16:32 2008 UTC

  Modified files:              
    /php-src/ext/standard/tests/dir     scandir_error1.phpt 
                                        scandir_variation7.phpt 
                                        scandir_variation8.phpt 
                                        scandir_variation5.phpt 
                                        scandir_variation3.phpt 
                                        scandir_variation4.phpt 
                                        scandir_error2.phpt 
                                        scandir_variation1.phpt 
                                        scandir_variation9.phpt 
                                        scandir_variation6.phpt 
                                        scandir_variation2.phpt 
                                        scandir_basic.phpt 
  Log:
  - New tests for scandir() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_error1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_error1.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_error1.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_error1.phpt  Mon Mar 10 14:16:32 2008
@@ -0,0 +1,60 @@
+--TEST--
+Test scandir() function : error conditions - Incorrect number of args
+--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 incorrect number of arguments to scandir() to test behaviour
+ */
+
+echo "*** Testing scandir() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing scandir() function with Zero arguments --\n";
+var_dump( scandir() );
+
+//Test scandir with one more than the expected number of arguments
+echo "\n-- Testing scandir() function with more than expected no. of arguments 
--\n";
+$dir = dirname(__FILE__) . '/scandir_error';
+mkdir($dir);
+$sorting_order = 10;
+$context = stream_context_create();
+$extra_arg = 10;
+var_dump( scandir($dir, $sorting_order, $context, $extra_arg) );
+?>
+===DONE===
+--CLEAN--
+<?php
+$directory = dirname(__FILE__) . '/scandir_error';
+rmdir($directory);
+?>
+--EXPECTF--
+*** Testing scandir() : error conditions ***
+
+-- Testing scandir() function with Zero arguments --
+
+Warning: scandir() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing scandir() function with more than expected no. of arguments --
+
+Warning: scandir() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : error conditions ***
+
+-- Testing scandir() function with Zero arguments --
+
+Warning: scandir() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing scandir() function with more than expected no. of arguments --
+
+Warning: scandir() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation7.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation7.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation7.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation7.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,262 @@
+--TEST--
+Test scandir() 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__) . "/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  : array scandir(string $dir [, int $sorting_order [, resource 
$context]])
+ * Description: List files & directories inside the specified path 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * Create directories with different permissions to test whether scandir() can 
access them
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+// create the temporary directory
+$dir_path = dirname(__FILE__) . "/scandir_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
+);
+
+$iterator = 1;
+foreach ($permission_values as $perm) {
+       echo "\n-- Iteration $iterator --\n";
+       
+       // Remove the directory if already exists
+       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(scandir($dir_path));
+       $iterator++;
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir_path = dirname(__FILE__) . "/scandir_variation7";
+rmdir($dir_path);
+?>
+--EXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 2 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 3 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 4 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 5 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 6 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 7 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 8 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 9 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 10 --
+bool(true)
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 2 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 3 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 4 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 5 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 6 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 7 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 8 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 9 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 10 --
+bool(true)
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation8.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation8.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation8.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation8.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,239 @@
+--TEST--
+Test scandir() function : usage variations - different file names
+--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 containing files with different types of names to test how 
scandir()
+ * reads them
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+$dir_path = dirname(__FILE__) . "/scandir_variation8/";
+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') );
+       fclose($$handle);
+       $iterator++;
+};
+
+echo "\n-- Call to scandir() --\n";
+var_dump($content = scandir($dir_path));
+
+// remove all files in directory so can remove directory in CLEAN section
+foreach ($content as $file_name) {
+       // suppress errors as won't be able to remove "." and ".." entries
+       @unlink($dir_path . $file_name);
+}
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir_path = dirname(__FILE__) . "/scandir_variation8";
+rmdir($dir_path);
+?>
+--EXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+resource(%d) of type (stream)
+
+-- Iteration 2 --
+resource(%d) of type (stream)
+
+-- Iteration 3 --
+resource(%d) of type (stream)
+
+-- Iteration 4 --
+resource(%d) of type (stream)
+
+-- Iteration 5 --
+resource(%d) of type (stream)
+
+-- Iteration 6 --
+resource(%d) of type (stream)
+
+-- Iteration 7 --
+resource(%d) of type (stream)
+
+-- Iteration 8 --
+resource(%d) of type (stream)
+
+-- Iteration 9 --
+resource(%d) of type (stream)
+
+-- Iteration 10 --
+resource(%d) of type (stream)
+
+-- Iteration 11 --
+
+Notice: Array to string conversion in %s on line %d
+resource(%d) of type (stream)
+
+-- Iteration 12 --
+resource(%d) of type (stream)
+
+-- Iteration 13 --
+resource(%d) of type (stream)
+
+-- Iteration 14 --
+resource(%d) of type (stream)
+
+-- Call to scandir() --
+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 scandir() : usage variations ***
+
+-- Iteration 1 --
+resource(%d) of type (stream)
+
+-- Iteration 2 --
+resource(%d) of type (stream)
+
+-- Iteration 3 --
+resource(%d) of type (stream)
+
+-- Iteration 4 --
+resource(%d) of type (stream)
+
+-- Iteration 5 --
+resource(%d) of type (stream)
+
+-- Iteration 6 --
+resource(%d) of type (stream)
+
+-- Iteration 7 --
+resource(%d) of type (stream)
+
+-- Iteration 8 --
+resource(%d) of type (stream)
+
+-- Iteration 9 --
+resource(%d) of type (stream)
+
+-- Iteration 10 --
+resource(%d) of type (stream)
+
+-- Iteration 11 --
+
+Notice: Array to string conversion in %s on line %d
+resource(%d) of type (stream)
+
+-- Iteration 12 --
+resource(%d) of type (stream)
+
+-- Iteration 13 --
+resource(%d) of type (stream)
+
+-- Iteration 14 --
+resource(%d) of type (stream)
+
+-- Call to scandir() --
+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/scandir_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation5.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation5.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation5.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,115 @@
+--TEST--
+Test scandir() 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__)."/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  : array scandir(string $dir [, int $sorting_order [, resource 
$context]])
+ * Description: List files & directories inside the specified path 
+ * Source code: ext/standard/dir.c
+ */
+
+/*
+ * remove the execute permission from the parent dir and test scandir() on 
child dir
+ * 1. remove write & execute permission from the 1st parent and test scandir()
+ * 2. remove execute permission from 2nd parent and test scandir()
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+/* 
+ * create the temporary directory :
+ * scandir_variation5  ( parent )
+ *  |-> sub_dir     ( sub parent )
+ *      |-> child_dir  ( child dir)
+ */
+
+$parent_dir_path = dirname(__FILE__) . "/scandir_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";
+var_dump(scandir($child_dir_path));
+
+// 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";
+var_dump(scandir($child_dir_path));
+?>
+===DONE===
+--CLEAN--
+<?php
+$parent_dir_path = dirname(__FILE__) . "/scandir_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 scandir() : usage variations ***
+
+-- After restricting 1st level parent directory --
+
+Warning: scandir(%s/scandir_variation5/sub_dir/child_dir): failed to open dir: 
%s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- After restricting parent directory --
+
+Warning: scandir(%s/scandir_variation5/sub_dir/child_dir): failed to open dir: 
%s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- After restricting 1st level parent directory --
+
+Warning: scandir(%s/scandir_variation5/sub_dir/child_dir): failed to open dir: 
%s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- After restricting parent directory --
+
+Warning: scandir(%s/scandir_variation5/sub_dir/child_dir): failed to open dir: 
%s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation3.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation3.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation3.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,371 @@
+--TEST--
+Test scandir() function : usage variations - diff data types as $context arg
+--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 $context argument to test how scandir() behaves
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+// Initialise function arguments not being substituted
+$dir = dirname(__FILE__) . '/scandir_variation3';
+mkdir($dir);
+$sorting_order = 0;
+
+//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 scandir()
+$iterator = 1;
+foreach($inputs as $input) {
+  echo "\n-- Iteration $iterator --\n";
+  var_dump( scandir($dir, $sorting_order, $input) );
+  $iterator++;
+};
+
+fclose($fp);
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir = dirname(__FILE__) . '/scandir_variation3';
+rmdir($dir);
+?>
+--EXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 2 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 3 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 4 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 5 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 6 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 13 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 14 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 15 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 16 --
+
+Warning: scandir() expects parameter 3 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: scandir() expects parameter 3 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: scandir() expects parameter 3 to be resource, array given in %s on 
line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: scandir() expects parameter 3 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: scandir() expects parameter 3 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: scandir() expects parameter 3 to be resource, string given in %s on 
line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: scandir() expects parameter 3 to be resource, object given in %s on 
line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 25 --
+
+Warning: scandir(): supplied resource is not a valid Stream-Context resource 
in %s on line %d
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 2 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 3 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 4 --
+
+Warning: scandir() expects parameter 3 to be resource, integer given in %s on 
line %d
+NULL
+
+-- Iteration 5 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 6 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: scandir() expects parameter 3 to be resource, double given in %s on 
line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 13 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 14 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 15 --
+
+Warning: scandir() expects parameter 3 to be resource, boolean given in %s on 
line %d
+NULL
+
+-- Iteration 16 --
+
+Warning: scandir() expects parameter 3 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: scandir() expects parameter 3 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: scandir() expects parameter 3 to be resource, array given in %s on 
line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: scandir() expects parameter 3 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: scandir() expects parameter 3 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: scandir() expects parameter 3 to be resource, Unicode string given in 
%s on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: scandir() expects parameter 3 to be resource, object given in %s on 
line %d
+NULL
+
+-- Iteration 23 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 24 --
+
+Warning: scandir() expects parameter 3 to be resource, null given in %s on 
line %d
+NULL
+
+-- Iteration 25 --
+
+Warning: scandir(): supplied resource is not a valid Stream-Context resource 
in %s on line %d
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation4.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation4.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation4.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,271 @@
+--TEST--
+Test scandir() function : usage variations - different relative paths
+--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
+ */
+
+/*
+ * Test scandir() with relative paths as $dir argument
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+// include for create_files/delete_files functions
+include (dirname(__FILE__) . '/../file/file.inc');
+
+$base_dir_path = dirname(__FILE__);
+
+$level_one_dir_path = "$base_dir_path/level_one";
+$level_two_dir_path = "$level_one_dir_path/level_two";
+
+// create directories and files
+mkdir($level_one_dir_path);
[EMAIL PROTECTED]($level_one_dir_path, 2, 'numeric', 0755, 1, 'w', 'level_one', 
1);
+mkdir($level_two_dir_path);
[EMAIL PROTECTED]($level_two_dir_path, 2, 'numeric', 0755, 1, 'w', 'level_two', 
1);
+
+echo "\n-- \$path = './level_one': --\n";
+var_dump(chdir($base_dir_path));
+var_dump(scandir('./level_one'));
+
+echo "\n-- \$path = 'level_one/level_two': --\n";
+var_dump(chdir($base_dir_path));
+var_dump(scandir('level_one/level_two'));
+
+echo "\n-- \$path = '..': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump(scandir('..'));
+
+echo "\n-- \$path = 'level_two', '.': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump(scandir('.'));
+
+echo "\n-- \$path = '../': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump(scandir('../'));
+
+echo "\n-- \$path = './': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump(scandir('./'));
+
+echo "\n-- \$path = '../../'level_one': --\n";
+var_dump(chdir($level_two_dir_path));
+var_dump(scandir('../../level_one'));
+
[EMAIL PROTECTED]($level_one_dir_path, 2, 'level_one');
[EMAIL PROTECTED]($level_two_dir_path, 2, 'level_two');
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir_path = dirname(__FILE__);
+rmdir("$dir_path/level_one/level_two");
+rmdir("$dir_path/level_one");
+?>
+--EXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- $path = './level_one': --
+bool(true)
+array(5) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_one1.tmp"
+  [3]=>
+  string(14) "level_one2.tmp"
+  [4]=>
+  string(9) "level_two"
+}
+
+-- $path = 'level_one/level_two': --
+bool(true)
+array(4) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_two1.tmp"
+  [3]=>
+  string(14) "level_two2.tmp"
+}
+
+-- $path = '..': --
+bool(true)
+array(5) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_one1.tmp"
+  [3]=>
+  string(14) "level_one2.tmp"
+  [4]=>
+  string(9) "level_two"
+}
+
+-- $path = 'level_two', '.': --
+bool(true)
+array(4) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_two1.tmp"
+  [3]=>
+  string(14) "level_two2.tmp"
+}
+
+-- $path = '../': --
+bool(true)
+array(5) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_one1.tmp"
+  [3]=>
+  string(14) "level_one2.tmp"
+  [4]=>
+  string(9) "level_two"
+}
+
+-- $path = './': --
+bool(true)
+array(4) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_two1.tmp"
+  [3]=>
+  string(14) "level_two2.tmp"
+}
+
+-- $path = '../../'level_one': --
+bool(true)
+array(5) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(14) "level_one1.tmp"
+  [3]=>
+  string(14) "level_one2.tmp"
+  [4]=>
+  string(9) "level_two"
+}
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- $path = './level_one': --
+bool(true)
+array(5) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_one1.tmp"
+  [3]=>
+  unicode(14) "level_one2.tmp"
+  [4]=>
+  unicode(9) "level_two"
+}
+
+-- $path = 'level_one/level_two': --
+bool(true)
+array(4) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_two1.tmp"
+  [3]=>
+  unicode(14) "level_two2.tmp"
+}
+
+-- $path = '..': --
+bool(true)
+array(5) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_one1.tmp"
+  [3]=>
+  unicode(14) "level_one2.tmp"
+  [4]=>
+  unicode(9) "level_two"
+}
+
+-- $path = 'level_two', '.': --
+bool(true)
+array(4) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_two1.tmp"
+  [3]=>
+  unicode(14) "level_two2.tmp"
+}
+
+-- $path = '../': --
+bool(true)
+array(5) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_one1.tmp"
+  [3]=>
+  unicode(14) "level_one2.tmp"
+  [4]=>
+  unicode(9) "level_two"
+}
+
+-- $path = './': --
+bool(true)
+array(4) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_two1.tmp"
+  [3]=>
+  unicode(14) "level_two2.tmp"
+}
+
+-- $path = '../../'level_one': --
+bool(true)
+array(5) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(14) "level_one1.tmp"
+  [3]=>
+  unicode(14) "level_one2.tmp"
+  [4]=>
+  unicode(9) "level_two"
+}
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_error2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_error2.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_error2.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_error2.phpt  Mon Mar 10 14:16:32 2008
@@ -0,0 +1,58 @@
+--TEST--
+Test scandir() function : error conditions - Non-existent directory
+--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): 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): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : error conditions ***
+
+-- Pass scandir() an absolute path that does not exist --
+
+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): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation1.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation1.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation1.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,423 @@
+--TEST--
+Test scandir() function : usage variations - different data types as $dir arg
+--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): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: scandir(1): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: scandir(12345): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: scandir(-2345): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: scandir(10.5): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: scandir(-10.5): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: scandir(123456789000): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: scandir(1.23456789E-9): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: scandir(0.5): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 11 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+
+Warning: scandir(1): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 14 --
+
+Warning: scandir(1): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 16 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 17 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 18 --
+
+Notice: Array to string conversion in %s on line %d
+
+Warning: scandir(Array): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 19 --
+
+Warning: scandir(string): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 20 --
+
+Warning: scandir(string): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+
+Warning: scandir(hello world): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 22 --
+
+Warning: scandir(Class A object): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 23 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 24 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 25 --
+
+Warning: scandir(Resource id #%d): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+
+Warning: scandir(0): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 2 --
+
+Warning: scandir(1): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 3 --
+
+Warning: scandir(12345): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 4 --
+
+Warning: scandir(-2345): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 5 --
+
+Warning: scandir(10.5): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: scandir(-10.5): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+
+Warning: scandir(123456789000): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 8 --
+
+Warning: scandir(1.23456789E-9): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 9 --
+
+Warning: scandir(0.5): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 10 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 11 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+
+Warning: scandir(1): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 13 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 14 --
+
+Warning: scandir(1): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 15 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 16 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 17 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 18 --
+
+Notice: Array to string conversion in %s on line %d
+
+Warning: scandir(Array): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 19 --
+
+Warning: scandir(string): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 20 --
+
+Warning: scandir(string): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 21 --
+
+Warning: scandir(hello world): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 22 --
+
+Warning: scandir(Class A object): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 23 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 24 --
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Iteration 25 --
+
+Warning: scandir(Resource id #%d): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation9.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation9.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation9.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation9.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,105 @@
+--TEST--
+Test scandir() function : usage variations - different ints as $sorting_order 
arg
+--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 integers as $sorting_order argument to test how scandir()
+ * re-orders the array
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+// include for create_files/delete_files functions
+include(dirname(__FILE__) . '/../file/file.inc');
+
+// create directory and files
+$dir = dirname(__FILE__) . '/scandir_variation9';
+mkdir($dir);
[EMAIL PROTECTED]($dir, 2);
+
+// different ints to pass as $sorting_order argument
+$ints = array (PHP_INT_MAX, -PHP_INT_MAX, 0);
+
+foreach($ints as $sorting_order) {
+       var_dump( scandir($dir, $sorting_order) );
+}
+
+delete_files($dir, 2);
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir = dirname(__FILE__) . '/scandir_variation9';
+rmdir($dir);
+?>
+--EXPECTF--
+*** Testing scandir() : usage variations ***
+array(4) {
+  [0]=>
+  string(9) "file2.tmp"
+  [1]=>
+  string(9) "file1.tmp"
+  [2]=>
+  string(2) ".."
+  [3]=>
+  string(1) "."
+}
+array(4) {
+  [0]=>
+  string(9) "file2.tmp"
+  [1]=>
+  string(9) "file1.tmp"
+  [2]=>
+  string(2) ".."
+  [3]=>
+  string(1) "."
+}
+array(4) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(9) "file1.tmp"
+  [3]=>
+  string(9) "file2.tmp"
+}
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+array(4) {
+  [0]=>
+  unicode(9) "file2.tmp"
+  [1]=>
+  unicode(9) "file1.tmp"
+  [2]=>
+  unicode(2) ".."
+  [3]=>
+  unicode(1) "."
+}
+array(4) {
+  [0]=>
+  unicode(9) "file2.tmp"
+  [1]=>
+  unicode(9) "file1.tmp"
+  [2]=>
+  unicode(2) ".."
+  [3]=>
+  unicode(1) "."
+}
+array(4) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(9) "file1.tmp"
+  [3]=>
+  unicode(9) "file2.tmp"
+}
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation6.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation6.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation6.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,97 @@
+--TEST--
+Test scandir() function : usage variations - Wildcards in directory path
+--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*): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+Warning: scandir(%s/*): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Wildcard = '?' --
+
+Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: %s in %s 
on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: %s in %s 
on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Wildcard = '*' --
+
+Warning: scandir(%s/scandir_var*): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+Warning: scandir(%s/*): failed to open dir: %s in %s on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+-- Wildcard = '?' --
+
+Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: %s in %s 
on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+
+Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: %s in %s 
on line %d
+
+Warning: scandir(): (errno %d): %s in %s on line %d
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_variation2.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_variation2.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_variation2.phpt      Mon Mar 10 
14:16:32 2008
@@ -0,0 +1,462 @@
+--TEST--
+Test scandir() function : usage variations - diff data types as $sorting_order 
arg
+--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 $sorting_order argument to test how scandir() 
behaves
+ */
+
+echo "*** Testing scandir() : usage variations ***\n";
+
+// Initialise function arguments not being substituted
+$dir = dirname(__FILE__) . '/scandir_variation2';
+mkdir($dir);
+
+//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 $sorting_order 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($dir, $input) );
+  $iterator++;
+};
+
+fclose($fp);
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir = dirname(__FILE__) . '/scandir_variation2';
+rmdir($dir);
+?>
+--EXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 2 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 3 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 4 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 5 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 6 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 7 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 8 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 9 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 10 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 11 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 12 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 13 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 14 --
+array(2) {
+  [0]=>
+  string(2) ".."
+  [1]=>
+  string(1) "."
+}
+
+-- Iteration 15 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 16 --
+
+Warning: scandir() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+-- Iteration 17 --
+
+Warning: scandir() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+-- Iteration 18 --
+
+Warning: scandir() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: scandir() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+-- Iteration 20 --
+
+Warning: scandir() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+-- Iteration 21 --
+
+Warning: scandir() expects parameter 2 to be long, string given in %s on line 
%d
+NULL
+
+-- Iteration 22 --
+
+Warning: scandir() expects parameter 2 to be long, object given in %s on line 
%d
+NULL
+
+-- Iteration 23 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 24 --
+array(2) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+}
+
+-- Iteration 25 --
+
+Warning: scandir() expects parameter 2 to be long, resource given in %s on 
line %d
+NULL
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : usage variations ***
+
+-- Iteration 1 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 2 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 3 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 4 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 5 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 6 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 7 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 8 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 9 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 10 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 11 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 12 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 13 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 14 --
+array(2) {
+  [0]=>
+  unicode(2) ".."
+  [1]=>
+  unicode(1) "."
+}
+
+-- Iteration 15 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 16 --
+
+Warning: scandir() expects parameter 2 to be long, Unicode string given in %s 
on line %d
+NULL
+
+-- Iteration 17 --
+
+Warning: scandir() expects parameter 2 to be long, Unicode string given in %s 
on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: scandir() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: scandir() expects parameter 2 to be long, Unicode string given in %s 
on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: scandir() expects parameter 2 to be long, Unicode string given in %s 
on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: scandir() expects parameter 2 to be long, Unicode string given in %s 
on line %d
+NULL
+
+-- Iteration 22 --
+
+Warning: scandir() expects parameter 2 to be long, object given in %s on line 
%d
+NULL
+
+-- Iteration 23 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 24 --
+array(2) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+}
+
+-- Iteration 25 --
+
+Warning: scandir() expects parameter 2 to be long, resource given in %s on 
line %d
+NULL
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/dir/scandir_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/dir/scandir_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/dir/scandir_basic.phpt:1.2
--- /dev/null   Mon Mar 10 14:16:32 2008
+++ php-src/ext/standard/tests/dir/scandir_basic.phpt   Mon Mar 10 14:16:32 2008
@@ -0,0 +1,101 @@
+--TEST--
+Test scandir() function : basic functionality 
+--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
+ */
+
+/*
+ * Test basic functionality of scandir()
+ */
+
+echo "*** Testing scandir() : basic functionality ***\n";
+
+// include file.inc for create_files function
+include (dirname(__FILE__) . '/../file/file.inc');
+
+// set up directory
+$directory = dirname(__FILE__) . '/scandir_basic';
+mkdir($directory);
[EMAIL PROTECTED]($directory, 3);
+
+echo "\n-- scandir() with mandatory arguments --\n";
+var_dump(scandir($directory));
+
+echo "\n-- scandir() with all arguments --\n";
+$sorting_order = 1;
+$context = stream_context_create();
+var_dump(scandir($directory, $sorting_order, $context));
+
+delete_files($directory, 3);
+?>
+===DONE===
+--CLEAN--
+<?php
+$directory = dirname(__FILE__) . '/scandir_basic';
+rmdir($directory);
+?>
+--EXPECTF--
+*** Testing scandir() : basic functionality ***
+
+-- scandir() with mandatory arguments --
+array(5) {
+  [0]=>
+  string(1) "."
+  [1]=>
+  string(2) ".."
+  [2]=>
+  string(9) "file1.tmp"
+  [3]=>
+  string(9) "file2.tmp"
+  [4]=>
+  string(9) "file3.tmp"
+}
+
+-- scandir() with all arguments --
+array(5) {
+  [0]=>
+  string(9) "file3.tmp"
+  [1]=>
+  string(9) "file2.tmp"
+  [2]=>
+  string(9) "file1.tmp"
+  [3]=>
+  string(2) ".."
+  [4]=>
+  string(1) "."
+}
+===DONE===
+--UEXPECTF--
+*** Testing scandir() : basic functionality ***
+
+-- scandir() with mandatory arguments --
+array(5) {
+  [0]=>
+  unicode(1) "."
+  [1]=>
+  unicode(2) ".."
+  [2]=>
+  unicode(9) "file1.tmp"
+  [3]=>
+  unicode(9) "file2.tmp"
+  [4]=>
+  unicode(9) "file3.tmp"
+}
+
+-- scandir() with all arguments --
+array(5) {
+  [0]=>
+  unicode(9) "file3.tmp"
+  [1]=>
+  unicode(9) "file2.tmp"
+  [2]=>
+  unicode(9) "file1.tmp"
+  [3]=>
+  unicode(2) ".."
+  [4]=>
+  unicode(1) "."
+}
+===DONE===

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

Reply via email to