]> granicus.if.org Git - php/commitdiff
File system tests: checked on PHP 5.3 (Windows, Linux and Linux 64 bit).
authorAnt Phillips <ant@php.net>
Wed, 26 Nov 2008 10:10:19 +0000 (10:10 +0000)
committerAnt Phillips <ant@php.net>
Wed, 26 Nov 2008 10:10:19 +0000 (10:10 +0000)
208 files changed:
ext/standard/tests/file/001-win32.phpt
ext/standard/tests/file/005_variation2-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/005_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/006_error.phpt
ext/standard/tests/file/006_variation2.phpt
ext/standard/tests/file/007_error.phpt
ext/standard/tests/file/basename-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/basename.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_error.phpt [new file with mode: 0644]
ext/standard/tests/file/bug41655_1.phpt
ext/standard/tests/file/chmod_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/copy_variation13.phpt
ext/standard/tests/file/copy_variation18.phpt
ext/standard/tests/file/dirname_basic-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/dirname_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/dirname_error.phpt [new file with mode: 0644]
ext/standard/tests/file/dirname_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/disk.phpt
ext/standard/tests/file/disk_free_space_basic.phpt
ext/standard/tests/file/disk_free_space_error.phpt
ext/standard/tests/file/disk_free_space_variation.phpt
ext/standard/tests/file/disk_total_space_basic.phpt
ext/standard/tests/file/disk_total_space_error.phpt
ext/standard/tests/file/disk_total_space_variation.phpt
ext/standard/tests/file/feof_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/fflush_error.phpt
ext/standard/tests/file/fgets_error.phpt
ext/standard/tests/file/fgets_socket_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fgets_socket_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/fgets_variation2.phpt
ext/standard/tests/file/file.inc
ext/standard/tests/file/file_exists_error.phpt [new file with mode: 0644]
ext/standard/tests/file/file_exists_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_error.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation7-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation7.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation8-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation8.phpt [new file with mode: 0644]
ext/standard/tests/file/file_get_contents_variation9.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation7-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation7.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation8-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation8.phpt [new file with mode: 0644]
ext/standard/tests/file/file_put_contents_variation9.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation8-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation8.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation9.phpt [new file with mode: 0644]
ext/standard/tests/file/filegroup_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/filegroup_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/filegroup_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/fileinode_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fileinode_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/fileinode_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/fileowner_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fileowner_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/fileowner_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/fileperms_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fileperms_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/fileperms_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/filesize_variation1.phpt
ext/standard/tests/file/filesize_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/filetype_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/flock_error.phpt
ext/standard/tests/file/flock_variation.phpt
ext/standard/tests/file/flock_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_include_path.inc [new file with mode: 0644]
ext/standard/tests/file/fopen_variation10-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation11-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation12.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation13.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation14-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation14.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation15-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation15.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation16.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation17.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation19.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation7.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation8.phpt [new file with mode: 0644]
ext/standard/tests/file/fopen_variation9.phpt [new file with mode: 0644]
ext/standard/tests/file/fpassthru_error.phpt
ext/standard/tests/file/fpassthru_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fread_error.phpt
ext/standard/tests/file/fread_fwrite_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/fseek_dir_basic.phpt
ext/standard/tests/file/fseek_ftell_rewind_error1.phpt
ext/standard/tests/file/fseek_ftell_rewind_error2.phpt
ext/standard/tests/file/fseek_ftell_rewind_error3.phpt
ext/standard/tests/file/fseek_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/fseek_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/fseek_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/ftruncate_error.phpt
ext/standard/tests/file/fwrite_error.phpt
ext/standard/tests/file/fwrite_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/glob_basic.phpt
ext/standard/tests/file/glob_error_002-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/glob_error_002.phpt [new file with mode: 0644]
ext/standard/tests/file/is_dir_variation2.phpt
ext/standard/tests/file/is_dir_variation3.phpt
ext/standard/tests/file/is_executable_variation3.phpt
ext/standard/tests/file/is_file_variation3.phpt
ext/standard/tests/file/is_file_variation4.phpt
ext/standard/tests/file/is_readable_variation1.phpt
ext/standard/tests/file/is_readable_variation3.phpt
ext/standard/tests/file/is_uploaded_file_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/is_writable_variation1.phpt
ext/standard/tests/file/is_writable_variation3.phpt
ext/standard/tests/file/lstat_stat_variation2.phpt
ext/standard/tests/file/lstat_stat_variation22.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation1-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation5-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/mkdir_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/move_uploaded_file_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation6-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/parse_ini_file_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_basic1-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_basic1.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_basic2-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_basic2.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/pathinfo_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/pclose_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/popen_pclose_error-sunos.phpt
ext/standard/tests/file/readfile_variation10-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation10.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation7.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation8-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/readfile_variation9.phpt [new file with mode: 0644]
ext/standard/tests/file/readlink_realpath_basic1.phpt
ext/standard/tests/file/readlink_realpath_basic2.phpt
ext/standard/tests/file/readlink_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/realpath_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/rename_variation10.phpt [new file with mode: 0644]
ext/standard/tests/file/rename_variation11-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/rename_variation12.phpt [new file with mode: 0644]
ext/standard/tests/file/rename_variation13-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/rename_variation13.phpt [new file with mode: 0644]
ext/standard/tests/file/rmdir_variation1-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/rmdir_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/rmdir_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/rmdir_variation3-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/rmdir_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt
ext/standard/tests/file/tempnam_variation1-win32.phpt
ext/standard/tests/file/tempnam_variation1.phpt
ext/standard/tests/file/tempnam_variation2-win32.phpt
ext/standard/tests/file/tempnam_variation2.phpt
ext/standard/tests/file/tempnam_variation3-win32.phpt
ext/standard/tests/file/tempnam_variation3.phpt
ext/standard/tests/file/tempnam_variation4.phpt
ext/standard/tests/file/tempnam_variation5-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/tempnam_variation5.phpt
ext/standard/tests/file/tempnam_variation6-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/tempnam_variation6.phpt
ext/standard/tests/file/tempnam_variation7-win32.phpt
ext/standard/tests/file/tempnam_variation7.phpt
ext/standard/tests/file/tempnam_variation8-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/touch.phpt
ext/standard/tests/file/touch_basic-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_error.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation3-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation4-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation5-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/touch_variation6-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/umask_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/unlink_variation10.phpt [new file with mode: 0644]
ext/standard/tests/file/unlink_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/unlink_variation7.phpt [new file with mode: 0644]
ext/standard/tests/file/unlink_variation8-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/unlink_variation8.phpt [new file with mode: 0644]
ext/standard/tests/file/unlink_variation9-win32.phpt [new file with mode: 0644]

index d6709e8d04d871d482261485aabe955cb289749d..ee520940e44674db683a4f3015b813f592edd19a 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 File type functions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
 --SKIPIF--
 <?php
 if (substr(PHP_OS, 0, 3) != 'WIN') {
@@ -10,7 +12,6 @@ if (substr(PHP_OS, 0, 3) != 'WIN') {
 <?php
 chdir(dirname(__FILE__));
 @unlink('test.file');
-@unlink('test.link');
 if (file_exists('test.file')) {
     echo "test.file exists\n";
 } else {
@@ -23,22 +24,11 @@ if (file_exists('test.file')) {
 } else {
     echo "test.file does not exist\n";
 }
-sleep (2);
-if (file_exists('test.link')) {
-    echo "test.link exists\n";
-} else {
-    echo "test.link does not exist\n";
-}
 if (is_link('test.file')) {
     echo "test.file is a symlink\n";
 } else {
     echo "test.file is not a symlink\n";
 }
-if (is_link('test.link')) {
-    echo "test.link is a symlink\n";
-} else {
-    echo "test.link is not a symlink\n";
-}
 if (file_exists('test.file')) {
     echo "test.file exists\n";
 } else {
@@ -52,7 +42,6 @@ for ($i = 0; $i <= 12; $i++) {
     }
 }
 echo "test.file is " . filetype('test.file') . "\n";
-echo "test.link is <" . filetype('test.link') . ">\n";
 printf ("test.file permissions are 0%o\n", 0777 & fileperms('test.file'));
 echo "test.file size is " . filesize('test.file') . "\n";
 if (is_writeable('test.file')) {
@@ -70,16 +59,6 @@ if (is_file('test.file')) {
 } else {
     echo "test.file is not a regular file\n";
 }
-if (is_file('test.link')) {
-    echo "test.link is a regular file\n";
-} else {
-    echo "test.link is not a regular file\n";
-}
-if (is_dir('test.link')) {
-    echo "test.link is a directory\n";
-} else {
-    echo "test.link is not a directory\n";
-}
 if (is_dir('../file')) {
     echo "../file is a directory\n";
 } else {
@@ -103,25 +82,19 @@ if (file_exists('test.file')) {
     echo "test.file does not exist\n";
 }
 ?>
---EXPECTF--
+--EXPECT--
 test.file does not exist
 test.file exists
-test.link does not exist
 test.file is not a symlink
-test.link is not a symlink
 test.file exists
 test.file is file
-
-Warning: filetype(): Lstat failed for test.link in %s
-test.link is <>
 test.file permissions are 0666
 test.file size is 0
 test.file is writeable
 test.file is readable
 test.file is a regular file
-test.link is not a regular file
-test.link is not a directory
 ../file is a directory
 test.file is not a directory
 test.file does not exist
 test.file does not exist
+
diff --git a/ext/standard/tests/file/005_variation2-win32.phpt b/ext/standard/tests/file/005_variation2-win32.phpt
new file mode 100644 (file)
index 0000000..caed7e6
--- /dev/null
@@ -0,0 +1,125 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+   Prototype: int fileatime ( string $filename );
+   Description: Returns the time the file was last accessed, or FALSE 
+     in case of an error. The time is returned as a Unix timestamp.
+
+   Prototype: int filemtime ( string $filename );
+   Description: Returns the time the file was last modified, or FALSE 
+     in case of an error. 
+
+   Prototype: int filectime ( string $filename );
+   Description: Returns the time the file was last changed, or FALSE
+     in case of an error. The time is returned as a Unix timestamp.
+
+   Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+   Description: Attempts to set the access and modification times of the file
+     named in the filename parameter to the value given in time.
+*/
+
+/*
+   Prototype: void stat_fn(string $filename);
+   Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+  echo "\n-- File '$filename' --\n";
+  echo "-- File access time is => "; 
+  echo fileatime($filename)."\n";
+  clearstatcache();
+  echo "-- File modification time is => "; 
+  echo filemtime($filename)."\n";
+  clearstatcache();
+  echo "-- inode change time is => "; 
+  echo filectime($filename)."\n";
+  clearstatcache();
+  
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+echo "\n*** testing file info ***";
+stat_fn(NULL);
+stat_fn(false);
+stat_fn('');
+stat_fn(' ');
+stat_fn('|');
+echo "\n*** testing touch ***";
+var_dump(touch(NULL));
+var_dump(touch(false));
+var_dump(touch(''));
+
+//php generates permission denied, we generate No such file or dir.
+var_dump(touch(' '));
+var_dump(touch('|'));
+
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+
+*** testing file info ***
+-- File '' --
+-- File access time is => 
+-- File modification time is => 
+-- inode change time is => 
+
+-- File '' --
+-- File access time is => 
+-- File modification time is => 
+-- inode change time is => 
+
+-- File '' --
+-- File access time is => 
+-- File modification time is => 
+-- inode change time is => 
+
+-- File ' ' --
+-- File access time is => 
+Warning: fileatime(): stat failed for   in %s on line %d
+
+-- File modification time is => 
+Warning: filemtime(): stat failed for   in %s on line %d
+
+-- inode change time is => 
+Warning: filectime(): stat failed for   in %s on line %d
+
+
+-- File '|' --
+-- File access time is => 
+Warning: fileatime(): stat failed for | in %s on line %d
+
+-- File modification time is => 
+Warning: filemtime(): stat failed for | in %s on line %d
+
+-- inode change time is => 
+Warning: filectime(): stat failed for | in %s on line %d
+
+
+*** testing touch ***
+Warning: touch(): Unable to create file  because No such file or directory in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file  because No such file or directory in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file  because No such file or directory in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file   because %s in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file | because %s in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/005_variation2.phpt b/ext/standard/tests/file/005_variation2.phpt
new file mode 100644 (file)
index 0000000..4d99424
--- /dev/null
@@ -0,0 +1,113 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. only for Non Windows Systems');
+}
+?>
+--FILE--
+<?php
+/*
+   Prototype: int fileatime ( string $filename );
+   Description: Returns the time the file was last accessed, or FALSE 
+     in case of an error. The time is returned as a Unix timestamp.
+
+   Prototype: int filemtime ( string $filename );
+   Description: Returns the time the file was last modified, or FALSE 
+     in case of an error. 
+
+   Prototype: int filectime ( string $filename );
+   Description: Returns the time the file was last changed, or FALSE
+     in case of an error. The time is returned as a Unix timestamp.
+
+   Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+   Description: Attempts to set the access and modification times of the file
+     named in the filename parameter to the value given in time.
+*/
+
+/*
+   Prototype: void stat_fn(string $filename);
+   Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+  echo "\n-- File '$filename' --\n";
+  echo "-- File access time is => "; 
+  echo fileatime($filename)."\n";
+  clearstatcache();
+  echo "-- File modification time is => "; 
+  echo filemtime($filename)."\n";
+  clearstatcache();
+  echo "-- inode change time is => "; 
+  echo filectime($filename)."\n";
+  clearstatcache();
+  
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+echo "\n*** testing touch ***\n";
+var_dump(touch(NULL));
+var_dump(touch(false));
+var_dump(touch(''));
+var_dump(touch(' '));
+var_dump(touch('|'));
+
+echo "\n*** testing file info ***";
+stat_fn(NULL);
+stat_fn(false);
+stat_fn('');
+stat_fn(' ');
+stat_fn('|');
+
+var_dump(unlink(' '));
+var_dump(unlink('|'));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+
+*** testing touch ***
+
+Warning: touch(): Unable to create file  because No such file or directory in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file  because No such file or directory in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file  because No such file or directory in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+
+*** testing file info ***
+-- File '' --
+-- File access time is => 
+-- File modification time is => 
+-- inode change time is => 
+
+-- File '' --
+-- File access time is => 
+-- File modification time is => 
+-- inode change time is => 
+
+-- File '' --
+-- File access time is => 
+-- File modification time is => 
+-- inode change time is => 
+
+-- File ' ' --
+-- File access time is => %d
+-- File modification time is => %d
+-- inode change time is => %d
+
+-- File '|' --
+-- File access time is => %d
+-- File modification time is => %d
+-- inode change time is => %d
+bool(true)
+bool(true)
+Done
index 04cc274ecc397080ca70856de81d331b95926314..bef7a89f44a47b63367f556ea314f3cfd8604e1a 100644 (file)
@@ -11,7 +11,7 @@ $fp = fopen($filename, 'w');
 fclose($fp);
 if(fileowner($filename) == 0) {
         unlink ($filename);
-        die('skip cannot be run as root');
+        die('skip...cannot be run as root\n');
 }
 
 unlink($filename);
@@ -68,13 +68,13 @@ unlink( dirname(__FILE__)."/006_error.tmp");
 --EXPECTF--
 *** Testing error conditions for fileperms(), chmod() ***
 
-Warning: chmod(): %s in %s on line %d
+Warning: chmod(): Operation not permitted in %s on line %d
 bool(false)
-100%d44
+%d
 
-Warning: chmod(): %s in %s on line %d
+Warning: chmod(): Operation not permitted in %s on line %d
 bool(false)
-40755
+%d
 
 Warning: chmod(): No such file or directory in %s on line %d
 bool(false)
@@ -105,3 +105,4 @@ Warning: fileperms() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 
 *** Done ***
+
index d56207a3497665889ccfec2f7f3dbb3e8800da93..9c9707664e5352e0c5fa8f8a363a2004db07f577 100644 (file)
@@ -11,7 +11,7 @@ $fp = fopen($filename, 'w');
 fclose($fp);
 if(fileowner($filename) == 0) {
         unlink ($filename);
-        die('skip cannot be run as root');
+        die('skip...cannot be run as root\n');
 }
 
 unlink($filename);
@@ -94,93 +94,94 @@ rmdir(dirname(__FILE__)."/006_variation2");
 *** Testing fileperms(), chmod() with miscellaneous permissions ***
 -- Iteration 1 --
 bool(true)
-107777
+%d
 bool(true)
-47777
+%d
 -- Iteration 2 --
 bool(true)
-100000
+%d
 bool(true)
-40000
+%d
 -- Iteration 3 --
 bool(true)
-101000
+%d
 bool(true)
-41000
+%d
 -- Iteration 4 --
 bool(true)
-101111
+%d
 bool(true)
-41111
+%d
 -- Iteration 5 --
 bool(true)
-107001
+%d
 bool(true)
-47001
+%d
 -- Iteration 6 --
 bool(true)
-100001
+%d
 bool(true)
-40001
+%d
 -- Iteration 7 --
 bool(true)
-101411
+%d
 bool(true)
-41411
+%d
 -- Iteration 8 --
 bool(true)
-107141
+%d
 bool(true)
-47141
+%d
 -- Iteration 9 --
 bool(true)
-100637
+%d
 bool(true)
-40637
+%d
 -- Iteration 10 --
 bool(true)
-103567
+%d
 bool(true)
-43567
+%d
 -- Iteration 11 --
 bool(true)
-103567
+%d
 bool(true)
-43567
+%d
 -- Iteration 12 --
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-103567
+%d
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-43567
+%d
 -- Iteration 13 --
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-103567
+%d
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-43567
+%d
 -- Iteration 14 --
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-103567
+%d
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-43567
+%d
 -- Iteration 15 --
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-103567
+%d
 
 Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
 NULL
-43567
+%d
 *** Done ***
+
index cc986ebdae58659093bbbc9fb79c250f37d20018..ecec336f84657d80e127a802b14d539d28d85001 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 Test fopen, fclose() & feof() functions: error conditions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
 --FILE--
 <?php
 /*
@@ -44,7 +46,6 @@ var_dump( feof($fp, "handle"));
 fclose($fp);
 
 /* test invalid arguments : non-resources */
-chdir(dirname(__FILE__));
 echo "-- Testing fopen(), fclose() & feof() with invalid arguments --\n";
 $invalid_args = array (
   "string",
@@ -78,7 +79,7 @@ bool(false)
 Warning: fclose(): 5 is not a valid stream resource in %s on line %d
 bool(false)
 
-Warning: fclose() expects parameter 1 to be resource, string given %s on line %d
+Warning: fclose() expects parameter 1 to be resource, string given in %s on line %d
 bool(false)
 
 Warning: fclose() expects exactly 1 parameter, 0 given in %s on line %d
@@ -87,7 +88,7 @@ bool(false)
 Warning: feof(): 5 is not a valid stream resource in %s on line %d
 bool(false)
 
-Warning: feof() expects parameter 1 to be resource, string given %s on line %d
+Warning: feof() expects parameter 1 to be resource, string given in %s on line %d
 bool(false)
 
 Warning: feof() expects exactly 1 parameter, 0 given in %s on line %d
@@ -178,3 +179,4 @@ bool(false)
 
 Warning: feof() expects parameter 1 to be resource, string given in %s on line %d
 bool(false)
+
diff --git a/ext/standard/tests/file/basename-win32.phpt b/ext/standard/tests/file/basename-win32.phpt
new file mode 100644 (file)
index 0000000..5fd0f96
--- /dev/null
@@ -0,0 +1,341 @@
+--TEST--
+basename
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+/* 
+ * proto string basename(string path [, string suffix])
+ * Function is implemented in ext/standard/string.c
+ */ 
+$file_paths = array (
+  /* simple paths */
+  array("bar"),
+  array("\\foo\\bar"),
+  array("foo\\bar"),
+  array("\\bar"),
+
+  /* simple paths with trailing slashes */
+  array("bar\\"),
+  array("\\bar\\"),
+  array("\\foo\\bar\\"),
+  array("foo\\bar\\"),
+  array("\\bar\\"),
+
+  /* paths with suffix removal */
+  array("bar.zip", ".zip"),
+  array("bar.zip", "bar.zip"),
+  array("\\foo\\bar.zip", ".zip"),
+  array("foo\\bar.zip", ".zip"),
+  array("\\bar.zip", ".zip"),  
+
+  /* paths with suffix and trailing slashes with suffix removal*/
+  array("bar.zip\\", ".zip"),
+  array("\\bar.zip\\", ".zip"),
+  array("\\foo\\bar.zip\\", ".zip"),
+  array("foo\\bar.zip\\", ".zip"),
+  array("\\bar.zip\\", ".zip"),  
+  
+  /* paths with basename only suffix, with suffix removal*/
+  array("\\.zip", ".zip"),
+  array(".zip", ".zip"),
+  array("\\foo\\.zip", ".zip"),
+
+  /* paths with basename only suffix & trailing slashes, with suffix removal*/
+  array(".zip\\", ".zip"),
+  array("\\foo\\.zip\\", ".zip"),
+  array("foo\\.zip\\", ".zip"),
+);
+
+$file_path_variations = array (
+  /* paths with shortcut home dir char, with suffix variation */
+  array("C:\\temp\\bar"),
+  array("C:\\temp\\bar", ""),
+  array("C:\\temp\\bar", NULL),
+  array("C:\\temp\\bar", ' '),
+  array("C:\\temp\\bar.tar", ".tar"),
+  array("C:\\temp\\bar.tar", "~"),
+  array("C:\\temp\\bar.tar\\", "~"),
+  array("C:\\temp\\bar.tar\\", ""),
+  array("C:\\temp\\bar.tar", NULL),
+  array("C:\\temp\\bar.tar", ''),
+  array("C:\\temp\\bar.tar", " "),
+
+  /* paths with numeric strings */
+  array("10.5"),
+  array("10.5", ".5"),
+  array("10.5", "10.5"),
+  array("10"),
+  array("105", "5"),
+  array("/10.5"),
+  array("10.5\\"),
+  array("10/10.zip"),
+  array("0"),
+  array('0'),
+
+  /* paths and suffix given as same */
+  array("bar.zip", "bar.zip"),
+  array("\\bar.zip", "\\bar.zip"),
+  array("\\bar.zip\\", "\\bar.zip\\"),
+  array(" ", " "),
+  array(' ', ' '),
+  array(NULL, NULL),
+
+  /* path with spaces */
+  array(" "),
+  array(' '),
+  
+  /* empty paths */
+  array(""),
+  array(''),
+  array(NULL)
+);
+
+function check_basename( $path_arrays ) {
+   $loop_counter = 1;
+   foreach ($path_arrays as $path) {
+     echo "\n--Iteration $loop_counter--\n"; $loop_counter++;
+     if( 1 == count($path) ) { // no suffix provided
+       var_dump( basename($path[0]) );
+     } else { // path as well as suffix provided,
+       var_dump( basename($path[0], $path[1]) );    
+     } 
+   }
+}
+
+echo "*** Testing basic operations ***\n";
+check_basename( $file_paths );
+
+echo "\n*** Testing possible variations in path and suffix ***\n";
+check_basename( $file_path_variations );
+
+echo "\n*** Testing error conditions ***\n";
+// zero arguments 
+var_dump( basename() );
+
+// more than expected no. of arguments
+var_dump( basename("\\blah\\tmp\\bar.zip", ".zip", ".zip") );
+
+// passing invalid type arguments 
+$object = new stdclass;
+var_dump( basename( array("string\\bar") ) );
+var_dump( basename( array("string\\bar"), "bar" ) );
+var_dump( basename( "bar", array("string\\bar") ) );
+var_dump( basename( $object, "bar" ) );
+var_dump( basename( $object ) );
+var_dump( basename( $object, $object ) );
+var_dump( basename( "bar", $object ) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic operations ***
+
+--Iteration 1--
+string(3) "bar"
+
+--Iteration 2--
+string(3) "bar"
+
+--Iteration 3--
+string(3) "bar"
+
+--Iteration 4--
+string(3) "bar"
+
+--Iteration 5--
+string(3) "bar"
+
+--Iteration 6--
+string(3) "bar"
+
+--Iteration 7--
+string(3) "bar"
+
+--Iteration 8--
+string(3) "bar"
+
+--Iteration 9--
+string(3) "bar"
+
+--Iteration 10--
+string(3) "bar"
+
+--Iteration 11--
+string(7) "bar.zip"
+
+--Iteration 12--
+string(3) "bar"
+
+--Iteration 13--
+string(3) "bar"
+
+--Iteration 14--
+string(3) "bar"
+
+--Iteration 15--
+string(3) "bar"
+
+--Iteration 16--
+string(3) "bar"
+
+--Iteration 17--
+string(3) "bar"
+
+--Iteration 18--
+string(3) "bar"
+
+--Iteration 19--
+string(3) "bar"
+
+--Iteration 20--
+string(4) ".zip"
+
+--Iteration 21--
+string(4) ".zip"
+
+--Iteration 22--
+string(4) ".zip"
+
+--Iteration 23--
+string(4) ".zip"
+
+--Iteration 24--
+string(4) ".zip"
+
+--Iteration 25--
+string(4) ".zip"
+
+*** Testing possible variations in path and suffix ***
+
+--Iteration 1--
+string(3) "bar"
+
+--Iteration 2--
+string(3) "bar"
+
+--Iteration 3--
+string(3) "bar"
+
+--Iteration 4--
+string(3) "bar"
+
+--Iteration 5--
+string(3) "bar"
+
+--Iteration 6--
+string(7) "bar.tar"
+
+--Iteration 7--
+string(7) "bar.tar"
+
+--Iteration 8--
+string(7) "bar.tar"
+
+--Iteration 9--
+string(7) "bar.tar"
+
+--Iteration 10--
+string(7) "bar.tar"
+
+--Iteration 11--
+string(7) "bar.tar"
+
+--Iteration 12--
+string(4) "10.5"
+
+--Iteration 13--
+string(2) "10"
+
+--Iteration 14--
+string(4) "10.5"
+
+--Iteration 15--
+string(2) "10"
+
+--Iteration 16--
+string(2) "10"
+
+--Iteration 17--
+string(4) "10.5"
+
+--Iteration 18--
+string(4) "10.5"
+
+--Iteration 19--
+string(6) "10.zip"
+
+--Iteration 20--
+string(1) "0"
+
+--Iteration 21--
+string(1) "0"
+
+--Iteration 22--
+string(7) "bar.zip"
+
+--Iteration 23--
+string(7) "bar.zip"
+
+--Iteration 24--
+string(7) "bar.zip"
+
+--Iteration 25--
+string(1) " "
+
+--Iteration 26--
+string(1) " "
+
+--Iteration 27--
+string(0) ""
+
+--Iteration 28--
+string(1) " "
+
+--Iteration 29--
+string(1) " "
+
+--Iteration 30--
+string(0) ""
+
+--Iteration 31--
+string(0) ""
+
+--Iteration 32--
+string(0) ""
+
+*** Testing error conditions ***
+
+Warning: basename() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: basename() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 2 to be string, array given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 2 to be string, object given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/basename.phpt b/ext/standard/tests/file/basename.phpt
new file mode 100644 (file)
index 0000000..c0e7498
Binary files /dev/null and b/ext/standard/tests/file/basename.phpt differ
diff --git a/ext/standard/tests/file/basename_error.phpt b/ext/standard/tests/file/basename_error.phpt
new file mode 100644 (file)
index 0000000..53c53cf
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Test basename() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : string basename(string path [, string suffix])
+ * Description: Returns the filename component of the path 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing basename() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing basename() function with Zero arguments --\n";
+var_dump( basename() );
+
+//Test basename with one more than the expected number of arguments
+echo "\n-- Testing basename() function with more than expected no. of arguments --\n";
+$path = 'string_val';
+$suffix = 'string_val';
+$extra_arg = 10;
+var_dump( basename($path, $suffix, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basename() : error conditions ***
+
+-- Testing basename() function with Zero arguments --
+
+Warning: basename() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing basename() function with more than expected no. of arguments --
+
+Warning: basename() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+===DONE===
index d02de7066a90549a2cf5c8d9aee3988412709618..62d64dfb1e10a968bc8cf1fbbc68d0610bb8d9ae 100644 (file)
@@ -1,12 +1,15 @@
 --TEST--
 Bug #41655 (open_basedir bypass via glob()) 1/2
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
 --INI--
 open_basedir=/tmp
 --FILE--
 <?php
-       $a=glob("./*.jpeg");
-
+$a=glob("./*.jpeg");
+var_dump($a);
 echo "Done\n";
 ?>
 --EXPECT--
+bool(false)
 Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/chmod_variation3.phpt b/ext/standard/tests/file/chmod_variation3.phpt
new file mode 100644 (file)
index 0000000..c2dd607
--- /dev/null
@@ -0,0 +1,209 @@
+--TEST--
+Test chmod() function : first parameter variation 
+--FILE--
+<?php
+/* Prototype  : bool chmod(string filename, int mode)
+ * Description: Change file mode 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing chmod() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$mode = 0777;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for filename
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( chmod($value, $mode) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing chmod() : usage variation ***
+
+--int 0--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - chmod() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - chmod() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+===DONE===
+
diff --git a/ext/standard/tests/file/chmod_variation4.phpt b/ext/standard/tests/file/chmod_variation4.phpt
new file mode 100644 (file)
index 0000000..4ff85f0
--- /dev/null
@@ -0,0 +1,202 @@
+--TEST--
+Test chmod() function : second parameter variation 
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : bool chmod(string filename, int mode)
+ * Description: Change file mode 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing chmod() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted
+$filename = __FILE__ . ".tmp";
+$fd = fopen($filename, "w+");
+fclose($fd);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for mode
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( chmod($filename, $value) );
+};
+
+chmod($filename, 0777);
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing chmod() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float -10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float -12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - chmod() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - chmod() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
index a71c597e4172937ea1f64d54117894bb3daf579e..779f82b6f6299408ca27447df37c4ce5f65aa272 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test copy() function: usage variations - src as dir and dest as an existing file (Bug #42243)
+Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243)
 --FILE--
 <?php
 /* Prototype: bool copy ( string $source, string $dest );
index 65c1dc2ef6913939c2a075cc6b23b140ef39b90c..53467af8a3c3d761c12a54fdaa141a675fe9ac41 100644 (file)
@@ -16,7 +16,7 @@ require($file_path."/file.inc");
 echo "*** Test copy() function: stat of file before and after copy ***\n";
 $src_file_name = $file_path."/copy_variation18.tmp";
 $file_handle =  fopen($src_file_name, "w");
-fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
+fwrite($file_handle, str_repeat("Hello2world...\n", 100));
 fclose($file_handle);
 
 $dest_file_name = $file_path."/copy_copy_variation18.tmp";
@@ -32,8 +32,13 @@ var_dump( copy($src_file_name, $dest_file_name) );
 $stat_after_copy = stat($src_file_name);
 clearstatcache();
 
+// compare all stat fields except access time
+$stat_keys_to_compare = array("dev", "ino", "mode", "nlink", "uid", "gid", 
+                       "rdev", "size", "mtime", "ctime",
+                       "blksize", "blocks");
+
 echo "Comparing the stats of file before and after copy operation => ";
-var_dump( compare_stats($stat_before_copy, $stat_after_copy, $all_stat_keys) );
+var_dump( compare_stats($stat_before_copy, $stat_after_copy, $stat_keys_to_compare) );
 
 echo "*** Done ***\n";
 ?>
@@ -43,6 +48,7 @@ echo "*** Done ***\n";
 unlink(dirname(__FILE__)."/copy_copy_variation18.tmp");
 unlink(dirname(__FILE__)."/copy_variation18.tmp");
 ?>
+
 --EXPECTF--
 *** Test copy() function: stat of file before and after copy ***
 Copy operation => bool(true)
diff --git a/ext/standard/tests/file/dirname_basic-win32.phpt b/ext/standard/tests/file/dirname_basic-win32.phpt
new file mode 100644 (file)
index 0000000..61a6e33
--- /dev/null
@@ -0,0 +1,93 @@
+--TEST--
+Test dirname() function : basic functionality 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string dirname(string path)
+ * Description: Returns the directory name component of the path 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing dirname() : basic functionality ***\n";
+
+
+// Initialise all required variables
+$paths = array(
+                       '',
+                       ' ',
+                       'c:',
+                       'c:\\',
+                       'c:/',
+                       'afile',
+                       'c:\test\afile',
+                       'c:\\test\\afile',
+                       'c://test//afile',
+                       'c:\test\afile\\',
+                       '/usr/lib/locale/en_US',
+                       '//usr/lib//locale/en_US',
+                       '\\',
+                       '\\\\',
+                       '/',
+                       '//',
+                       '///',
+                       '/usr/lib/locale/en_US/',
+                       'c:\windows/system32\drivers/etc\hosts',
+                       '/usr\lib/locale\en_US',
+                       '   c:\test\adir\afile.txt',
+                       'c:\test\adir\afile.txt   ',
+                       '   c:\test\adir\afile.txt   ',
+                       '   /usr/lib/locale/en_US',
+                       '/usr/lib/locale/en_US   ',
+                       '   /usr/lib/locale/en_US   ',
+                       ' c:',
+                       '               c:\test\adir\afile.txt',
+                       '/usr',
+                       '/usr/',                        
+                       );
+
+foreach ($paths as $path) {
+       var_dump( dirname($path) );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : basic functionality ***
+string(0) ""
+string(1) "."
+string(2) "c:"
+string(3) "c:\"
+string(3) "c:\"
+string(1) "."
+string(7) "c:\test"
+string(7) "c:\test"
+string(8) "c://test"
+string(7) "c:\test"
+string(15) "/usr/lib/locale"
+string(17) "//usr/lib//locale"
+string(1) "\"
+string(1) "\"
+string(1) "\"
+string(1) "\"
+string(1) "\"
+string(15) "/usr/lib/locale"
+string(31) "c:\windows/system32\drivers/etc"
+string(15) "/usr\lib/locale"
+string(15) "   c:\test\adir"
+string(12) "c:\test\adir"
+string(15) "   c:\test\adir"
+string(18) "   /usr/lib/locale"
+string(15) "/usr/lib/locale"
+string(18) "   /usr/lib/locale"
+string(1) "."
+string(14) "           c:\test\adir"
+string(1) "\"
+string(1) "\"
+===DONE===
diff --git a/ext/standard/tests/file/dirname_basic.phpt b/ext/standard/tests/file/dirname_basic.phpt
new file mode 100644 (file)
index 0000000..8f1944e
--- /dev/null
@@ -0,0 +1,94 @@
+--TEST--
+Test dirname() function : basic functionality 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string dirname(string path)
+ * Description: Returns the directory name component of the path 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing dirname() : basic functionality ***\n";
+
+
+// Initialise all required variables
+$paths = array(
+                       '',
+                       ' ',
+                       'c:',
+                       'c:\\',
+                       'c:/',
+                       'afile',
+                       'c:\test\afile',
+                       'c:\\test\\afile',
+                       'c://test//afile',
+                       'c:\test\afile\\',
+                       '/usr/lib/locale/en_US',
+                       '//usr/lib//locale/en_US',
+                       '\\',
+                       '\\\\',
+                       '/',
+                       '//',
+                       '///',
+                       '/usr/lib/locale/en_US/',
+                       'c:\windows/system32\drivers/etc\hosts',
+                       '/usr\lib/locale\en_US',
+                       '   c:\test\adir\afile.txt',
+                       'c:\test\adir\afile.txt   ',
+                       '   c:\test\adir\afile.txt   ',
+                       '   /usr/lib/locale/en_US',
+                       '/usr/lib/locale/en_US   ',
+                       '   /usr/lib/locale/en_US   ',
+                       ' c:',
+                       '               c:\test\adir\afile.txt',
+                       '/usr',
+                       '/usr/'                 
+                       );
+
+foreach ($paths as $path) {
+       var_dump( dirname($path) );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : basic functionality ***
+string(0) ""
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(8) "c://test"
+string(1) "."
+string(15) "/usr/lib/locale"
+string(17) "//usr/lib//locale"
+string(1) "."
+string(1) "."
+string(1) "/"
+string(1) "/"
+string(1) "/"
+string(15) "/usr/lib/locale"
+string(27) "c:\windows/system32\drivers"
+string(8) "/usr\lib"
+string(1) "."
+string(1) "."
+string(1) "."
+string(18) "   /usr/lib/locale"
+string(15) "/usr/lib/locale"
+string(18) "   /usr/lib/locale"
+string(1) "."
+string(1) "."
+string(1) "/"
+string(1) "/"
+===DONE===
+
diff --git a/ext/standard/tests/file/dirname_error.phpt b/ext/standard/tests/file/dirname_error.phpt
new file mode 100644 (file)
index 0000000..dc7814f
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Test dirname() function : error conditions 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string dirname(string path)
+ * Description: Returns the directory name component of the path 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing dirname() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing dirname() function with Zero arguments --\n";
+var_dump( dirname() );
+
+//Test dirname with one more than the expected number of arguments
+echo "\n-- Testing dirname() function with more than expected no. of arguments --\n";
+$path = 'string_val';
+$extra_arg = 10;
+var_dump( dirname($path, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : error conditions ***
+
+-- Testing dirname() function with Zero arguments --
+
+Warning: dirname() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing dirname() function with more than expected no. of arguments --
+
+Warning: dirname() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
+
diff --git a/ext/standard/tests/file/dirname_variation1.phpt b/ext/standard/tests/file/dirname_variation1.phpt
new file mode 100644 (file)
index 0000000..15041ff
--- /dev/null
@@ -0,0 +1,190 @@
+--TEST--
+Test dirname() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string dirname(string path)
+ * Description: Returns the directory name component of the path 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing dirname() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for path
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( dirname($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : usage variation ***
+
+--int 0--
+string(1) "."
+
+--int 1--
+string(1) "."
+
+--int 12345--
+string(1) "."
+
+--int -12345--
+string(1) "."
+
+--float 10.5--
+string(1) "."
+
+--float -10.5--
+string(1) "."
+
+--float 12.3456789000e10--
+string(1) "."
+
+--float -12.3456789000e10--
+string(1) "."
+
+--float .5--
+string(1) "."
+
+--empty array--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(1) "."
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(1) "."
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+string(0) ""
+
+--empty string SQ--
+string(0) ""
+
+--instance of classWithToString--
+string(1) "."
+
+--instance of classWithoutToString--
+Error: 2 - dirname() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
+
index 6eef4b4a772a358e1d9b2bba004d89a5068dd86d..e1a74fc984c039b6fd9add8aa54a31d3b3d868e3 100644 (file)
@@ -37,8 +37,8 @@ bool(false)
 
 Warning: disk_total_space(): No such file or directory in %s on line %d
 bool(false)
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 Warning: disk_free_space(): No such file or directory in %s on line %d
 bool(false)
index f8684e92a9b68bbae15983f1a63ef647321e49ed..cae37bad59d37799b52b3763a488301ac944b5b9 100644 (file)
@@ -7,27 +7,26 @@ memory_limit=32M
 /*
  *  Prototype: float disk_free_space( string directory )
  *  Description: Given a string containing a directory, this function 
- *               will return the number of bytes available on the corresponding 
- *               filesystem or disk partition
+ *  will return the number of bytes available on the corresponding 
+ *  filesystem or disk partition
  */
 
 $file_path = dirname(__FILE__);
+include($file_path."/file.inc");
 
 echo "*** Testing with existing directory ***\n";
 var_dump( disk_free_space($file_path) ); 
 var_dump( diskfreespace($file_path) ); 
+$dir = "/disk_free_space";
 
 echo "*** Testing with newly created directory ***\n";
-$dir = "/disk_free_space";
 mkdir($file_path.$dir);
 echo" \n Free Space before writing to a file\n";
 $space1 =  disk_free_space($file_path.$dir); 
-var_dump( $space1 ); 
+var_dump($space1); 
 
-$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a");
-for( $i=1; $i<=1000; $i++)
-fwrite($fh, (binary)"x");
-fclose($fh);
+fill_buffer($buffer, "text", 3000000);
+file_put_contents($file_path.$dir."/disk_free_space.tmp", $buffer);
 
 echo "\n Free Space after writing to a file\n";
 $space2 =  disk_free_space($file_path.$dir); 
@@ -38,33 +37,29 @@ if( $space1 > $space2 )
 else
   echo "\n Free Space Value Is Incorrect\n";
 
-echo "*** Testing with Binary Input ***\n";
-var_dump( disk_free_space(b"$file_path") ); 
-
-echo"\n--- Done ---";
+echo"\n-- Done --";
 ?>
 
 --CLEAN--
 <?php
 $file_path = dirname(__FILE__);
-unlink($file_path."/disk_free_space/disk_free_space.tmp");
-rmdir($file_path."/disk_free_space");
+$dir = "/disk_free_space";
+unlink($file_path.$dir."/disk_free_space.tmp");
+rmdir($file_path.$dir);
 ?>
 
 --EXPECTF--
 *** Testing with existing directory ***
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 *** Testing with newly created directory ***
  
  Free Space before writing to a file
-float(%d)
+float(%f)
 
  Free Space after writing to a file
-float(%d)
+float(%f)
 
  Free Space Value Is Correct
-*** Testing with Binary Input ***
-float(%d)
 
---- Done ---
+-- Done --
index ddd25a35db86630c76d6478b7e8756b2f1b68488..945b7b9c847b22af452727fcb6f2786c34c9c378 100644 (file)
@@ -1,15 +1,15 @@
 --TEST--
-Test disk_free_space and its alias diskfreespace() functions : error conditions.
+Test disk_free_space and its alias diskfreespace() functions : error conditions
 --SKIPIF--
 <?php
-if(substr(PHP_OS, 0, 3) == 'WIN')
-  die("skip Not valid on Windows");
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+  die("skip Not Valid for Windows");
 ?>
 --FILE--
 <?php
 /*
  *  Prototype: float disk_free_space( string directory )
- *  Description: Given a string containing a directory, this function will 
+ *  Description: Given a string containing a directory, this function will
  *               return the number of bytes available on the corresponding 
  *               filesystem or disk partition
  */
@@ -27,7 +27,7 @@ var_dump( disk_free_space( $file_path."/dir1" )); // Invalid directory
 var_dump( diskfreespace( $file_path."/dir1" ));
 
 $fh = fopen( $file_path."/disk_free_space.tmp", "w" );
-fwrite( $fh, (binary)" Garbage data for the temporary file" );
+fwrite( $fh, " Garbage data for the temporary file" );
 var_dump( disk_free_space( $file_path."/disk_free_space.tmp" )); // file input instead of directory
 var_dump( diskfreespace( $file_path."/disk_free_space.tmp" ));
 fclose($fh);
@@ -55,13 +55,12 @@ NULL
 Warning: diskfreespace() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 
-Warning: disk_free_space(): No such file or directory in %s on line %d
+Warning: disk_free_space(): %s in %s on line %d
 bool(false)
 
-Warning: diskfreespace(): No such file or directory in %s on line %d
+Warning: diskfreespace(): %s in %s on line %d
 bool(false)
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Done --
-
index c1809986fd8604c08df7bf06189041758d45b03e..01fa183735b7e1baa0c2392056833dd68ffdac21 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test disk_free_space and its alias diskfreespace() functions : Usage Variations
+Test disk_free_space and its alias diskfreespace() functions : usage variations
 --FILE--
 <?php
 /*
@@ -11,15 +11,16 @@ Test disk_free_space and its alias diskfreespace() functions : Usage Variations
 
 $file_path = dirname(__FILE__);
 
-echo "*** Testing with a directory ***\n";
+echo "*** Testing disk_free_space() function with a directory ***\n";
 var_dump( disk_free_space($file_path."/..") ); 
 var_dump( diskfreespace($file_path."/..") ); 
 
-echo "\nTesting for the return type ***\n";
+echo "\n*** Testing for the return type ***\n";
 $return_value = disk_free_space($file_path); 
 var_dump( is_float($return_value) );
 
-echo "\n*** Testing with different directory combinations ***";
+echo "\n*** Testing disk_free_space() function with different styles of file and directory ***";
+
 $dir = "/disk_free_space";
 mkdir($file_path.$dir);
 
@@ -41,15 +42,15 @@ $dirs_arr = array(
   $file_path.$dir.chr(0),
   $file_path."/.".$dir.chr(0),
   ".".chr(0).$file_path.$dir,
-  ".".chr(0).$file_path.$dir.chr(0)
+  ".".chr(0).$file_path.$dir.chr(0) 
 );
 
 $count = 1;
 /* loop through to test each element the above array */
-foreach($dirs_arr as $dir1) {
+foreach($dirs_arr as $dir) {
   echo "\n-- Iteration $count --\n";
-  var_dump( disk_free_space( $dir1 ) );
-  var_dump( diskfreespace( $dir1 ) );
+  var_dump( disk_free_space( $dir ) );
+  var_dump( diskfreespace( $dir ) );
   $count++;
 }
 
@@ -58,66 +59,65 @@ echo"\n--- Done ---";
 
 --CLEAN--
 <?php
-$file_path = dirname(__FILE__);
-rmdir($file_path."/disk_free_space");
+$file_path = dirname(__FILE__)."/disk_free_space";
+rmdir($file_path);
 ?>
 
-
 --EXPECTF--
-*** Testing with a directory ***
-float(%d)
-float(%d)
+*** Testing disk_free_space() function with a directory ***
+float(%f)
+float(%f)
 
-Testing for the return type ***
+*** Testing for the return type ***
 bool(true)
 
-*** Testing with different directory combinations ***
+*** Testing disk_free_space() function with different styles of file and directory ***
 -- Iteration 1 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 2 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 3 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 4 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 5 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 6 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 7 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 8 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 9 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 10 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 11 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 -- Iteration 12 --
-float(%d)
-float(%d)
+float(%f)
+float(%f)
 
 --- Done ---
index d211f39437bf76f32565041bf5a5718f1c16dbcb..8f3a2f21c3dc232e14f4df1e815e235c23417104 100644 (file)
@@ -4,31 +4,31 @@ Test disk_total_space() function : basic functionality
 <?php
 /*
  *  Prototype: float disk_total_space( string $directory );
- *  Description: given a string containing a directory, this function will 
- *               return the total number of bytes on the corresponding filesyatem
- *               or disk partition.
+ *  Description: given a string containing a directory, this 
+ *               function will return the total number of bytes 
+ *               on the corresponding filesyatem or disk partition.
  */
 
 $file_path = dirname(__FILE__);
 
-echo "*** Testing with normal directory ***\n";
+echo "*** Testing with existing directory ***\n";
 var_dump( disk_total_space($file_path) );
 
 echo "*** Testing with newly created directory ***\n";
-$dir = "/disk_total_space";
+mkdir($file_path."/disk_total_space");
+var_dump( disk_total_space($file_path."/disk_total_space") );
 
-mkdir($file_path.$dir);
-var_dump( disk_total_space($file_path.$dir) );
-$fh = fopen($file_path.$dir."/disk_total_space.tmp", "w");
-fwrite($fh, (binary)"Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data");
+$fh = fopen($file_path."/disk_total_space/disk_total_space.tmp", "w");
+fwrite($fh, "Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data");
 
 fclose($fh);
 
-echo"\nTotal Space after writing to a file\n";
-var_dump( disk_total_space($file_path.$dir) );
+echo" \n Total Space after writing to a file\n";
+var_dump( disk_total_space($file_path."/disk_total_space") );
 
-echo"\n-- Done --";
+echo"\n--- Done ---";
 ?>
+
 --CLEAN--
 <?php
 $file_path = dirname(__FILE__);
@@ -37,12 +37,12 @@ rmdir($file_path."/disk_total_space");
 ?>
 
 --EXPECTF--
-*** Testing with normal directory ***
-float(%d)
+*** Testing with existing directory ***
+float(%f)
 *** Testing with newly created directory ***
-float(%d)
-
-Total Space after writing to a file
-float(%d)
+float(%f)
+ Total Space after writing to a file
+float(%f)
 
--- Done --
+--- Done ---
index d986f779ba66fde8a9a7b563a8cb2af64fddb799..196028007ea96dfb62a415c431d2a5f9954a0ffe 100644 (file)
@@ -2,14 +2,14 @@
 Test disk_total_space() function : error conditions
 --SKIPIF--
 <?php
-if(substr(PHP_OS, 0, 3) == 'WIN')
-  die("skip Not valid on Windows");
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+  die("skip Not Valid for Windows");
 ?>
 --FILE--
 <?php
 /*
  *  Prototype: float disk_total_space( string $directory );
- *  Description: given a string containing a directory, this function 
+ *  Description: given a string containing a directory, this function
  *               will return the total number of bytes on the corresponding 
  *               filesystem or disk partition
  */
@@ -24,7 +24,7 @@ var_dump( disk_total_space( $file_path, "extra argument") ); // More than valid
 var_dump( disk_total_space( $file_path."/dir1" )); // Invalid directory
 
 $fh = fopen( $file_path."/disk_total_space.tmp", "w" );
-fwrite( $fh, (binary)" Garbage data for the temporary file" );
+fwrite( $fh, " Garbage data for the temporary file" );
 var_dump( disk_total_space( $file_path."/disk_total_space.tmp" )); // file input instead of directory
 fclose($fh);
 
@@ -46,7 +46,6 @@ NULL
 
 Warning: disk_total_space(): No such file or directory in %s on line %d
 bool(false)
-float(%d)
+float(%f)
 
 --- Done ---
-
index c03ba594bdfaa29e819a1fe2bb08570b9c8e0af1..6cd96cd8725d882e0c6c85df2864c7188f5f2f49 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Testing disk_total_space() functions : Usage Variations.
+Test disk_total_space() functions : usage variations
 --FILE--
 <?php
 /*
@@ -18,9 +18,9 @@ echo "\nTesting for the return type ***\n";
 $return_value = disk_total_space($file_path); 
 var_dump( is_float($return_value) );
 
-echo "\n*** Testing with different directory combinations ***";
-$dir = "/disk_total_space";
+echo "\n*** Testing disk_total_space() function with different directory combinations ***";
 
+$dir = "/disk_total_space";
 mkdir($file_path.$dir);
 
 $dirs_arr = array(
@@ -29,7 +29,7 @@ $dirs_arr = array(
   $file_path."/.".$dir,
 
   /* Testing a file trailing slash */
-  $file_path."".$dir."/",
+  $file_path.$dir."/",
   $file_path."/.".$dir."/",
 
   /* Testing file with double trailing slashes */
@@ -44,7 +44,6 @@ $dirs_arr = array(
   ".".chr(0).$file_path.$dir.chr(0)
 );
 
-
 $count = 1;
 /* loop through to test each element the above array */
 foreach($dirs_arr as $dir1) {
@@ -53,63 +52,57 @@ foreach($dirs_arr as $dir1) {
   $count++;
 }
 
-echo "*** Testing with Binary Input ***\n";
-var_dump( disk_total_space(b"$file_path") ); 
-
 echo"\n--- Done ---";
 ?>
 
 --CLEAN--
 <?php
 $file_path = dirname(__FILE__);
-rmdir($file_path."/disk_total_space");
+$dir = "/disk_total_space";
+rmdir($file_path.$dir);
 ?>
-
-
 --EXPECTF--
 *** Testing with a directory ***
-float(%d)
+float(%f)
 
 Testing for the return type ***
 bool(true)
 
-*** Testing with different directory combinations ***
+*** Testing disk_total_space() function with different directory combinations ***
 -- Iteration 1 --
-float(%d)
+float(%f)
 
 -- Iteration 2 --
-float(%d)
+float(%f)
 
 -- Iteration 3 --
-float(%d)
+float(%f)
 
 -- Iteration 4 --
-float(%d)
+float(%f)
 
 -- Iteration 5 --
-float(%d)
+float(%f)
 
 -- Iteration 6 --
-float(%d)
+float(%f)
 
 -- Iteration 7 --
-float(%d)
+float(%f)
 
 -- Iteration 8 --
-float(%d)
+float(%f)
 
 -- Iteration 9 --
-float(%d)
+float(%f)
 
 -- Iteration 10 --
-float(%d)
+float(%f)
 
 -- Iteration 11 --
-float(%d)
+float(%f)
 
 -- Iteration 12 --
-float(%d)
-*** Testing with Binary Input ***
-float(%d)
+float(%f)
 
 --- Done ---
diff --git a/ext/standard/tests/file/feof_basic.phpt b/ext/standard/tests/file/feof_basic.phpt
new file mode 100644 (file)
index 0000000..ff1d179
--- /dev/null
@@ -0,0 +1,101 @@
+--TEST--
+Test feof() function : basic functionality 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto bool feof(resource fp)
+ * Description: Test for end-of-file on a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzeof
+ */
+
+echo "*** Testing feof() : basic functionality ***\n";
+$tmpFile1 = __FILE__.".tmp1";
+$h = fopen($tmpFile1, 'wb');
+$count = 10;
+for ($i = 1; $i <= $count; $i++) {
+   fwrite($h, "some data $i\n");
+}
+fclose($h);
+
+echo "\n*** testing reading complete file using feof to stop ***\n";
+$h = fopen($tmpFile1, 'rb');
+
+//feof is not set to true until you try to read past the end of file.
+//so fgets will be called even if we are at the end of the file on
+//last time to set the eof flag but it will fail to read.
+$lastline = "";
+while (!feof($h)) {
+   $previousLine = $lastline;
+   $lastline = fgets($h);
+}
+echo $previousLine;
+var_dump($lastline); // this should be false 
+fclose($h);
+
+$tmpFile2 = __FILE__.".tmp2";
+$h = fopen($tmpFile2, 'wb+');
+$count = 10;
+echo "*** writing $count lines, testing feof ***\n";
+for ($i = 1; $i <=$count; $i++) {
+   fwrite($h, "some data $i\n");
+   var_dump(feof($h));
+}
+
+echo "*** testing feof on unclosed file after a read ***\n";
+
+fread($h, 100);
+var_dump(feof($h));
+
+$eofPointer = ftell($h);
+
+echo "*** testing feof after a seek to near the beginning ***\n";
+fseek($h, 20, SEEK_SET);
+var_dump(feof($h));
+
+echo "*** testing feof after a seek to end ***\n";
+fseek($h, $eofPointer, SEEK_SET);
+var_dump(feof($h));
+
+echo "*** testing feof after a seek passed the end ***\n";
+fseek($h, $eofPointer + 1000, SEEK_SET);
+var_dump(feof($h));
+
+echo "*** closing file, testing eof ***\n";
+fclose($h);
+feof($h);
+unlink($tmpFile1);
+unlink($tmpFile2);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing feof() : basic functionality ***
+
+*** testing reading complete file using feof to stop ***
+some data 10
+bool(false)
+*** writing 10 lines, testing feof ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+*** testing feof on unclosed file after a read ***
+bool(true)
+*** testing feof after a seek to near the beginning ***
+bool(false)
+*** testing feof after a seek to end ***
+bool(false)
+*** testing feof after a seek passed the end ***
+bool(false)
+*** closing file, testing eof ***
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+Done
index 6d7f731763e6056abf0656383a852aa3c69dd1fa..9f745e520261f066dd1a7d7eaeb9c406bc75f5b8 100644 (file)
@@ -24,9 +24,10 @@ if($file_handle == false)
    
 var_dump( fflush($file_handle, $file_handle) );
 fclose($file_handle);
+fflush($file_handle);
 
 // test invalid arguments : non-resources
-echo "-- Testing fflush(): with invalid arguments --\n";
+echo "\n-- Testing fflush(): with invalid arguments --\n";
 $invalid_args = array (
   "string",
   10,
@@ -41,7 +42,7 @@ for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
   echo "-- Iteration $loop_counter --\n";
   var_dump( fflush($invalid_args[$loop_counter - 1]) );
 }
-echo "\n*** Done ***";
+echo "Done\n";
 ?>
 
 --CLEAN--
@@ -60,6 +61,9 @@ bool(false)
 
 Warning: fflush() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
+
+Warning: fflush(): %d is not a valid stream resource in %s on line %d
+
 -- Testing fflush(): with invalid arguments --
 -- Iteration 1 --
 
@@ -85,6 +89,5 @@ bool(false)
 
 Warning: fflush() expects parameter 1 to be resource, object given in %s on line %d
 bool(false)
-
-*** Done ***
+Done
 
index a55c53f9bfa5641b536944a495562f8197857ff4..51ae3c6a37b56aa71b0d9d70e6cb060818abbc37 100644 (file)
@@ -99,9 +99,10 @@ bool(false)
 Warning: fgets() expects parameter 1 to be resource, object given in %s on line %d
 bool(false)
 -- Testing fgets() with closed/unset file handle --
-Warning: fgets(): 5 is not a valid stream resource in %s on line %d
+Warning: fgets(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
diff --git a/ext/standard/tests/file/fgets_socket_variation1.phpt b/ext/standard/tests/file/fgets_socket_variation1.phpt
new file mode 100644 (file)
index 0000000..57944d8
--- /dev/null
@@ -0,0 +1,56 @@
+--TEST--
+fgets() with a socket stream
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+/* Setup socket server */
+$server = stream_socket_server('tcp://127.0.0.1:31337');
+
+/* Connect to it */
+$client = fsockopen('tcp://127.0.0.1:31337');
+
+if (!$client) {
+       die("Unable to create socket");
+}
+
+/* Accept that connection */
+$socket = stream_socket_accept($server);
+
+echo "Write some data:\n";
+fwrite($socket, "line1\nline2\nline3\n");
+
+
+echo "\n\nRead a line from the client:\n";
+var_dump(fgets($client));
+
+echo "\n\nRead another line from the client:\n";
+var_dump(fgets($client));
+
+echo "\n\nClose the server side socket and read the remaining data from the client\n";
+fclose($socket);
+fclose($server);
+while(!feof($client)) {
+       fread($client, 1);
+}
+
+echo "done\n";
+
+?>
+--EXPECT--
+Write some data:
+
+
+Read a line from the client:
+string(6) "line1
+"
+
+
+Read another line from the client:
+string(6) "line2
+"
+
+
+Close the server side socket and read the remaining data from the client
+done
diff --git a/ext/standard/tests/file/fgets_socket_variation2.phpt b/ext/standard/tests/file/fgets_socket_variation2.phpt
new file mode 100644 (file)
index 0000000..3500837
--- /dev/null
@@ -0,0 +1,63 @@
+--TEST--
+fgets() over a socket with more than a buffer's worth of data
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+// create a file
+$filename = __FILE__ . ".tmp";
+$fd = fopen($filename, "w+");
+
+// populate the file with lines of data
+define("LINE_OF_DATA", "12345678\n");
+for ($i = 0; $i < 1000; $i++) {
+       fwrite($fd, LINE_OF_DATA);
+}
+fclose($fd);
+
+/* Setup socket server */
+$server = stream_socket_server('tcp://127.0.0.1:31337');
+
+/* Connect to it */
+$client = fsockopen('tcp://127.0.0.1:31337');
+
+if (!$client) {
+       die("Unable to create socket");
+}
+
+/* Accept that connection */
+$socket = stream_socket_accept($server);
+
+echo "Write data from the file:\n";
+$data = file_get_contents($filename);
+unlink($filename);
+
+var_dump(fwrite($socket, $data));
+fclose($socket);
+
+echo "\nRead lines from the client\n";
+while ($line = fgets($client,256)) {
+       if (strcmp($line, LINE_OF_DATA) != 0) {
+               echo "Error - $line does not match " . LINE_OF_DATA;
+               break;
+       }
+}
+
+echo "\nClose the server side socket and read the remaining data from the client\n";
+fclose($server);
+while(!feof($client)) {
+       fread($client, 1);
+}
+
+echo "done\n";
+
+?>
+--EXPECT--
+Write data from the file:
+int(9000)
+
+Read lines from the client
+
+Close the server side socket and read the remaining data from the client
+done
index b24956a59dad8e86f58116842045392e8a1a7de6..964216bf8cbba0eb7156035b6354354f93fcd950 100644 (file)
@@ -43,10 +43,10 @@ echo "Done";
 *** Testing fgets() : usage variations ***
 -- Testing fgets() with closed handle --
 
-Warning: fgets(): 6 is not a valid stream resource in %s on line %d
+Warning: fgets(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
-Warning: fgets(): 6 is not a valid stream resource in %s on line %d
+Warning: fgets(): %d is not a valid stream resource in %s on line %d
 bool(false)
 -- Testing fgets() with unset handle --
 
@@ -60,3 +60,4 @@ Notice: Undefined variable: file_handle in %s on line %d
 Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
index a18fd2ceb46a8e25d284ae093f6e47259f9dbf8d..efb425ca42239bbd29c017c5c9e3e690e1d817d7 100644 (file)
@@ -7,7 +7,7 @@
        delete_links() : delete links 
        fill_files()   : fill file with specified contents 
        change_file_perms() : Change permission of files 
-       fill_buffer()    : fill buffer with specified contents
+       fill_buffer()  : fills buffer with specified contents
        compare_self_stat() : compares the first 13 elements of the 
                             stat with the corresponding named key values of
                             the same stat.
@@ -80,7 +80,7 @@ function fill_buffer(&$buffer, $fill_type, $fill_size) {
 }
 
 /*
- Function : bool fill_file(resource $file_handle, string $fill_type, int $file_size);
+ Function : bool fill_file(resource $file_handle, string $fill_type, string $file_size);
  Description: Fills the file with data as specified with requested size.
    $file_handle = file handle, opened with write options,
    $fill_type: 
@@ -638,8 +638,6 @@ function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
   // if the result is false(i.e values are not as expected), 
   // dump the stat array so that easy to figure out the error
   if ( $result == false ) {
-    echo "\n Dumping diff between stat array 1 and 2...\n";
-    var_dump(array_diff($stat1, $stat2));
     echo "\n Dumping stat array 1...\n";
     var_dump($stat1);
     echo "\n Dumping stat array 2...\n";
diff --git a/ext/standard/tests/file/file_exists_error.phpt b/ext/standard/tests/file/file_exists_error.phpt
new file mode 100644 (file)
index 0000000..bd890f9
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+Test file_exists() function : error conditions 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto bool file_exists(string filename)
+ * Description: Returns true if filename exists 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+/*
+ * add a comment here to say what the test is supposed to do
+ */
+
+echo "*** Testing file_exists() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing file_exists() function with Zero arguments --\n";
+var_dump( file_exists() );
+
+//Test file_exists with one more than the expected number of arguments
+echo "\n-- Testing file_exists() function with more than expected no. of arguments --\n";
+$filename = 'string_val';
+$extra_arg = 10;
+var_dump( file_exists($filename, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing file_exists() : error conditions ***
+
+-- Testing file_exists() function with Zero arguments --
+
+Warning: file_exists() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing file_exists() function with more than expected no. of arguments --
+
+Warning: file_exists() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/standard/tests/file/file_exists_variation1.phpt b/ext/standard/tests/file/file_exists_variation1.phpt
new file mode 100644 (file)
index 0000000..35c86a2
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Test file_exists() function : usage variations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto bool file_exists(string filename)
+ * Description: Returns true if filename exists 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_exists() : usage variations ***\n";
+
+var_dump(file_exists(NULL));
+var_dump(file_exists(false));
+var_dump(file_exists(''));
+var_dump(file_exists(' '));
+var_dump(file_exists('|'));
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing file_exists() : usage variations ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_basic.phpt b/ext/standard/tests/file/file_get_contents_basic.phpt
new file mode 100644 (file)
index 0000000..5dc0a5e
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+file_get_contents() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+/*  Prototype: string file_get_contents( string $filename[, bool $use_include_path[,
+ *                                       resource $context[, int $offset[, int $maxlen]]]] )
+ *  Description: Reads entire file into a string
+ */
+
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "*** Testing the basic functionality of the file_get_contents() function ***\n";
+
+echo "-- Testing with simple valid data file --\n";
+
+
+create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte");
+var_dump( file_get_contents($file_path."/file1.tmp") );
+delete_files($file_path, 1);
+
+echo "\n-- Testing with empty file --\n";
+
+create_files($file_path, 1, "empty", 0755, 100, "w", "file", 1, "byte");
+var_dump( file_get_contents($file_path."/file1.tmp") );
+delete_files($file_path, 1);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_put_contents.tmp");
+unlink($file_path."/file_put_contents1.tmp");
+?>
+--EXPECTF--
+*** Testing the basic functionality of the file_get_contents() function ***
+-- Testing with simple valid data file --
+string(100) "text text text text text text text text text text text text text text text text text text text text "
+
+-- Testing with empty file --
+string(0) ""
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_error.phpt b/ext/standard/tests/file/file_get_contents_error.phpt
new file mode 100644 (file)
index 0000000..9c30c23
--- /dev/null
@@ -0,0 +1,64 @@
+--TEST--
+Test file_get_contents() function : error conditions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: string file_get_contents( string $filename{, bool $use_include_path[,
+ *                                      resource $context[, int $offset[, int $maxlen]]]] ) 
+ * Description: Reads entire file into a string
+ */
+
+echo "*** Testing error conditions ***\n";
+
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "\n-- Testing with  Non-existing file --\n";
+print( file_get_contents("/no/such/file/or/dir") );
+
+echo "\n-- Testing No.of arguments less than expected --\n";
+print( file_get_contents() );
+
+echo "\n-- Testing No.of arguments greater than expected --\n";
+
+create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte");
+$file_handle = fopen($file_path."/file_put_contents_error.tmp", "w");
+print( file_get_contents($file_path."/file1.tmp", false, $file_handle, 1, 2, "extra_argument") );
+
+echo "\n-- Testing for invalid negative maxlen values --";
+var_dump( file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5) );
+   
+delete_files($file_path, 1);
+fclose($file_handle);
+unlink($file_path."/file_put_contents_error.tmp");
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_put_contents_error.tmp");
+unlink($file_path."/file_put_contents1.tmp");
+
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+-- Testing with  Non-existing file --
+
+Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d
+
+-- Testing No.of arguments less than expected --
+
+Warning: file_get_contents() expects at least 1 parameter, 0 given in %s on line %d
+
+-- Testing No.of arguments greater than expected --
+
+Warning: file_get_contents() expects at most 5 parameters, 6 given in %s on line %d
+
+-- Testing for invalid negative maxlen values --
+Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation1.phpt b/ext/standard/tests/file/file_get_contents_variation1.phpt
new file mode 100644 (file)
index 0000000..ddc9261
--- /dev/null
@@ -0,0 +1,51 @@
+--TEST--
+Test file_get_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "fileGetContentsVar1.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "afile.txt";
+$secondFile = $dir2."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $secondFile, $filename;
+   $h = fopen($secondFile, "w");
+   fwrite($h, "File in include path");
+   fclose($h);
+   $line = file_get_contents($filename, true);
+   echo "$line\n";
+   unlink($secondFile);  
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_get_contents() : variation ***
+File in include path
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation2.phpt b/ext/standard/tests/file/file_get_contents_variation2.phpt
new file mode 100644 (file)
index 0000000..510ec12
--- /dev/null
@@ -0,0 +1,52 @@
+--TEST--
+Test file_get_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "FileGetContentsVar2.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = 'FileGetContentsVar2.tmp';
+$scriptLocFile = dirname(__FILE__)."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $scriptLocFile, $filename;
+   $h = fopen($scriptLocFile, "w");
+   fwrite($h, "File in script location");
+   fclose($h);
+   $line = file_get_contents($filename, true);
+   echo "$line\n";
+   unlink($scriptLocFile);  
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_get_contents() : variation ***
+File in script location
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation3.phpt b/ext/standard/tests/file/file_get_contents_variation3.phpt
new file mode 100644 (file)
index 0000000..f485b0e
--- /dev/null
@@ -0,0 +1,218 @@
+--TEST--
+Test file_get_contents() function : usage variation - different type for use_include_path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar3.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for use_include_path
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file_get_contents($absFile, $value) );
+};
+
+unlink($absFile);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+string(13) "contents read"
+
+--int 1--
+string(13) "contents read"
+
+--int 12345--
+string(%d) "contents read"
+
+--int -12345--
+string(%d) "contents read"
+
+--float 10.5--
+string(%d) "contents read"
+
+--float -10.5--
+string(%d) "contents read"
+
+--float 12.3456789000e10--
+string(%d) "contents read"
+
+--float -12.3456789000e10--
+string(%d) "contents read"
+
+--float .5--
+string(%d) "contents read"
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) "contents read"
+
+--lowercase null--
+string(%d) "contents read"
+
+--lowercase true--
+string(%d) "contents read"
+
+--lowercase false--
+string(%d) "contents read"
+
+--uppercase TRUE--
+string(%d) "contents read"
+
+--uppercase FALSE--
+string(%d) "contents read"
+
+--empty string DQ--
+string(%d) "contents read"
+
+--empty string SQ--
+string(%d) "contents read"
+
+--string DQ--
+string(%d) "contents read"
+
+--string SQ--
+string(%d) "contents read"
+
+--mixed case string--
+string(%d) "contents read"
+
+--heredoc--
+string(%d) "contents read"
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) "contents read"
+
+--unset var--
+string(%d) "contents read"
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation4.phpt b/ext/standard/tests/file/file_get_contents_variation4.phpt
new file mode 100644 (file)
index 0000000..3b494b4
--- /dev/null
@@ -0,0 +1,251 @@
+--TEST--
+Test file_get_contents() function : usage variation - different types for context.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar4.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+$fileRes = fopen(__FILE__,'r');
+$strContext = stream_context_create();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //non context resource
+      'file resource' => $fileRes,
+      
+      //valid stream context
+      'stream context' => $strContext,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file_get_contents($absFile, false, $value) );
+};
+
+unlink($absFile);
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 1--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 12345--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int -12345--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--float 10.5--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -10.5--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float 12.3456789000e10--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -12.3456789000e10--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float .5--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) "contents read"
+
+--lowercase null--
+string(%d) "contents read"
+
+--lowercase true--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--lowercase false--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase TRUE--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase FALSE--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--empty string DQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) "contents read"
+
+--unset var--
+string(%d) "contents read"
+
+--file resource--
+Error: 2 - file_get_contents(): supplied resource is not a valid Stream-Context resource, %s(%d)
+string(%d) "contents read"
+
+--stream context--
+string(%d) "contents read"
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation5.phpt b/ext/standard/tests/file/file_get_contents_variation5.phpt
new file mode 100644 (file)
index 0000000..9b40031
--- /dev/null
@@ -0,0 +1,222 @@
+--TEST--
+Test file_get_contents() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar5.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for offset
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file_get_contents($absFile, false, null, $value) );
+};
+
+unlink($absFile);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+string(%d) "contents read"
+
+--int 1--
+string(%d) "ontents read"
+
+--int 12345--
+string(%d) ""
+
+--int -12345--
+string(%d) "contents read"
+
+--float 10.5--
+string(3) "ead"
+
+--float -10.5--
+string(%d) "contents read"
+
+--float 12.3456789000e10--
+string(%d) %s
+
+--float -12.3456789000e10--
+string(%d) %s
+
+--float .5--
+string(%d) "contents read"
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) "contents read"
+
+--lowercase null--
+string(%d) "contents read"
+
+--lowercase true--
+string(12) "ontents read"
+
+--lowercase false--
+string(%d) "contents read"
+
+--uppercase TRUE--
+string(12) "ontents read"
+
+--uppercase FALSE--
+string(%d) "contents read"
+
+--empty string DQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_get_contents() expects parameter 4 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_get_contents() expects parameter 4 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 4 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 4 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) "contents read"
+
+--unset var--
+string(%d) "contents read"
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation6.phpt b/ext/standard/tests/file/file_get_contents_variation6.phpt
new file mode 100644 (file)
index 0000000..6795e01
--- /dev/null
@@ -0,0 +1,215 @@
+--TEST--
+Test file_get_contents() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar5.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for maxlen
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file_get_contents($absFile, false, null, 0, $value) );
+};
+
+unlink($absFile);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+string(%d) ""
+
+--int 1--
+string(%d) "c"
+
+--int 12345--
+string(%d) "contents read"
+
+--int -12345--
+Error: 2 - file_get_contents(): length must be greater than or equal to zero, %s(%d)
+bool(false)
+
+--float 10.5--
+string(%d) "contents r"
+
+--float -10.5--
+Error: 2 - file_get_contents(): length must be greater than or equal to zero, %s(%d)
+bool(false)
+
+--float .5--
+string(%d) ""
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) ""
+
+--lowercase null--
+string(%d) ""
+
+--lowercase true--
+string(%d) "c"
+
+--lowercase false--
+string(%d) ""
+
+--uppercase TRUE--
+string(%d) "c"
+
+--uppercase FALSE--
+string(%d) ""
+
+--empty string DQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 5 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 5 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) ""
+
+--unset var--
+string(%d) ""
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation7-win32.phpt b/ext/standard/tests/file/file_get_contents_variation7-win32.phpt
new file mode 100644 (file)
index 0000000..d350b4b
--- /dev/null
@@ -0,0 +1,115 @@
+--TEST--
+Test file_get_contents() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+$mainDir = "fileGetContentsVar7.dir";
+$subDir = "fileGetContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir\\",
+  "$absSubDir\\..\\".$subDir,
+  "$absSubDir\\\\..\\.\\".$subDir,
+  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+  "$absSubDir\\BADDIR",
+  
+  // relative paths
+  $mainDir."\\".$subDir,
+  $mainDir."\\\\".$subDir, 
+   $mainDir."\\\\\\".$subDir, 
+  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+  "BADDIR",  
+  
+  // unixifed path
+  $unixifiedDir,
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  var_dump(file_get_contents($dir."\\".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+
+-- Iteration 1 --
+string(%d) "contents read"
+
+-- Iteration 2 --
+string(%d) "contents read"
+
+-- Iteration 3 --
+string(%d) "contents read"
+
+-- Iteration 4 --
+string(%d) "contents read"
+
+-- Iteration 5 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir\fileGetContentsVar7Sub\..\\\fileGetContentsVar7Sub\\..\\..\fileGetContentsVar7Sub\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir\fileGetContentsVar7Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+string(%d) "contents read"
+
+-- Iteration 8 --
+string(%d) "contents read"
+
+-- Iteration 9 --
+string(%d) "contents read"
+
+-- Iteration 10 --
+string(%d) "contents read"
+
+-- Iteration 11 --
+
+Warning: file_get_contents(BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+string(%d) "contents read"
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation7.phpt b/ext/standard/tests/file/file_get_contents_variation7.phpt
new file mode 100644 (file)
index 0000000..c076857
--- /dev/null
@@ -0,0 +1,104 @@
+--TEST--
+Test file_get_contents() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+$mainDir = "fileGetContentsVar7.dir";
+$subDir = "fileGetContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+  
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  var_dump(file_get_contents($dir."/".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+
+-- Iteration 1 --
+string(%d) "contents read"
+
+-- Iteration 2 --
+string(%d) "contents read"
+
+-- Iteration 3 --
+string(%d) "contents read"
+
+-- Iteration 4 --
+string(%d) "contents read"
+
+-- Iteration 5 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir/fileGetContentsVar7Sub/..///fileGetContentsVar7Sub//..//../fileGetContentsVar7Sub/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir/fileGetContentsVar7Sub/BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+string(%d) "contents read"
+
+-- Iteration 8 --
+string(%d) "contents read"
+
+-- Iteration 9 --
+string(%d) "contents read"
+
+-- Iteration 10 --
+string(%d) "contents read"
+
+-- Iteration 11 --
+
+Warning: file_get_contents(BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation8-win32.phpt b/ext/standard/tests/file/file_get_contents_variation8-win32.phpt
new file mode 100644 (file)
index 0000000..4e67a33
--- /dev/null
@@ -0,0 +1,79 @@
+--TEST--
+Test file_get_contents() function : variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+/* An array of filenames */ 
+$names_arr = array(
+  /* Invalid args */ 
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  "\0",
+  array(),
+
+  /* prefix with path separator of a non existing directory*/
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  echo "-- Iteration $i --\n";
+  var_dump(file_get_contents($names_arr[$i]));
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+-- Iteration 0 --
+
+Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 1 --
+
+Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 2 --
+bool(false)
+-- Iteration 3 --
+bool(false)
+-- Iteration 4 --
+bool(false)
+-- Iteration 5 --
+
+Warning: file_get_contents( ): failed to open stream: Permission denied in %s on line %d
+bool(false)
+-- Iteration 6 --
+bool(false)
+-- Iteration 7 --
+
+Warning: file_get_contents() expects parameter 1 to be string, array given in %s on line %d
+NULL
+-- Iteration 8 --
+
+Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 9 --
+
+Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation8.phpt b/ext/standard/tests/file/file_get_contents_variation8.phpt
new file mode 100644 (file)
index 0000000..21b3d2b
--- /dev/null
@@ -0,0 +1,79 @@
+--TEST--
+Test file_get_contents() function : variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+/* An array of filenames */ 
+$names_arr = array(
+  /* Invalid args */ 
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  "\0",
+  array(),
+
+  /* prefix with path separator of a non existing directory*/
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  echo "-- Iteration $i --\n";
+  var_dump(file_get_contents($names_arr[$i]));
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+-- Iteration 0 --
+
+Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 1 --
+
+Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 2 --
+bool(false)
+-- Iteration 3 --
+bool(false)
+-- Iteration 4 --
+bool(false)
+-- Iteration 5 --
+
+Warning: file_get_contents( ): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 6 --
+bool(false)
+-- Iteration 7 --
+
+Warning: file_get_contents() expects parameter 1 to be string, array given in %s on line %d
+NULL
+-- Iteration 8 --
+
+Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 9 --
+
+Warning: file_get_contents(php/php): failed to open stream: %s directory in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_variation9.phpt b/ext/standard/tests/file/file_get_contents_variation9.phpt
new file mode 100644 (file)
index 0000000..988a310
--- /dev/null
@@ -0,0 +1,56 @@
+--TEST--
+Test file_get_contents() function : variation - linked files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+$filename = dirname(__FILE__).'/fileGetContentsVar9.tmp';
+$softlink = dirname(__FILE__).'/fileGetContentsVar9.SoftLink';
+$hardlink = dirname(__FILE__).'/fileGetContentsVar9.HardLink';
+$chainlink = dirname(__FILE__).'/fileGetContentsVar9.ChainLink';
+
+// create file
+$h = fopen($filename,"w");
+//Data should be more than the size of a link.
+for ($i = 1; $i <= 10; $i++) {
+   fwrite($h, "Here is a repeated amount of data");
+}
+fclose($h);
+
+// link files
+link($filename, $hardlink);
+symlink($filename, $softlink);
+symlink($softlink, $chainlink);
+
+// perform tests
+var_dump(file_get_contents($chainlink));
+var_dump(file_get_contents($softlink));
+var_dump(file_get_contents($hardlink));
+
+unlink($chainlink);
+unlink($softlink);
+unlink($hardlink);
+unlink($filename);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+string(330) "Here is a repeated amount of data%s"
+string(330) "Here is a repeated amount of data%s"
+string(330) "Here is a repeated amount of data%s"
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/file_put_contents_variation1.phpt b/ext/standard/tests/file/file_put_contents_variation1.phpt
new file mode 100644 (file)
index 0000000..35d1930
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Test file_put_contents() function : variation - test append flag
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : variation ***\n";
+
+$filename = "FilePutContentsVar1.tmp";
+
+$data = "The first string to write";
+$extra = ", followed by this";
+
+var_dump(file_put_contents($filename, $data));
+var_dump(file_put_contents($filename, $extra, FILE_APPEND));
+echo filesize($filename)."\n";
+readfile($filename);
+echo "\n";
+clearstatcache();
+file_put_contents($filename, $data);
+echo filesize($filename)."\n";
+readfile($filename);
+echo "\n";
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_put_contents() : variation ***
+int(25)
+int(18)
+43
+The first string to write, followed by this
+25
+The first string to write
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation2.phpt b/ext/standard/tests/file/file_put_contents_variation2.phpt
new file mode 100644 (file)
index 0000000..dccb967
--- /dev/null
@@ -0,0 +1,167 @@
+--TEST--
+Test file_put_contents() function : usage variation - different data types to write 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+$filename = 'fwriteVar5.tmp';
+
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for str
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      file_put_contents($filename, $value);
+      readfile($filename);
+};
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+--int 0--
+0
+--int 1--
+1
+--int 12345--
+12345
+--int -12345--
+-2345
+--float 10.5--
+10.5
+--float -10.5--
+-10.5
+--float 12.3456789000e10--
+123456789000
+--float -12.3456789000e10--
+-123456789000
+--float .5--
+0.5
+--empty array--
+
+--int indexed array--
+123
+--associative array--
+12
+--nested arrays--
+Error: 8 - Array to string conversion, %s(%d)
+Error: 8 - Array to string conversion, %s(%d)
+fooArrayArray
+--uppercase NULL--
+
+--lowercase null--
+
+--lowercase true--
+1
+--lowercase false--
+
+--uppercase TRUE--
+1
+--uppercase FALSE--
+
+--empty string DQ--
+
+--empty string SQ--
+
+--instance of classWithToString--
+Class A object
+--instance of classWithoutToString--
+
+--undefined var--
+
+--unset var--
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation3.phpt b/ext/standard/tests/file/file_put_contents_variation3.phpt
new file mode 100644 (file)
index 0000000..e16f640
--- /dev/null
@@ -0,0 +1,250 @@
+--TEST--
+Test file_put_contents() function : usage variation - different types for context.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FilePutContentsVar4.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+
+$fileRes = fopen(__FILE__,'r');
+$strContext = stream_context_create();
+
+$data = "data to write";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //non context resource
+      'file resource' => $fileRes,
+      
+      //valid stream context
+      'stream context' => $strContext,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file_put_contents($absFile, $data, null, $value) );
+};
+
+unlink($absFile);
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+--int 0--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--int 1--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--int 12345--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--int -12345--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--float 10.5--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float -10.5--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float 12.3456789000e10--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float -12.3456789000e10--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float .5--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--empty array--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+int(13)
+
+--lowercase null--
+int(13)
+
+--lowercase true--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--lowercase false--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase TRUE--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase FALSE--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--empty string DQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, object given, %s(%d)
+NULL
+
+--undefined var--
+int(13)
+
+--unset var--
+int(13)
+
+--file resource--
+Error: 2 - file_put_contents(): supplied resource is not a valid Stream-Context resource, %s(%d)
+int(13)
+
+--stream context--
+int(13)
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation4.phpt b/ext/standard/tests/file/file_put_contents_variation4.phpt
new file mode 100644 (file)
index 0000000..ef05a39
--- /dev/null
@@ -0,0 +1,54 @@
+--TEST--
+Test file_put_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : variation ***\n";
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "filePutContentsVar4.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "afile.txt";
+$firstFile = $dir1."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $firstFile, $filename;
+   file_put_contents($filename, "File in include path", FILE_USE_INCLUDE_PATH);
+   $line = file_get_contents($firstFile);
+   echo "$line\n";
+   unlink($firstFile);  
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_put_contents() : variation ***
+File in include path
+File in include path
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation5.phpt b/ext/standard/tests/file/file_put_contents_variation5.phpt
new file mode 100644 (file)
index 0000000..0d3daad
--- /dev/null
@@ -0,0 +1,59 @@
+--TEST--
+Test file_put_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : variation ***\n";
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "fileGetContentsVar7.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "readFileVar7.tmp";
+$scriptLocFile = dirname(__FILE__)."/".$filename;
+
+$newpath = "rubbish";
+set_include_path($newpath);
+runtest();
+$newpath = "";
+set_include_path($newpath);
+runtest();
+set_include_path(null);
+runtest();
+set_include_path(";;  ; ;c:\\rubbish");
+runtest();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $scriptLocFile, $filename;
+   file_put_contents($filename, "File in script location", FILE_USE_INCLUDE_PATH);
+   $line = file_get_contents($scriptLocFile);
+   echo "$line\n";
+   unlink($scriptLocFile);     
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_put_contents() : variation ***
+File in script location
+File in script location
+File in script location
+File in script location
+===DONE===
+
diff --git a/ext/standard/tests/file/file_put_contents_variation6.phpt b/ext/standard/tests/file/file_put_contents_variation6.phpt
new file mode 100644 (file)
index 0000000..d31308f
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+Test file_put_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : variation ***\n";
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "filePutContentsVar6.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "afile.txt";
+$firstFile = $dir1."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $firstFile, $filename;
+   file_put_contents($filename, "File in include path", FILE_USE_INCLUDE_PATH);
+   file_put_contents($filename, ". This was appended", FILE_USE_INCLUDE_PATH | FILE_APPEND);  
+   $line = file_get_contents($firstFile);
+   echo "$line\n";
+   unlink($firstFile);  
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_put_contents() : variation ***
+File in include path. This was appended
+File in include path. This was appended
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation7-win32.phpt b/ext/standard/tests/file/file_put_contents_variation7-win32.phpt
new file mode 100644 (file)
index 0000000..d7bfdf9
--- /dev/null
@@ -0,0 +1,130 @@
+--TEST--
+Test file_put_contents() function : usage variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+$mainDir = "filePutContentsVar7.dir";
+$subDir = "filePutContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+
+// Note invalid dirs in p8 result in (The system cannot find the path specified.)
+// rather than No Such File or Directory in php.net
+$allDirs = array(
+  // absolute paths
+  "$absSubDir\\",
+  "$absSubDir\\..\\".$subDir,
+  "$absSubDir\\\\..\\.\\".$subDir,
+  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+  "$absSubDir\\BADDIR",
+  
+  // relative paths
+  $mainDir."\\".$subDir,
+  $mainDir."\\\\".$subDir, 
+   $mainDir."\\\\\\".$subDir, 
+  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+  "BADDIR",  
+  
+  // unixifed path
+  $unixifiedDir,
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$data = "This was the written data";
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  $res = file_put_contents($dir."\\".$filename, ($data + $i));
+  if ($res !== false) {
+      $in = file_get_contents($absFile);
+      if ($in == ($data + $i)) {
+         echo "Data written correctly\n";
+      }
+      else {
+         echo "Data not written correctly or to correct place\n";
+      }
+      unlink($dir."/".$filename);
+  }
+  else {
+     echo "No data written\n";
+  }
+      
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+-- Iteration 1 --
+Data written correctly
+
+-- Iteration 2 --
+Data written correctly
+
+-- Iteration 3 --
+Data written correctly
+
+-- Iteration 4 --
+Data written correctly
+
+-- Iteration 5 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir\filePutContentsVar7Sub\..\\\filePutContentsVar7Sub\\..\\..\filePutContentsVar7Sub\FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 6 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir\filePutContentsVar7Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 7 --
+Data written correctly
+
+-- Iteration 8 --
+Data written correctly
+
+-- Iteration 9 --
+Data written correctly
+
+-- Iteration 10 --
+Data written correctly
+
+-- Iteration 11 --
+
+Warning: file_put_contents(BADDIR\FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 12 --
+Data written correctly
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation7.phpt b/ext/standard/tests/file/file_put_contents_variation7.phpt
new file mode 100644 (file)
index 0000000..5c8e5f3
--- /dev/null
@@ -0,0 +1,119 @@
+--TEST--
+Test file_put_contents() function : usage variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+$mainDir = "filePutContentsVar7.dir";
+$subDir = "filePutContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+
+// Note invalid dirs in p8 result in (The system cannot find the path specified.)
+// rather than No Such File or Directory in php.net
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+  
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$data = "This was the written data";
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  $res = file_put_contents($dir."/".$filename, ($data + $i));
+  if ($res !== false) {
+      $in = file_get_contents($absFile);
+      if ($in == ($data + $i)) {
+         echo "Data written correctly\n";
+      }
+      else {
+         echo "Data not written correctly or to correct place\n";
+      }
+      unlink($dir."/".$filename);
+  }
+  else {
+     echo "No data written\n";
+  }
+      
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+-- Iteration 1 --
+Data written correctly
+
+-- Iteration 2 --
+Data written correctly
+
+-- Iteration 3 --
+Data written correctly
+
+-- Iteration 4 --
+Data written correctly
+
+-- Iteration 5 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir/filePutContentsVar7Sub/..///filePutContentsVar7Sub//..//../filePutContentsVar7Sub/FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 6 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir/filePutContentsVar7Sub/BADDIR/FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 7 --
+Data written correctly
+
+-- Iteration 8 --
+Data written correctly
+
+-- Iteration 9 --
+Data written correctly
+
+-- Iteration 10 --
+Data written correctly
+
+-- Iteration 11 --
+
+Warning: file_put_contents(BADDIR/FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation8-win32.phpt b/ext/standard/tests/file/file_put_contents_variation8-win32.phpt
new file mode 100644 (file)
index 0000000..ce06019
--- /dev/null
@@ -0,0 +1,82 @@
+--TEST--
+Test file_put_contents() function : usage variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+/* An array of filenames */ 
+$names_arr = array(
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  "\0",
+  array(),
+
+  //the next 2 generate java messages so we don't replicate the php messages
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  echo "-- Iteration $i --\n";
+  $res = file_put_contents($names_arr[$i], "Some data");
+  if ($res !== false && $res != null) {
+     echo "$res bytes written to: $names_arr[$i]\n";
+     unlink($names_arr[$i]);
+  }
+  else {
+     echo "Failed to write data to: $names_arr[$i]\n";
+  }
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+-- Iteration 0 --
+9 bytes written to: -1
+-- Iteration 1 --
+9 bytes written to: 1
+-- Iteration 2 --
+Failed to write data to: 
+-- Iteration 3 --
+Failed to write data to: 
+-- Iteration 4 --
+Failed to write data to: 
+-- Iteration 5 --
+
+Warning: file_put_contents( ): failed to open stream: Permission denied in %s on line %d
+Failed to write data to:  
+-- Iteration 6 --
+Failed to write data to:%s
+-- Iteration 7 --
+
+Warning: file_put_contents() expects parameter 1 to be string, array given in %s on line %d
+Failed to write data to: Array
+-- Iteration 8 --
+
+Warning: file_put_contents(/no/such/file/dir): failed to open stream: %s in %s on line %d
+Failed to write data to: /no/such/file/dir
+-- Iteration 9 --
+
+Warning: file_put_contents(php/php): failed to open stream: %s in %s on line %d
+Failed to write data to: php/php
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation8.phpt b/ext/standard/tests/file/file_put_contents_variation8.phpt
new file mode 100644 (file)
index 0000000..6042ecf
--- /dev/null
@@ -0,0 +1,81 @@
+--TEST--
+Test file_put_contents() function : usage variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+/* An array of filenames */ 
+$names_arr = array(
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  //this one also generates a java message rather than our own so we don't replicate php message
+  "\0",
+  array(),
+
+  //the next 2 generate java messages so we don't replicate the php messages
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  echo "-- Iteration $i --\n";
+  $res = file_put_contents($names_arr[$i], "Some data");
+  if ($res !== false && $res != null) {
+     echo "$res bytes written to: $names_arr[$i]\n";
+     unlink($names_arr[$i]);
+  }
+  else {
+     echo "Failed to write data to: $names_arr[$i]\n";
+  }
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+-- Iteration 0 --
+9 bytes written to: -1
+-- Iteration 1 --
+9 bytes written to: 1
+-- Iteration 2 --
+Failed to write data to: 
+-- Iteration 3 --
+Failed to write data to: 
+-- Iteration 4 --
+Failed to write data to: 
+-- Iteration 5 --
+9 bytes written to:  
+-- Iteration 6 --
+Failed to write data to:%s
+-- Iteration 7 --
+
+Warning: file_put_contents() expects parameter 1 to be string, array given in %s on line %d
+Failed to write data to: Array
+-- Iteration 8 --
+
+Warning: file_put_contents(/no/such/file/dir): failed to open stream: %s in %s on line %d
+Failed to write data to: /no/such/file/dir
+-- Iteration 9 --
+
+Warning: file_put_contents(php/php): failed to open stream: %s in %s on line %d
+Failed to write data to: php/php
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation9.phpt b/ext/standard/tests/file/file_put_contents_variation9.phpt
new file mode 100644 (file)
index 0000000..7ad09c4
--- /dev/null
@@ -0,0 +1,70 @@
+--TEST--
+est file_put_contents() function : usage variation - linked files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+$filename = dirname(__FILE__).'/fileGetContentsVar9.tmp';
+$softlink = dirname(__FILE__).'/fileGetContentsVar9.SoftLink';
+$hardlink = dirname(__FILE__).'/fileGetContentsVar9.HardLink';
+$chainlink = dirname(__FILE__).'/fileGetContentsVar9.ChainLink';
+
+
+// link files even though it original file doesn't exist yet
+symlink($filename, $softlink);
+symlink($softlink, $chainlink);
+
+
+// perform tests
+run_test($chainlink);
+run_test($softlink);
+
+//can only create a hardlink if the file exists.
+file_put_contents($filename,"");
+link($filename, $hardlink); 
+run_test($hardlink);
+
+unlink($chainlink);
+unlink($softlink);
+unlink($hardlink);
+unlink($filename);
+
+
+function run_test($file) {
+    $data = "Here is some data";
+    $extra = ", more data";
+    var_dump(file_put_contents($file, $data));
+    var_dump(file_put_contents($file, $extra, FILE_APPEND));
+    readfile($file);
+    echo "\n";
+}
+
+
+echo "\n*** Done ***\n";
+?>
+--EXPECT--
+*** Testing file_put_contents() : usage variation ***
+int(17)
+int(11)
+Here is some data, more data
+int(17)
+int(11)
+Here is some data, more data
+int(17)
+int(11)
+Here is some data, more data
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_variation8-win32.phpt b/ext/standard/tests/file/file_variation8-win32.phpt
new file mode 100644 (file)
index 0000000..ca3be36
--- /dev/null
@@ -0,0 +1,142 @@
+--TEST--
+Test file() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file() : variation ***\n";
+$mainDir = "fileVar8.dir";
+$subDir = "fileVar8Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir\\",
+  "$absSubDir\\..\\".$subDir,
+  "$absSubDir\\\\..\\.\\".$subDir,
+  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+  "$absSubDir\\BADDIR",
+  
+  // relative paths
+  $mainDir."\\".$subDir,
+  $mainDir."\\\\".$subDir, 
+   $mainDir."\\\\\\".$subDir, 
+  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+  "BADDIR",  
+  
+  // unixifed path
+  $unixifiedDir,
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  var_dump(file($dir."\\".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 2 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 3 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 4 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 5 --
+
+Warning: file(%sfileVar8.dir\fileVar8Sub\..\\\fileVar8Sub\\..\\..\fileVar8Sub\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file(%sfileVar8.dir\fileVar8Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 8 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 9 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 10 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 11 --
+
+Warning: file(BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_variation8.phpt b/ext/standard/tests/file/file_variation8.phpt
new file mode 100644 (file)
index 0000000..be18fcb
--- /dev/null
@@ -0,0 +1,128 @@
+--TEST--
+Test file function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file() : variation ***\n";
+$mainDir = "fileVar8.dir";
+$subDir = "fileVar8Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+  
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  var_dump(file($dir."/".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 2 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 3 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 4 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 5 --
+
+Warning: file(%sfileVar8.dir/fileVar8Sub/..///fileVar8Sub//..//../fileVar8Sub/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file(%sfileVar8.dir/fileVar8Sub/BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 8 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 9 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 10 --
+array(1) {
+  [0]=>
+  string(13) "contents read"
+}
+
+-- Iteration 11 --
+
+Warning: file(BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/file_variation9.phpt b/ext/standard/tests/file/file_variation9.phpt
new file mode 100644 (file)
index 0000000..9ddd1e6
--- /dev/null
@@ -0,0 +1,89 @@
+--TEST--
+Test file function : variation - test various endings of a file
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing file() : variation ***\n";
+$testfile = dirname(__FILE__)."/fileVar9.txt";
+
+$contents = array(
+   "File ends on a single character\na",
+   "File ends on a new line\n",
+   "File ends on multiple newlines\n\n\n\n",
+   "File has\n\nmultiple lines and newlines\n\n",
+   "File has\r\nmultiple crlfs\n\r\n"
+   );
+
+@unlink($testfile);   
+foreach ($contents as $content) {
+    $h = fopen($testfile, "w");
+    fwrite($h, $content);
+    fclose($h);
+    var_dump(file($testfile));
+       unlink($testfile);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file() : variation ***
+array(2) {
+  [0]=>
+  string(32) "File ends on a single character
+"
+  [1]=>
+  string(1) "a"
+}
+array(1) {
+  [0]=>
+  string(24) "File ends on a new line
+"
+}
+array(4) {
+  [0]=>
+  string(31) "File ends on multiple newlines
+"
+  [1]=>
+  string(1) "
+"
+  [2]=>
+  string(1) "
+"
+  [3]=>
+  string(1) "
+"
+}
+array(4) {
+  [0]=>
+  string(9) "File has
+"
+  [1]=>
+  string(1) "
+"
+  [2]=>
+  string(28) "multiple lines and newlines
+"
+  [3]=>
+  string(1) "
+"
+}
+array(3) {
+  [0]=>
+  string(10) "File has
+"
+  [1]=>
+  string(15) "multiple crlfs
+"
+  [2]=>
+  string(2) "
+"
+}
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/filegroup_variation1.phpt b/ext/standard/tests/file/filegroup_variation1.phpt
new file mode 100644 (file)
index 0000000..ee76477
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Test filegroup() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Creating soft and hard links to a file and applying filegroup() on links */ 
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/filegroup_variation1.tmp", "w") );
+
+echo "*** Testing filegroup() with links ***\n";
+/* With symlink */
+symlink($file_path."/filegroup_variation1.tmp", $file_path."/filegroup_variation1_symlink.tmp");
+var_dump( filegroup($file_path."/filegroup_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/filegroup_variation1.tmp", $file_path."/filegroup_variation1_link.tmp");
+var_dump( filegroup($file_path."/filegroup_variation1_link.tmp") );  // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filegroup_variation1_symlink.tmp");
+unlink($file_path."/filegroup_variation1_link.tmp");
+unlink($file_path."/filegroup_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing filegroup() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/filegroup_variation2.phpt b/ext/standard/tests/file/filegroup_variation2.phpt
new file mode 100644 (file)
index 0000000..d5b7b1b
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+Test filegroup() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Testing filegroup() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/filegroup_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+  /* Invalid filenames */
+  -2.34555,
+  " ",
+  "",
+  TRUE,
+  FALSE,
+  NULL,
+  $file_handle,
+  
+  /* scalars */
+  1234,
+  0
+);
+   
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+  var_dump( filegroup($filename) );
+  clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filegroup_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: filegroup(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for   in %s on line %d
+bool(false)
+bool(false)
+
+Warning: filegroup(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: filegroup() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: filegroup(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/filegroup_variation3.phpt b/ext/standard/tests/file/filegroup_variation3.phpt
new file mode 100644 (file)
index 0000000..dd875a0
--- /dev/null
@@ -0,0 +1,81 @@
+--TEST--
+Test filegroup() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing filegroup() with different notations of file names ***\n";
+$dir_name = $file_path."/filegroup_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/filegroup_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+  "/filegroup_variation3/filegroup_variation3.tmp",
+
+  /* Testing a file trailing slash */
+  "/filegroup_variation3/filegroup_variation3.tmp/",
+
+  /* Testing file with double slashes */
+  "/filegroup_variation3//filegroup_variation3.tmp",
+  "//filegroup_variation3//filegroup_variation3.tmp",
+  "/filegroup_variation3/*.tmp",
+  "filegroup_variation3/filegroup*.tmp", 
+
+  /* Testing Binary safe */
+  "/filegroup_variation3/filegroup_variation3.tmp".chr(0),
+  "/filegroup_variation3/filegroup_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+  echo "- Iteration $count -\n";
+  var_dump( filegroup( $file_path."/".$file ) );
+  clearstatcache();
+  $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/filegroup_variation3";
+unlink($dir_name."/filegroup_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing filegroup() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: filegroup(): stat failed for %s//filegroup_variation3/filegroup_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: filegroup(): stat failed for %s//filegroup_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: filegroup(): stat failed for %s/filegroup_variation3/filegroup*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+int(%d)
+- Iteration 8 -
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation1.phpt b/ext/standard/tests/file/fileinode_variation1.phpt
new file mode 100644 (file)
index 0000000..d251cc3
--- /dev/null
@@ -0,0 +1,48 @@
+--TEST--
+Test fileinode() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* 
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+/* Creating soft and hard links to a file and applying fileinode() on links */ 
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/fileinode_variation1.tmp", "w") );
+
+echo "*** Testing fileinode() with links ***\n";
+/* With symlink */
+symlink($file_path."/fileinode_variation1.tmp", $file_path."/fileinode_variation1_symlink.tmp");
+var_dump( fileinode($file_path."/fileinode_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/fileinode_variation1.tmp", $file_path."/fileinode_variation1_link.tmp");
+var_dump( fileinode($file_path."/fileinode_variation1_link.tmp") );  // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileinode_variation1_symlink.tmp");
+unlink($file_path."/fileinode_variation1_link.tmp");
+unlink($file_path."/fileinode_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileinode() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation2.phpt b/ext/standard/tests/file/fileinode_variation2.phpt
new file mode 100644 (file)
index 0000000..7d71ef4
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+Test fileinode() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* 
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+/* Testing fileinode() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/fileinode_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+  /* Invalid filenames */
+  -2.34555,
+  " ",
+  "",
+  TRUE,
+  FALSE,
+  NULL,
+  $file_handle,
+  
+  /* scalars */
+  1234,
+  0
+);
+   
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+  var_dump( fileinode($filename) );
+  clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileinode_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: fileinode(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: fileinode(): stat failed for   in %s on line %d
+bool(false)
+bool(false)
+
+Warning: fileinode(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fileinode() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: fileinode(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: fileinode(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileinode_variation3.phpt b/ext/standard/tests/file/fileinode_variation3.phpt
new file mode 100644 (file)
index 0000000..c81b573
--- /dev/null
@@ -0,0 +1,82 @@
+--TEST--
+Test fileinode() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* 
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fileinode() with different notations of file names ***\n";
+$dir_name = $file_path."/fileinode_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/fileinode_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+  "/fileinode_variation3/fileinode_variation3.tmp",
+
+  /* Testing a file trailing slash */
+  "/fileinode_variation3/fileinode_variation3.tmp/",
+
+  /* Testing file with double slashes */
+  "/fileinode_variation3//fileinode_variation3.tmp",
+  "//fileinode_variation3//fileinode_variation3.tmp",
+  "/fileinode_variation3/*.tmp",
+  "fileinode_variation3/fileinode*.tmp", 
+
+  /* Testing Binary safe */
+  "/fileinode_variation3/fileinode_variation3.tmp".chr(0),
+  "/fileinode_variation3/fileinode_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+  echo "- Iteration $count -\n";
+  var_dump( fileinode( $file_path."/".$file ) );
+  clearstatcache();
+  $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/fileinode_variation3";
+unlink($dir_name."/fileinode_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing fileinode() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: fileinode(): stat failed for %s//fileinode_variation3/fileinode_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: fileinode(): stat failed for %s//fileinode_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: fileinode(): stat failed for %s/fileinode_variation3/fileinode*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+int(%d)
+- Iteration 8 -
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileowner_variation1.phpt b/ext/standard/tests/file/fileowner_variation1.phpt
new file mode 100644 (file)
index 0000000..b70ac36
--- /dev/null
@@ -0,0 +1,48 @@
+--TEST--
+Test fileowner() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ *              FALSE in case of an error.
+ */
+
+/* Creating soft and hard links to a file and applying fileowner() on links */ 
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/fileowner_variation1.tmp", "w") );
+
+echo "*** Testing fileowner() with links ***\n";
+/* With symlink */
+symlink($file_path."/fileowner_variation1.tmp", $file_path."/fileowner_variation1_symlink.tmp");
+var_dump( fileowner($file_path."/fileowner_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/fileowner_variation1.tmp", $file_path."/fileowner_variation1_link.tmp");
+var_dump( fileowner($file_path."/fileowner_variation1_link.tmp") );  // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileowner_variation1_symlink.tmp");
+unlink($file_path."/fileowner_variation1_link.tmp");
+unlink($file_path."/fileowner_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileowner() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileowner_variation2.phpt b/ext/standard/tests/file/fileowner_variation2.phpt
new file mode 100644 (file)
index 0000000..07eb6ec
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+Test fileowner() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ *              FALSE in case of an error.
+ */
+
+/* Testing fileowner() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/fileowner_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+  /* Invalid filenames */
+  -2.34555,
+  " ",
+  "",
+  TRUE,
+  FALSE,
+  NULL,
+  $file_handle,
+  
+  /* scalars */
+  1234,
+  0
+);
+   
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+  var_dump( fileowner($filename) );
+  clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileowner_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: fileowner(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for   in %s on line %d
+bool(false)
+bool(false)
+
+Warning: fileowner(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fileowner() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: fileowner(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileowner_variation3.phpt b/ext/standard/tests/file/fileowner_variation3.phpt
new file mode 100644 (file)
index 0000000..2a322b6
--- /dev/null
@@ -0,0 +1,82 @@
+--TEST--
+Test fileowner() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ *              FALSE in case of an error.
+ */
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fileowner() with different notations of file names ***\n";
+$dir_name = $file_path."/fileowner_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/fileowner_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+  "/fileowner_variation3/fileowner_variation3.tmp",
+
+  /* Testing a file trailing slash */
+  "/fileowner_variation3/fileowner_variation3.tmp/",
+
+  /* Testing file with double slashes */
+  "/fileowner_variation3//fileowner_variation3.tmp",
+  "//fileowner_variation3//fileowner_variation3.tmp",
+  "/fileowner_variation3/*.tmp",
+  "fileowner_variation3/fileowner*.tmp", 
+
+  /* Testing Binary safe */
+  "/fileowner_variation3/fileowner_variation3.tmp".chr(0),
+  "/fileowner_variation3/fileowner_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+  echo "- Iteration $count -\n";
+  var_dump( fileowner( $file_path."/".$file ) );
+  clearstatcache();
+  $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/fileowner_variation3";
+unlink($dir_name."/fileowner_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing fileowner() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: fileowner(): stat failed for %s//fileowner_variation3/fileowner_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: fileowner(): stat failed for %s//fileowner_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: fileowner(): stat failed for %s/fileowner_variation3/fileowner*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+int(%d)
+- Iteration 8 -
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileperms_variation1.phpt b/ext/standard/tests/file/fileperms_variation1.phpt
new file mode 100644 (file)
index 0000000..e90cf87
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Test fileperms() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: int fileperms ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Creating soft and hard links to a file and applying fileperms() on links */ 
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/fileperms_variation1.tmp", "w") );
+
+echo "*** Testing fileperms() with links ***\n";
+/* With symlink */
+symlink($file_path."/fileperms_variation1.tmp", $file_path."/fileperms_variation1_symlink.tmp");
+var_dump( fileperms($file_path."/fileperms_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/fileperms_variation1.tmp", $file_path."/fileperms_variation1_link.tmp");
+var_dump( fileperms($file_path."/fileperms_variation1_link.tmp") );  // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileperms_variation1_symlink.tmp");
+unlink($file_path."/fileperms_variation1_link.tmp");
+unlink($file_path."/fileperms_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileperms() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileperms_variation2.phpt b/ext/standard/tests/file/fileperms_variation2.phpt
new file mode 100644 (file)
index 0000000..ad809a1
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+Test fileperms() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileperms ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Testing fileperms() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/fileperms_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+  /* Invalid filenames */
+  -2.34555,
+  " ",
+  "",
+  TRUE,
+  FALSE,
+  NULL,
+  $file_handle,
+  
+  /* scalars */
+  1234,
+  0
+);
+   
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+  var_dump( fileperms($filename) );
+  clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileperms_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: fileperms(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: fileperms(): stat failed for   in %s on line %d
+bool(false)
+bool(false)
+
+Warning: fileperms(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fileperms() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: fileperms(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: fileperms(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileperms_variation3.phpt b/ext/standard/tests/file/fileperms_variation3.phpt
new file mode 100644 (file)
index 0000000..38101e3
--- /dev/null
@@ -0,0 +1,81 @@
+--TEST--
+Test fileperms() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileperms ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fileperms() with different notations of file names ***\n";
+$dir_name = $file_path."/fileperms_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/fileperms_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+  "/fileperms_variation3/fileperms_variation3.tmp",
+
+  /* Testing a file trailing slash */
+  "/fileperms_variation3/fileperms_variation3.tmp/",
+
+  /* Testing file with double slashes */
+  "/fileperms_variation3//fileperms_variation3.tmp",
+  "//fileperms_variation3//fileperms_variation3.tmp",
+  "/fileperms_variation3/*.tmp",
+  "fileperms_variation3/fileperms*.tmp", 
+
+  /* Testing Binary safe */
+  "/fileperms_variation3/fileperms_variation3.tmp".chr(0),
+  "/fileperms_variation3/fileperms_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+  echo "- Iteration $count -\n";
+  var_dump( fileperms( $file_path."/".$file ) );
+  clearstatcache();
+  $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/fileperms_variation3";
+unlink($dir_name."/fileperms_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing fileperms() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: fileperms(): stat failed for %s//fileperms_variation3/fileperms_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: fileperms(): stat failed for %s//fileperms_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: fileperms(): stat failed for %s/fileperms_variation3/fileperms*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+int(%d)
+- Iteration 8 -
+int(%d)
+
+*** Done ***
index a8a4d4e7f535e82fb66243efba70aad47d5be37d..0a490cd7e6a96e542f04f223f6d5fad3582f2bce 100644 (file)
@@ -3,7 +3,7 @@ Test filesize() function: usage variations - size of files
 --SKIPIF--
 <?php
 if (substr(PHP_OS, 0, 3) == 'WIN') {
-    die('skip only valid for Linux');
+     die('skip Not valid on Windows');
 }
 --FILE--
 <?php
@@ -32,14 +32,14 @@ echo "Done\n";
 --EXPECTF--
 *** Testing filesize(): usage variations ***
 *** Checking filesize() with different size of files ***
-int(1024)
-int(1025024)
-int(2049024)
-int(3073024)
-int(4097024)
-int(5121024)
-int(6145024)
-int(7169024)
-int(8193024)
-int(9217024)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
 Done
diff --git a/ext/standard/tests/file/filesize_variation5.phpt b/ext/standard/tests/file/filesize_variation5.phpt
new file mode 100644 (file)
index 0000000..638f8ba
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Test filesize() function: usage variations - size of files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* 
+ * Prototype   : int filesize ( string $filename );
+ * Description : Returns the size of the file in bytes, or FALSE 
+ *               (and generates an error of level E_WARNING) in case of an error.
+ */
+
+echo "*** Testing filesize(): usage variations ***\n"; 
+
+/* null, false, "", " " */
+var_dump( filesize(NULL) );
+var_dump( filesize(false) );
+var_dump( filesize('') );
+var_dump( filesize(' ') );
+var_dump( filesize('|') );
+echo "*** Done ***\n";
+?>
+--EXPECTF--    
+*** Testing filesize(): usage variations ***
+bool(false)
+bool(false)
+bool(false)
+
+Warning: filesize(): stat failed for   in %s on line %d
+bool(false)
+
+Warning: filesize(): stat failed for | in %s on line %d
+bool(false)
+*** Done ***
diff --git a/ext/standard/tests/file/filetype_variation2.phpt b/ext/standard/tests/file/filetype_variation2.phpt
new file mode 100644 (file)
index 0000000..9588575
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+Test filetype() function: Variations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no /dev on Windows');
+}
+?>
+--FILE--
+<?php
+/*
+Prototype: string filetype ( string $filename );
+Description: Returns the type of the file. Possible values are fifo, char,
+             dir, block, link, file, and unknown. 
+*/
+
+echo "*** Testing filetype() with various types ***\n";
+echo "-- Checking for char --\n";
+print( filetype("/dev/console") )."\n";
+
+echo "-- Checking for block --\n";
+//we have cheated in our mac build by creating a ram0 block device.
+print( filetype("/dev/ram0") )."\n";
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing filetype() with various types ***
+-- Checking for char --
+char
+-- Checking for block --
+block
+
+*** Done ***
index 077e5430ba5fcc222fdc3d87e96010cc352fb068..fe61e2a173a718fb65fbeeaa938e496d1a6fd257 100644 (file)
@@ -94,7 +94,7 @@ NULL
 Warning: flock() expects parameter 2 to be long, string given in %s on line %d
 NULL
 
-Warning: flock(): 6 is not a valid stream resource in %s on line %d
+Warning: flock(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: flock() expects parameter 1 to be resource, string given in %s on line %d
index af67ab402a9a160a2198ea4442869028b9e43729..339f10cb9f32b1d90e6efce1c8b696ba8ecd9b82 100644 (file)
 --TEST--
-Test flock() function: Variations
+Test flock() function: usage variations
 --FILE--
 <?php
 /* 
 Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
-Description: PHP supports a portable way of locking complete files 
-  in an advisory way
+Description: PHP supports a portable way of locking complete files in an advisory way
 */
 
-echo "*** Testing flock() fun with the various operation and 
-            wouldblock values                                ***\n";
-$file = dirname(__FILE__)."/flock.tmp";
-$fp = fopen($file, "w");
+echo "*** Test flock() function: with the operations given as numeric values ***\n";
 
-/* array of operatons */
-$operations = array(
-  LOCK_SH,
-  LOCK_EX,
-  LOCK_SH|LOCK_NB,
-  LOCK_EX|LOCK_NB,
-  LOCK_SH|LOCK_EX,
-  LOCK_UN,
-  1, 
-  2,
-  2.234,
-  TRUE
-);
+$filename = dirname(__FILE__)."/flock_variation.tmp";
+$file_handle = fopen($filename, "w");
 
-/* array of wouldblocks */
-$wouldblocks = array(
-  0,
-  1,
-  2,
-  1.234,
-  TRUE,
-  FALSE,
-  NULL,
-  array(1,2,3),
-  array(),
-  "string",
-  "",
-  /* binary input */
-  b"string",
-  b"",
-  "\0"
+/* array of operations */
+$operations = array(
+  1,  //nothing but LOCK_SH
+  2,  //nothing but LOCK_EX
+  2.234,  //nothing but LOCK_EX
+  TRUE  //nothing but LOCK_SH
 );
 
 $i = 0;
 foreach($operations as $operation) {
-  echo "--- Outer iteration $i ---\n";
-  var_dump(flock($fp, $operation));
-  $j = 0;
-  foreach($wouldblocks as $wouldblock) {
-    echo "-- Inner iteration $j in $i --\n";
-    var_dump(flock($fp, $operation, $wouldblock));
-    $j++;
-  }
+  var_dump(flock($file_handle, $operation));
+  var_dump(flock($file_handle, 3));  //nothing but LOCK_UN
   $i++;
 }
 
-fclose($fp);
-@unlink($file);
+fclose($file_handle);
+unlink($filename);
 
-echo "\n*** Done ***\n";
+echo "*** Done ***\n";
 ?>
 --EXPECTF--    
-*** Testing flock() fun with the various operation and 
-            wouldblock values                                ***
---- Outer iteration 0 ---
-bool(true)
--- Inner iteration 0 in 0 --
-bool(true)
--- Inner iteration 1 in 0 --
-bool(true)
--- Inner iteration 2 in 0 --
-bool(true)
--- Inner iteration 3 in 0 --
-bool(true)
--- Inner iteration 4 in 0 --
-bool(true)
--- Inner iteration 5 in 0 --
-bool(true)
--- Inner iteration 6 in 0 --
-bool(true)
--- Inner iteration 7 in 0 --
-bool(true)
--- Inner iteration 8 in 0 --
-bool(true)
--- Inner iteration 9 in 0 --
-bool(true)
--- Inner iteration 10 in 0 --
-bool(true)
--- Inner iteration 11 in 0 --
-bool(true)
--- Inner iteration 12 in 0 --
-bool(true)
--- Inner iteration 13 in 0 --
-bool(true)
---- Outer iteration 1 ---
-bool(true)
--- Inner iteration 0 in 1 --
-bool(true)
--- Inner iteration 1 in 1 --
-bool(true)
--- Inner iteration 2 in 1 --
-bool(true)
--- Inner iteration 3 in 1 --
-bool(true)
--- Inner iteration 4 in 1 --
-bool(true)
--- Inner iteration 5 in 1 --
-bool(true)
--- Inner iteration 6 in 1 --
-bool(true)
--- Inner iteration 7 in 1 --
-bool(true)
--- Inner iteration 8 in 1 --
-bool(true)
--- Inner iteration 9 in 1 --
-bool(true)
--- Inner iteration 10 in 1 --
-bool(true)
--- Inner iteration 11 in 1 --
-bool(true)
--- Inner iteration 12 in 1 --
-bool(true)
--- Inner iteration 13 in 1 --
-bool(true)
---- Outer iteration 2 ---
-bool(true)
--- Inner iteration 0 in 2 --
-bool(true)
--- Inner iteration 1 in 2 --
-bool(true)
--- Inner iteration 2 in 2 --
-bool(true)
--- Inner iteration 3 in 2 --
-bool(true)
--- Inner iteration 4 in 2 --
-bool(true)
--- Inner iteration 5 in 2 --
-bool(true)
--- Inner iteration 6 in 2 --
-bool(true)
--- Inner iteration 7 in 2 --
-bool(true)
--- Inner iteration 8 in 2 --
-bool(true)
--- Inner iteration 9 in 2 --
-bool(true)
--- Inner iteration 10 in 2 --
-bool(true)
--- Inner iteration 11 in 2 --
-bool(true)
--- Inner iteration 12 in 2 --
-bool(true)
--- Inner iteration 13 in 2 --
-bool(true)
---- Outer iteration 3 ---
-bool(true)
--- Inner iteration 0 in 3 --
-bool(true)
--- Inner iteration 1 in 3 --
-bool(true)
--- Inner iteration 2 in 3 --
-bool(true)
--- Inner iteration 3 in 3 --
-bool(true)
--- Inner iteration 4 in 3 --
-bool(true)
--- Inner iteration 5 in 3 --
-bool(true)
--- Inner iteration 6 in 3 --
-bool(true)
--- Inner iteration 7 in 3 --
-bool(true)
--- Inner iteration 8 in 3 --
-bool(true)
--- Inner iteration 9 in 3 --
-bool(true)
--- Inner iteration 10 in 3 --
-bool(true)
--- Inner iteration 11 in 3 --
-bool(true)
--- Inner iteration 12 in 3 --
-bool(true)
--- Inner iteration 13 in 3 --
-bool(true)
---- Outer iteration 4 ---
-bool(true)
--- Inner iteration 0 in 4 --
-bool(true)
--- Inner iteration 1 in 4 --
-bool(true)
--- Inner iteration 2 in 4 --
-bool(true)
--- Inner iteration 3 in 4 --
-bool(true)
--- Inner iteration 4 in 4 --
-bool(true)
--- Inner iteration 5 in 4 --
-bool(true)
--- Inner iteration 6 in 4 --
-bool(true)
--- Inner iteration 7 in 4 --
-bool(true)
--- Inner iteration 8 in 4 --
-bool(true)
--- Inner iteration 9 in 4 --
+*** Test flock() function: with the operations given as numeric values ***
 bool(true)
--- Inner iteration 10 in 4 --
 bool(true)
--- Inner iteration 11 in 4 --
 bool(true)
--- Inner iteration 12 in 4 --
 bool(true)
--- Inner iteration 13 in 4 --
 bool(true)
---- Outer iteration 5 ---
 bool(true)
--- Inner iteration 0 in 5 --
 bool(true)
--- Inner iteration 1 in 5 --
 bool(true)
--- Inner iteration 2 in 5 --
-bool(true)
--- Inner iteration 3 in 5 --
-bool(true)
--- Inner iteration 4 in 5 --
-bool(true)
--- Inner iteration 5 in 5 --
-bool(true)
--- Inner iteration 6 in 5 --
-bool(true)
--- Inner iteration 7 in 5 --
-bool(true)
--- Inner iteration 8 in 5 --
-bool(true)
--- Inner iteration 9 in 5 --
-bool(true)
--- Inner iteration 10 in 5 --
-bool(true)
--- Inner iteration 11 in 5 --
-bool(true)
--- Inner iteration 12 in 5 --
-bool(true)
--- Inner iteration 13 in 5 --
-bool(true)
---- Outer iteration 6 ---
-bool(true)
--- Inner iteration 0 in 6 --
-bool(true)
--- Inner iteration 1 in 6 --
-bool(true)
--- Inner iteration 2 in 6 --
-bool(true)
--- Inner iteration 3 in 6 --
-bool(true)
--- Inner iteration 4 in 6 --
-bool(true)
--- Inner iteration 5 in 6 --
-bool(true)
--- Inner iteration 6 in 6 --
-bool(true)
--- Inner iteration 7 in 6 --
-bool(true)
--- Inner iteration 8 in 6 --
-bool(true)
--- Inner iteration 9 in 6 --
-bool(true)
--- Inner iteration 10 in 6 --
-bool(true)
--- Inner iteration 11 in 6 --
-bool(true)
--- Inner iteration 12 in 6 --
-bool(true)
--- Inner iteration 13 in 6 --
-bool(true)
---- Outer iteration 7 ---
-bool(true)
--- Inner iteration 0 in 7 --
-bool(true)
--- Inner iteration 1 in 7 --
-bool(true)
--- Inner iteration 2 in 7 --
-bool(true)
--- Inner iteration 3 in 7 --
-bool(true)
--- Inner iteration 4 in 7 --
-bool(true)
--- Inner iteration 5 in 7 --
-bool(true)
--- Inner iteration 6 in 7 --
-bool(true)
--- Inner iteration 7 in 7 --
-bool(true)
--- Inner iteration 8 in 7 --
-bool(true)
--- Inner iteration 9 in 7 --
-bool(true)
--- Inner iteration 10 in 7 --
-bool(true)
--- Inner iteration 11 in 7 --
-bool(true)
--- Inner iteration 12 in 7 --
-bool(true)
--- Inner iteration 13 in 7 --
-bool(true)
---- Outer iteration 8 ---
-bool(true)
--- Inner iteration 0 in 8 --
-bool(true)
--- Inner iteration 1 in 8 --
-bool(true)
--- Inner iteration 2 in 8 --
-bool(true)
--- Inner iteration 3 in 8 --
-bool(true)
--- Inner iteration 4 in 8 --
-bool(true)
--- Inner iteration 5 in 8 --
-bool(true)
--- Inner iteration 6 in 8 --
-bool(true)
--- Inner iteration 7 in 8 --
-bool(true)
--- Inner iteration 8 in 8 --
-bool(true)
--- Inner iteration 9 in 8 --
-bool(true)
--- Inner iteration 10 in 8 --
-bool(true)
--- Inner iteration 11 in 8 --
-bool(true)
--- Inner iteration 12 in 8 --
-bool(true)
--- Inner iteration 13 in 8 --
-bool(true)
---- Outer iteration 9 ---
-bool(true)
--- Inner iteration 0 in 9 --
-bool(true)
--- Inner iteration 1 in 9 --
-bool(true)
--- Inner iteration 2 in 9 --
-bool(true)
--- Inner iteration 3 in 9 --
-bool(true)
--- Inner iteration 4 in 9 --
-bool(true)
--- Inner iteration 5 in 9 --
-bool(true)
--- Inner iteration 6 in 9 --
-bool(true)
--- Inner iteration 7 in 9 --
-bool(true)
--- Inner iteration 8 in 9 --
-bool(true)
--- Inner iteration 9 in 9 --
-bool(true)
--- Inner iteration 10 in 9 --
-bool(true)
--- Inner iteration 11 in 9 --
-bool(true)
--- Inner iteration 12 in 9 --
-bool(true)
--- Inner iteration 13 in 9 --
-bool(true)
-
 *** Done ***
diff --git a/ext/standard/tests/file/flock_variation1.phpt b/ext/standard/tests/file/flock_variation1.phpt
new file mode 100644 (file)
index 0000000..3e3f510
--- /dev/null
@@ -0,0 +1,62 @@
+--TEST--
+Test flock() function: usage variations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. not for Windows');
+}
+if (function_exists("pcntl_fork") == FALSE) {
+    die('skip.. no pcntl_fork()');
+}
+?> 
+--FILE--
+<?php
+/* 
+Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
+Description: PHP supports a portable way of locking complete files in an advisory way
+*/
+
+echo "*** Test flock() function: with the operations given as numeric values ***\n";
+
+$filename = dirname(__FILE__)."/flock_variation1.tmp";
+$file_handle = fopen($filename, "w");
+fwrite($file_handle, str_repeat("Hello2World", 10) );
+fclose($file_handle);
+
+$file_read = fopen($filename, "r");
+
+$pid = pcntl_fork();
+echo "-- child process is created --\n";
+if ($pid == -1) {
+  die('could not fork');
+} else if ($pid) {
+    echo "-- Trying to get the Reader Lock --\n";
+    if( flock($file_read, LOCK_EX) ) {
+      echo "-- Got Lock --\n";
+      sleep(5);
+      flock($file_read, LOCK_UN);
+    }
+    else
+       echo "-- Couldn't get the Lock --\n";
+} else {
+    echo "-- Trying to get the Writer Lock --\n";
+    if( flock($file_read, LOCK_EX) ) {
+      echo "-- Got Lock --\n";
+      flock($file_read, LOCK_UN);
+    }
+    else
+       echo "-- Couldn't get the Lock --\n";
+
+}
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+fclose($file_read);
+fclose($file_write);
+unlink($filename);
+?>
+--EXPECTF--    
diff --git a/ext/standard/tests/file/fopen_include_path.inc b/ext/standard/tests/file/fopen_include_path.inc
new file mode 100644 (file)
index 0000000..7d6723a
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+$pwd = getcwd();
+$f = basename(__FILE__);
+$dir1 = $pwd."/".$f.".dir1";
+$dir2 = $pwd."/".$f.".dir2";
+$dir3 = $pwd."/".$f.".dir3";
+//invalid directory
+$dir4 = $pwd."/".$f.".dir4";
+$newdirs = array($dir1, $dir2, $dir3);
+
+$reldirs = array("dir1", "dir2", "dir3");
+
+function generate_next_rel_path() {
+       global $reldirs;
+       //create the include directory structure
+       $pathSep = ":";
+       $newIncludePath = "";
+       if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+          $pathSep = ";";
+       }
+       foreach($reldirs as $newdir) {
+          $newIncludePath .= $newdir.$pathSep;
+       }
+       return "dir4".$pathSep . $newIncludePath;
+}
+
+function generate_next_path() {
+       global $newdirs, $dir4;
+       //create the include directory structure
+       $pathSep = ":";
+       $newIncludePath = "";
+       if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+          $pathSep = ";";
+       }
+       foreach($newdirs as $newdir) {
+          $newIncludePath .= $newdir.$pathSep;
+       }
+       return $dir4.$pathSep . $newIncludePath;
+}
+
+
+function create_include_path() {
+
+       global $newdirs;
+       //create the include directory structure
+       $pathSep = ":";
+       $newIncludePath = "";
+       if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+          $pathSep = ";";
+       }
+       foreach($newdirs as $newdir) {
+          mkdir($newdir);
+          $newIncludePath .= $newdir.$pathSep;
+       }
+       return $newIncludePath;
+}
+
+function relative_include_path() {
+
+       global $reldirs;
+       //create the include directory structure
+       $pathSep = ":";
+       $newIncludePath = "";
+       if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+          $pathSep = ";";
+       }
+       foreach($reldirs as $newdir) {
+          mkdir($newdir);
+          $newIncludePath .= $newdir.$pathSep;
+       }
+       return $newIncludePath;
+}
+
+
+function teardown_include_path() {
+
+       global $newdirs;
+       // remove the directory structure
+       foreach($newdirs as $newdir) {
+          rmdir($newdir);
+       }
+}
+
+function teardown_relative_path() {
+
+       global $reldirs;
+       // remove the directory structure
+       foreach($reldirs as $newdir) {
+          rmdir($newdir);
+       }
+}
+?>
\ No newline at end of file
diff --git a/ext/standard/tests/file/fopen_variation10-win32.phpt b/ext/standard/tests/file/fopen_variation10-win32.phpt
new file mode 100644 (file)
index 0000000..10184b2
--- /dev/null
@@ -0,0 +1,148 @@
+--TEST--
+Test fopen() function : variation: interesting paths, no use include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testdir = dirname(__FILE__).'/fopen10.tmpDir';
+$rootdir = 'fopen10.tmpdirTwo';
+mkdir($testdir);
+mkdir('c:\\'.$rootdir);
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
+
+$paths = array('c:\\', 
+               'c:', 
+               'c', 
+               '\\', 
+               '/', 
+               'c:'.$rootdir, 
+               'c:adir', 
+               'c:\\/', 
+               'c:\\'.$rootdir.'\\/',
+               'c:\\'.$rootdir.'\\', 
+               'c:\\'.$rootdir.'/',
+               $unixifiedDir, 
+               '/sortout');
+
+$file = "fopen_variation10.tmp";
+$firstfile = 'c:\\'.$rootdir.'\\'.$file;
+$secondfile = $testdir.'\\'.$file;
+$thirdfile = 'c:\\'.$file;
+
+$h = fopen($firstfile, 'w');
+fwrite($h, "file in $rootdir");
+fclose($h);
+
+$h = fopen($secondfile, 'w');
+fwrite($h, "file in fopen10.tmpDir");
+fclose($h);
+
+$h = fopen($thirdfile, 'w');
+fwrite($h, "file in root");
+fclose($h);
+
+foreach($paths as $path) {
+      echo "\n--$path--\n";
+      $toFind = $path.'\\'.$file;
+         $h = fopen($toFind, 'r');
+         if ($h === false) {
+            echo "file not opened for read\n";
+         }
+         else {
+            fpassthru($h);
+            echo "\n";
+         }
+         fclose($h);
+};
+
+unlink($firstfile);
+unlink($secondfile);
+unlink($thirdfile);
+rmdir($testdir);
+rmdir('c:\\'.$rootdir);
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+
+--c:\--
+file in root
+
+--c:--
+file in root
+
+--c--
+
+Warning: fopen(c\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--\--
+
+Warning: fopen(\\fopen_variation10.tmp): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--/--
+
+Warning: fopen(/\fopen_variation10.tmp): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:fopen10.tmpdirTwo--
+
+Warning: fopen(c:fopen10.tmpdirTwo\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:adir--
+
+Warning: fopen(c:adir\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:\/--
+file in root
+
+--c:\fopen10.tmpdirTwo\/--
+file in fopen10.tmpdirTwo
+
+--c:\fopen10.tmpdirTwo\--
+file in fopen10.tmpdirTwo
+
+--c:\fopen10.tmpdirTwo/--
+file in fopen10.tmpdirTwo
+
+--%s/fopen10.tmpDir--
+file in fopen10.tmpDir
+
+--/sortout--
+
+Warning: fopen(/sortout\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation11-win32.phpt b/ext/standard/tests/file/fopen_variation11-win32.phpt
new file mode 100644 (file)
index 0000000..23a557a
--- /dev/null
@@ -0,0 +1,147 @@
+--TEST--
+Test fopen() function : variation: interesting paths, use include path = true
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testdir = dirname(__FILE__).'/fopen11.tmpDir';
+$rootdir = 'fopen11.tmpdirTwo';
+mkdir($testdir);
+mkdir('c:\\'.$rootdir);
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
+
+$paths = array('c:\\', 
+               'c:', 
+               'c', 
+               '\\', 
+               '/', 
+               'c:'.$rootdir, 
+               'c:adir', 
+               'c:\\/', 
+               'c:\\'.$rootdir.'\\/',
+               'c:\\'.$rootdir.'\\', 
+               'c:\\'.$rootdir.'/',
+               $unixifiedDir, 
+               '/sortout');
+
+$file = "fopen_variation11.tmp";
+$firstfile = 'c:\\'.$rootdir.'\\'.$file;
+$secondfile = $testdir.'\\'.$file;
+$thirdfile = 'c:\\'.$file;
+
+$h = fopen($firstfile, 'w');
+fwrite($h, "file in $rootdir");
+fclose($h);
+
+$h = fopen($secondfile, 'w');
+fwrite($h, "file in fopen11.tmpDir");
+fclose($h);
+
+$h = fopen($thirdfile, 'w');
+fwrite($h, "file in root");
+fclose($h);
+
+foreach($paths as $path) {
+      echo "\n--$path--\n";
+      $toFind = $path.'\\'.$file;
+         $h = fopen($toFind, 'r', true);
+         if ($h === false) {
+            echo "file not opened for read\n";
+         }
+         else {
+            fpassthru($h);
+            echo "\n";
+         }
+         fclose($h);
+};
+
+unlink($firstfile);
+unlink($secondfile);
+unlink($thirdfile);
+rmdir($testdir);
+rmdir('c:\\'.$rootdir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+
+--c:\--
+file in root
+
+--c:--
+file in root
+
+--c--
+
+Warning: fopen(c\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--\--
+
+Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--/--
+
+Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:fopen11.tmpdirTwo--
+
+Warning: fopen(c:fopen11.tmpdirTwo\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:adir--
+
+Warning: fopen(c:adir\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:\/--
+file in root
+
+--c:\fopen11.tmpdirTwo\/--
+file in fopen11.tmpdirTwo
+
+--c:\fopen11.tmpdirTwo\--
+file in fopen11.tmpdirTwo
+
+--c:\fopen11.tmpdirTwo/--
+file in fopen11.tmpdirTwo
+
+--%s/fopen11.tmpDir--
+file in fopen11.tmpDir
+
+--/sortout--
+
+Warning: fopen(/sortout\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation12.phpt b/ext/standard/tests/file/fopen_variation12.phpt
new file mode 100644 (file)
index 0000000..3d3cdba
--- /dev/null
@@ -0,0 +1,54 @@
+--TEST--
+Test fopen() function : variation: use include path (path is bad) create a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+set_include_path("rubbish");
+testme();
+restore_include_path();
+
+
+function testme() {
+       $tmpfile = 'fopen_variation12.tmp';
+       $h = fopen($tmpfile, "w", true);
+       fwrite($h, "This is the test file");
+       fclose($h);
+       
+       
+       $h = @fopen($tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in working dir\n";
+       }
+       else {
+          echo "created in working dir\n";
+          fclose($h);
+          unlink($tmpfile);
+       }
+       
+       $scriptDirFile = dirname(__FILE__).'/'.$tmpfile; 
+       $h = fopen($scriptDirFile, "r");
+       if ($h === false) {
+          echo "Not created in script dir\n";
+       }
+       else {
+          echo "created in script dir\n";
+          fclose($h);
+          unlink($scriptDirFile);   
+       }
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+Not created in working dir
+created in script dir
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation13.phpt b/ext/standard/tests/file/fopen_variation13.phpt
new file mode 100644 (file)
index 0000000..d540d70
--- /dev/null
@@ -0,0 +1,56 @@
+--TEST--
+Test fopen() function : variation: use include path create a file (absolute)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing fopen() : variation ***\n";
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+
+
+function runtest() {
+    $tempDir = 'fopen_variation13.dir.tmp';
+       $tmpfile = 'fopen_variation13.tmp';
+       $absFile = getcwd().'/'.$tempDir.'/'.$tmpfile;
+       
+       mkdir($tempDir);
+       $h = fopen($absFile, "w", true);
+       fwrite($h, "This is the test file");
+       fclose($h);
+       
+       
+       $h = fopen($absFile, "r");
+       if ($h === false) {
+          echo "Not created absolute location\n";
+       }
+       else {
+          echo "Created in correct location\n";
+          fclose($h);
+       }
+    unlink($absFile);
+    rmdir($tempDir);
+       
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+Created in correct location
+Created in correct location
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation14-win32.phpt b/ext/standard/tests/file/fopen_variation14-win32.phpt
new file mode 100644 (file)
index 0000000..554d8c6
--- /dev/null
@@ -0,0 +1,189 @@
+--TEST--
+Test fopen() function : variation: file uri, no use include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testDir = 'fopen14.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation14.tmp";
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+
+$files = array("file://$testDir\\$file",
+               "file://$testDir/$file",
+               "file://./$testDir/$file",
+               "file://.\\$testDir\\$file",
+               "file://$absTestDir/$file",
+               "file://$absTestDir\\$file",
+               "file://$unixifiedDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+               "file://..\\$testDir\\$file",
+               "file://$absTestDir/$file",
+               "file://$absTestDir\\$file",
+               "file://$unixifiedDir/$file"
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+
+function runtest($fileURIs) {
+   global $absFile;
+   $iteration = 0;
+   foreach($fileURIs as $fileURI) {
+      echo "--- READ: $fileURI ---\n";
+   
+      $readData = "read:$iteration";
+      $writeData = "write:$iteration";
+      
+      // create the file and test read
+      $h = fopen($absFile, 'w');
+      fwrite($h, $readData);
+      fclose($h);
+      
+      $h = fopen($fileURI, 'r');
+      if ($h !== false) {
+         if (fread($h, 4096) != $readData) {
+            echo "contents not correct\n";
+         }
+         else {
+            echo "test passed\n";
+         }
+         fclose($h);
+      }
+      unlink($absFile);
+      
+      echo "--- WRITE: $fileURI ---\n";   
+      // create the file to test write
+      $h = fopen($fileURI, 'w');
+      if ($h !== false) {
+             fwrite($h, $writeData);
+             fclose($h);
+             
+             $h = fopen($absFile, 'r');
+             if ($h !== false) {
+                if (fread($h, 4096) != $writeData) {
+                   echo "contents not correct\n";
+                }
+                else {
+                   echo "test passed\n";
+                }
+                fclose($h);
+             }
+             unlink($absFile);
+          }
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://.\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://.\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://..\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://..\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation14.phpt b/ext/standard/tests/file/fopen_variation14.phpt
new file mode 100644 (file)
index 0000000..aa4e05b
--- /dev/null
@@ -0,0 +1,134 @@
+--TEST--
+Test fopen() function : variation: file uri, no use include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testDir = 'fopen14.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation14.tmp";
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+
+$files = array("file://$testDir/$file",
+               "file://./$testDir/$file",
+               "file://$absTestDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+               "file://$absTestDir/$file",
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+
+function runtest($fileURIs) {
+   global $absFile;
+   $iteration = 0;
+   foreach($fileURIs as $fileURI) {
+      echo "--- READ: $fileURI ---\n";
+   
+      $readData = "read:$iteration";
+      $writeData = "write:$iteration";
+      
+      // create the file and test read
+      $h = fopen($absFile, 'w');
+      fwrite($h, $readData);
+      fclose($h);
+      
+      $h = fopen($fileURI, 'r');
+      if ($h !== false) {
+         if (fread($h, 4096) != $readData) {
+            echo "contents not correct\n";
+         }
+         else {
+            echo "test passed\n";
+         }
+         fclose($h);
+      }
+      unlink($absFile);
+      
+      echo "--- WRITE: $fileURI ---\n";   
+      // create the file to test write
+      $h = fopen($fileURI, 'w');
+      if ($h !== false) {
+             fwrite($h, $writeData);
+             fclose($h);
+             
+             $h = fopen($absFile, 'r');
+             if ($h !== false) {
+                if (fread($h, 4096) != $writeData) {
+                   echo "contents not correct\n";
+                }
+                else {
+                   echo "test passed\n";
+                }
+                fclose($h);
+             }
+             unlink($absFile);
+          }
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/fopen_variation15-win32.phpt b/ext/standard/tests/file/fopen_variation15-win32.phpt
new file mode 100644 (file)
index 0000000..8599306
--- /dev/null
@@ -0,0 +1,193 @@
+--TEST--
+Test fopen() function : variation: file uri, use include path = true
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$includePathDir = getcwd().'/fopen15.includeDir';
+$testDir = 'fopen15.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation15.tmp";
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+mkdir($includePathDir);
+set_include_path($includePathDir);
+
+$files = array("file://$testDir\\$file",
+               "file://$testDir/$file",
+               "file://./$testDir/$file",
+               "file://.\\$testDir\\$file",
+               "file://$absTestDir/$file",
+               "file://$absTestDir\\$file",
+               "file://$unixifiedDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+               "file://..\\$testDir\\$file",
+               "file://$absTestDir/$file",
+               "file://$absTestDir\\$file",
+               "file://$unixifiedDir/$file"
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+rmdir($includePathDir);
+
+function runtest($fileURIs) {
+   global $absFile;
+   $iteration = 0;
+   foreach($fileURIs as $fileURI) {
+      echo "--- READ: $fileURI ---\n";
+   
+      $readData = "read:$iteration";
+      $writeData = "write:$iteration";
+      
+      // create the file and test read
+      $h = fopen($absFile, 'w');
+      fwrite($h, $readData);
+      fclose($h);
+      
+      $h = fopen($fileURI, 'r', true);
+      if ($h !== false) {
+         if (fread($h, 4096) != $readData) {
+            echo "contents not correct\n";
+         }
+         else {
+            echo "test passed\n";
+         }
+         fclose($h);
+      }
+      unlink($absFile);
+      
+      echo "--- WRITE: $fileURI ---\n";   
+      // create the file to test write
+      $h = fopen($fileURI, 'w', true);
+      if ($h !== false) {
+             fwrite($h, $writeData);
+             fclose($h);
+             
+             $h = fopen($absFile, 'r');
+             if ($h !== false) {
+                if (fread($h, 4096) != $writeData) {
+                   echo "contents not correct\n";
+                }
+                else {
+                   echo "test passed\n";
+                }
+                fclose($h);
+             }
+             unlink($absFile);
+          }
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation15.phpt b/ext/standard/tests/file/fopen_variation15.phpt
new file mode 100644 (file)
index 0000000..24b01fb
--- /dev/null
@@ -0,0 +1,138 @@
+--TEST--
+Test fopen() function : variation: file uri, use include path = true
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$includePathDir = getcwd().'/fopen15.includeDir';
+$testDir = 'fopen15.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation15.tmp";
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+mkdir($includePathDir);
+set_include_path($includePathDir);
+
+$files = array("file://$testDir/$file",
+               "file://./$testDir/$file",
+               "file://$absTestDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+               "file://$absTestDir/$file"
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+rmdir($includePathDir);
+
+function runtest($fileURIs) {
+   global $absFile;
+   $iteration = 0;
+   foreach($fileURIs as $fileURI) {
+      echo "--- READ: $fileURI ---\n";
+   
+      $readData = "read:$iteration";
+      $writeData = "write:$iteration";
+      
+      // create the file and test read
+      $h = fopen($absFile, 'w');
+      fwrite($h, $readData);
+      fclose($h);
+      
+      $h = fopen($fileURI, 'r', true);
+      if ($h !== false) {
+         if (fread($h, 4096) != $readData) {
+            echo "contents not correct\n";
+         }
+         else {
+            echo "test passed\n";
+         }
+         fclose($h);
+      }
+      unlink($absFile);
+      
+      echo "--- WRITE: $fileURI ---\n";   
+      // create the file to test write
+      $h = fopen($fileURI, 'w', true);
+      if ($h !== false) {
+             fwrite($h, $writeData);
+             fclose($h);
+             
+             $h = fopen($absFile, 'r');
+             if ($h !== false) {
+                if (fread($h, 4096) != $writeData) {
+                   echo "contents not correct\n";
+                }
+                else {
+                   echo "test passed\n";
+                }
+                fclose($h);
+             }
+             unlink($absFile);
+          }
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/fopen_variation16.phpt b/ext/standard/tests/file/fopen_variation16.phpt
new file mode 100644 (file)
index 0000000..375747f
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+Test fopen() function : variation: use include path create and read a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing fopen() : variation ***\n";
+$thisTestDir = "fopenVariation16.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+    global $dir1;
+       
+    $extraDir = "extraDir";
+
+    mkdir($dir1.'/'.$extraDir);
+    
+       $tmpfile = $extraDir.'/fopen_variation16.tmp';
+       $h = fopen($tmpfile, "w+", true);
+       fwrite($h, "This is the test file");
+       fclose($h);
+       
+       $h = fopen($dir1.'/'.$tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in dir1\n";
+       }
+       else {
+          echo "created in dir1\n";
+          fclose($h);
+       }
+
+       $h = fopen($tmpfile, "r", true);
+       if ($h === false) {
+          echo "could not find file for reading\n";
+       }
+       else {
+          echo "found file again in dir1\n";
+          fclose($h);
+       }
+       
+       unlink($dir1.'/'.$tmpfile);   
+    rmdir($dir1.'/'.$extraDir);        
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+created in dir1
+found file again in dir1
+created in dir1
+found file again in dir1
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation17.phpt b/ext/standard/tests/file/fopen_variation17.phpt
new file mode 100644 (file)
index 0000000..b47060c
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+Test fopen() function : variation: use include path create and read a file (relative) 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing fopen() : variation ***\n";
+$thisTestDir = "fopenVariation17.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+    global $dir1;
+       
+    $extraDir = "extraDir";
+
+    mkdir($dir1.'/'.$extraDir);
+    
+       $tmpfile = $extraDir.'/fopen_variation17.tmp';
+       $h = fopen($tmpfile, "w+", true);
+       fwrite($h, "This is the test file");
+       fclose($h);
+       
+       $h = fopen($dir1.'/'.$tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in dir1\n";
+       }
+       else {
+          echo "created in dir1\n";
+          fclose($h);
+       }
+
+       $h = fopen($tmpfile, "r", true);
+       if ($h === false) {
+          echo "could not find file for reading\n";
+       }
+       else {
+          echo "found file again in dir1\n";
+          fclose($h);
+       }
+       
+       unlink($dir1.'/'.$tmpfile);   
+    rmdir($dir1.'/'.$extraDir);        
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+created in dir1
+found file again in dir1
+created in dir1
+found file again in dir1
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation19.phpt b/ext/standard/tests/file/fopen_variation19.phpt
new file mode 100644 (file)
index 0000000..031ba45
--- /dev/null
@@ -0,0 +1,110 @@
+--TEST--
+Test fopen() function : variation: test opening linked files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+$tmpDir = 'fopenVar19.Dir';
+$realFilename = __FILE__.'.real';
+$sortFilename = __FILE__.'.soft';
+$hardFilename = __FILE__.'.hard';
+$linkOfLink = __FILE__.'.soft2';
+
+echo "*** Testing fopen() : variation ***\n";
+// start the test
+mkdir($tmpDir);
+chdir($tmpDir);
+
+$h = fopen($realFilename, "w");
+fwrite($h, "Hello World");
+fclose($h);
+
+symlink($realFilename, $sortFilename);
+symlink($sortFilename, $linkOfLink);
+link($realFilename, $hardFilename);
+
+
+
+echo "*** testing reading of links ***\n";
+echo "soft link:";
+readFile2($sortFilename);
+echo "hard link:";
+readFile2($hardFilename);
+echo "link of link:";
+readFile2($linkOfLink);
+
+echo "*** test appending to links ***\n";
+echo "soft link:";
+appendFile($sortFilename);
+echo "hard link:";
+appendFile($hardFilename);
+echo "link of link:";
+appendFile($linkOfLink);
+
+echo "*** test overwriting links ***\n";
+echo "soft link:";
+writeFile($sortFilename);
+echo "hard link:";
+writeFile($hardFilename);
+echo "link of link:";
+writeFile($linkOfLink);
+
+unlink($linkOfLink);
+unlink($sortFilename);
+unlink($hardFilename);
+unlink($realFilename);
+chdir("..");
+rmdir($tmpDir);
+
+function readFile2($file) {
+   $h = fopen($file, 'r');
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+}
+
+function appendFile($file) {
+   $h = fopen($file, 'a+');
+   fwrite($h, ' again!');
+   fseek($h, 0);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+}
+
+function writeFile($file) {
+   $h = fopen($file, 'w');
+   fwrite($h, 'Goodbye World');
+   fclose($h);
+   readFile2($file);
+}
+
+
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+*** testing reading of links ***
+soft link:Hello World
+hard link:Hello World
+link of link:Hello World
+*** test appending to links ***
+soft link:Hello World again!
+hard link:Hello World again! again!
+link of link:Hello World again! again! again!
+*** test overwriting links ***
+soft link:Goodbye World
+hard link:Goodbye World
+link of link:Goodbye World
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation3.phpt b/ext/standard/tests/file/fopen_variation3.phpt
new file mode 100644 (file)
index 0000000..3467a3a
--- /dev/null
@@ -0,0 +1,218 @@
+--TEST--
+Test fopen() function : usage variation different datatypes for use_include_path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__;
+$mode = 'r';
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for use_include_path
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $h = fopen($filename, $mode, $value);
+      if ($h !== false) {
+         echo "ok\n";
+         fclose($h);
+      }
+      else {
+         var_dump($h);
+      }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : usage variation ***
+
+--int 0--
+ok
+
+--int 1--
+ok
+
+--int 12345--
+ok
+
+--int -12345--
+ok
+
+--float 10.5--
+ok
+
+--float -10.5--
+ok
+
+--float 12.3456789000e10--
+ok
+
+--float -12.3456789000e10--
+ok
+
+--float .5--
+ok
+
+--empty array--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+ok
+
+--lowercase null--
+ok
+
+--lowercase true--
+ok
+
+--lowercase false--
+ok
+
+--uppercase TRUE--
+ok
+
+--uppercase FALSE--
+ok
+
+--empty string DQ--
+ok
+
+--empty string SQ--
+ok
+
+--string DQ--
+ok
+
+--string SQ--
+ok
+
+--mixed case string--
+ok
+
+--heredoc--
+ok
+
+--instance of classWithToString--
+Error: 2 - fopen() expects parameter 3 to be boolean, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - fopen() expects parameter 3 to be boolean, object given, %s(%d)
+bool(false)
+
+--undefined var--
+ok
+
+--unset var--
+ok
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation4.phpt b/ext/standard/tests/file/fopen_variation4.phpt
new file mode 100644 (file)
index 0000000..61d850c
--- /dev/null
@@ -0,0 +1,251 @@
+--TEST--
+Test fopen() function : usage variation different datatypes for stream context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__;
+$mode = 'r';
+$use_include_path = false;
+$fileresource = fopen($filename, $mode);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      //file resource
+      'file resource' => $fileresource
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $h = fopen($filename, $mode, false, $value);
+      if ($h !== false) {
+         echo "ok\n";
+         fclose($h);
+      }
+      else {
+         var_dump($h);
+      }
+};
+
+fclose($fileresource);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : usage variation ***
+
+--int 0--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - fopen() expects parameter 4 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - fopen() expects parameter 4 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--file resource--
+Error: 2 - fopen(): supplied resource is not a valid Stream-Context resource, %s(%d)
+ok
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation5.phpt b/ext/standard/tests/file/fopen_variation5.phpt
new file mode 100644 (file)
index 0000000..c8cc582
--- /dev/null
@@ -0,0 +1,172 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context (absolute directories in path)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+
+
+echo "*** Testing fopen() : variation ***\n";
+//create the include directory structure
+$thisTestDir = "fopenVariation5.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$workingDir = "workdir";
+$filename = "afile.txt";
+$scriptDir = dirname(__FILE__);
+$baseDir = getcwd();
+$secondFile = $baseDir."/dir2/".$filename;
+$firstFile = "../dir1/".$filename;
+$scriptFile = $scriptDir.'/'.$filename;
+
+$newdirs = array("dir1", "dir2", "dir3");
+$pathSep = ":";
+$newIncludePath = "";
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+   $pathSep = ";";
+}
+foreach($newdirs as $newdir) {
+   mkdir($newdir);
+   $newIncludePath .= $baseDir.'/'.$newdir.$pathSep;
+}
+mkdir($workingDir);
+chdir($workingDir);
+
+//define the files to go into these directories, create one in dir2
+echo "\n--- testing include path ---\n";
+set_include_path($newIncludePath);   
+$modes = array("r", "r+", "rt");
+foreach($modes as $mode) {
+    test_fopen($mode);
+}
+restore_include_path();
+
+// remove the directory structure
+chdir($baseDir);
+rmdir($workingDir);
+foreach($newdirs as $newdir) {
+   rmdir($newdir);
+}
+
+chdir("..");
+rmdir($thisTestDir);
+
+
+function test_fopen($mode) {
+   global $scriptFile, $secondFile, $firstFile, $filename;
+   
+   // create a file in the middle directory
+   $h = fopen($secondFile, "w");
+   fwrite($h, "in dir2");
+   fclose($h);
+
+   echo "\n** testing with mode=$mode **\n";
+   // should read dir2 file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+
+   //create a file in dir1
+   $h = fopen($firstFile, "w");
+   fwrite($h, "in dir1");
+   fclose($h);
+   
+   //should now read dir1 file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+   
+   // create a file in working directory
+   $h = fopen($filename, "w");
+   fwrite($h, "in working dir");
+   fclose($h);
+   
+   //should still read dir1 file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+   
+   unlink($firstFile);
+   unlink($secondFile);
+   
+   //should fail to read the file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+   
+   // create a file in the script directory
+   $h = fopen($scriptFile, "w");
+   fwrite($h, "in script dir");
+   fclose($h);
+   
+   //should read the file in script dir
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+     
+   //cleanup
+   unlink($filename);
+   unlink($scriptFile);
+
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+
+--- testing include path ---
+
+** testing with mode=r **
+in dir2
+in dir1
+in dir1
+
+Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+
+in script dir
+
+** testing with mode=r+ **
+in dir2
+in dir1
+in dir1
+
+Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+
+in script dir
+
+** testing with mode=rt **
+in dir2
+in dir1
+in dir1
+
+Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+
+in script dir
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation6.phpt b/ext/standard/tests/file/fopen_variation6.phpt
new file mode 100644 (file)
index 0000000..3a99212
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context relative/absolute file 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+$absfile = __FILE__.'.tmp';
+$relfile = "fopen_variation6.tmp";
+
+$h = fopen($absfile, "w");
+fwrite($h, "This is an absolute file");
+fclose($h);
+
+$h = fopen($relfile, "w");
+fwrite($h, "This is a relative file");
+fclose($h);
+
+$ctx = stream_context_create();
+$h = fopen($absfile, "r", true, $ctx);
+fpassthru($h);
+fclose($h);
+echo "\n";
+
+$h = fopen($relfile, "r", true, $ctx);
+fpassthru($h);
+fclose($h);
+echo "\n";
+
+unlink($absfile);
+unlink($relfile);
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+This is an absolute file
+This is a relative file
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation7.phpt b/ext/standard/tests/file/fopen_variation7.phpt
new file mode 100644 (file)
index 0000000..2d6647d
--- /dev/null
@@ -0,0 +1,69 @@
+--TEST--
+Test fopen() function : variation: use include path create a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing fopen() : variation ***\n";
+$thisTestDir = "fopenVariation7.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+    global $dir1;
+       $tmpfile = 'fopen_variation7.tmp';
+       $h = fopen($tmpfile, "w", true);
+       fwrite($h, "This is the test file");
+       fclose($h);
+       
+       
+       $h = @fopen($tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in working dir\n";
+       }
+       else {
+          echo "created in working dir\n";
+          fclose($h);
+          unlink($tmpfile);
+       }
+       
+       $h = fopen($dir1.'/'.$tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in dir1\n";
+       }
+       else {
+          echo "created in dir1\n";
+          fclose($h);
+          unlink($dir1.'/'.$tmpfile);   
+       }
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+Not created in working dir
+created in dir1
+Not created in working dir
+created in dir1
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation8.phpt b/ext/standard/tests/file/fopen_variation8.phpt
new file mode 100644 (file)
index 0000000..6672b62
--- /dev/null
@@ -0,0 +1,171 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context (relative directories in path)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+
+
+echo "*** Testing fopen() : variation ***\n";
+$thisTestDir = "fopenVariation8.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+//create the include directory structure
+$workingDir = "workdir";
+$filename = "afile.txt";
+$scriptDir = dirname(__FILE__);
+$baseDir = getcwd();
+$secondFile = $baseDir."/dir2/".$filename;
+$firstFile = "../dir1/".$filename;
+$scriptFile = $scriptDir.'/'.$filename;
+
+$newdirs = array("dir1", "dir2", "dir3");
+$pathSep = ":";
+$newIncludePath = "";
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+   $pathSep = ";";
+}
+foreach($newdirs as $newdir) {
+   mkdir($newdir);
+   $newIncludePath .= '../'.$newdir.$pathSep;
+}
+mkdir($workingDir);
+chdir($workingDir);
+
+//define the files to go into these directories, create one in dir2
+echo "\n--- testing include path ---\n";
+set_include_path($newIncludePath);   
+$modes = array("r", "r+", "rt");
+foreach($modes as $mode) {
+    test_fopen($mode);
+}
+restore_include_path();
+
+// remove the directory structure
+chdir($baseDir);
+rmdir($workingDir);
+foreach($newdirs as $newdir) {
+   rmdir($newdir);
+}
+
+chdir("..");
+rmdir($thisTestDir);
+
+function test_fopen($mode) {
+   global $scriptFile, $secondFile, $firstFile, $filename;
+   
+   // create a file in the middle directory
+   $h = fopen($secondFile, "w");
+   fwrite($h, "in dir2");
+   fclose($h);
+
+   echo "\n** testing with mode=$mode **\n";
+   // should read dir2 file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+
+   //create a file in dir1
+   $h = fopen($firstFile, "w");
+   fwrite($h, "in dir1");
+   fclose($h);
+   
+   //should now read dir1 file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+   
+   // create a file in working directory
+   $h = fopen($filename, "w");
+   fwrite($h, "in working dir");
+   fclose($h);
+   
+   //should still read dir1 file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+   
+   unlink($firstFile);
+   unlink($secondFile);
+   
+   //should fail to read the file
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+   
+   // create a file in the script directory
+   $h = fopen($scriptFile, "w");
+   fwrite($h, "in script dir");
+   fclose($h);
+   
+   //should read the file in script dir
+   $h = fopen($filename, $mode, true);
+   fpassthru($h);
+   fclose($h);
+   echo "\n";
+     
+   //cleanup
+   unlink($filename);
+   unlink($scriptFile);
+
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+
+--- testing include path ---
+
+** testing with mode=r **
+in dir2
+in dir1
+in dir1
+
+Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+
+in script dir
+
+** testing with mode=r+ **
+in dir2
+in dir1
+in dir1
+
+Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+
+in script dir
+
+** testing with mode=rt **
+in dir2
+in dir1
+in dir1
+
+Warning: fopen(afile.txt): failed to open stream: No such file or directory in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+
+in script dir
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation9.phpt b/ext/standard/tests/file/fopen_variation9.phpt
new file mode 100644 (file)
index 0000000..63630d3
--- /dev/null
@@ -0,0 +1,68 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context create a file, relative path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--FILE--
+<?php
+/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing fopen() : variation ***\n";
+$thisTestDir = "fopenVariation9.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = relative_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_rel_path();
+set_include_path($newpath);
+runtest();
+
+teardown_relative_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+       $tmpfile = 'fopen_variation7.tmp';
+       $h = fopen($tmpfile, "w", true);
+       fwrite($h, "This is the test file");
+       fclose($h);
+       
+       
+       $h = @fopen($tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in working dir\n";
+       }
+       else {
+          echo "created in working dir\n";
+          fclose($h);
+          unlink($tmpfile);
+       }
+       
+       $h = fopen('dir1/'.$tmpfile, "r");
+       if ($h === false) {
+          echo "Not created in dir1\n";
+       }
+       else {
+          echo "created in dir1\n";
+          fclose($h);
+          unlink('dir1/'.$tmpfile);   
+       }
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+Not created in working dir
+created in dir1
+Not created in working dir
+created in dir1
+===DONE===
index 958397b0e548626cd5997ef8a219460587decf10..16dacfada93bc2b033959b52d9b997c009adbba4 100644 (file)
@@ -20,6 +20,11 @@ var_dump( fpassthru() );
 /* No.of args greaer than expected */
 var_dump( fpassthru("", "") );
 
+/* fpassthru on a closed file */
+$h = fopen(__FILE__,'r');
+fclose($h);
+fpassthru($h);
+
 echo "\n*** Done ***\n";
 
 ?>
@@ -37,4 +42,7 @@ bool(false)
 Warning: fpassthru() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 
+Warning: fpassthru(): 5 is not a valid stream resource in %s on line %d
+
 *** Done ***
+
diff --git a/ext/standard/tests/file/fpassthru_variation1.phpt b/ext/standard/tests/file/fpassthru_variation1.phpt
new file mode 100644 (file)
index 0000000..2f1a963
--- /dev/null
@@ -0,0 +1,228 @@
+--TEST--
+Test fpassthru() function : usage variations  - different parameter types
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto int fpassthru(resource fp)
+ * Description: Output all remaining data from a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzpassthru
+ */
+
+/*
+ * add a comment here to say what the test is supposed to do
+ */
+
+echo "*** Testing fpassthru() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+class testClass {
+   public function __toString() {
+      return "testClass";
+   }
+}
+
+//array of values to iterate over
+$values = array(
+
+      // int data
+      0,
+      1,
+      12345,
+      -2345,
+
+      // float data
+      10.5,
+      -10.5,
+      10.1234567e10,
+      10.7654321E-10,
+      .5,
+
+      // array data
+      array(),
+      array(0),
+      array(1),
+      array(1, 2),
+      array('color' => 'red', 'item' => 'pen'),
+
+      // null data
+      NULL,
+      null,
+
+      // boolean data
+      true,
+      false,
+      TRUE,
+      FALSE,
+
+      // empty data
+      "",
+      '',
+
+      // string data
+      "string",
+      'string',
+
+      // object data
+      new testClass(),
+
+      // undefined data
+      $undefined_var,
+
+      // unset data
+      $unset_var,
+);
+
+// loop through each element of the array for fp
+
+foreach($values as $value) {
+      echo "\nArg value $value \n";
+      var_dump( fpassthru($value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fpassthru() : usage variations ***
+
+Arg value 0 
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value 1 
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value 12345 
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value -2345 
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value 10.5 
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value -10.5 
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value 101234567000 
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value 1.07654321E-9 
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value 0.5 
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value Array 
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array 
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array 
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array 
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array 
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Arg value 1 
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value 1 
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value string 
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value string 
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value testClass 
+
+Warning: fpassthru() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Arg value  
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
+
index 4bba8ecd7a8cf4db89e9193ed696bb918f50acbb..c6259b66423b1d792e9421c94e00d7569cc44cad 100644 (file)
@@ -103,7 +103,7 @@ bool(false)
 
 Notice: Undefined variable: file_content_type in %s on line %d
 
-Warning: fread(): 5 is not a valid stream resource in %s on line %d
+Warning: fread(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: fread() expects parameter 1 to be resource, null given in %s on line %d
@@ -112,3 +112,4 @@ bool(false)
 Warning: fclose() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
diff --git a/ext/standard/tests/file/fread_fwrite_basic.phpt b/ext/standard/tests/file/fread_fwrite_basic.phpt
new file mode 100644 (file)
index 0000000..0f5c4ed
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+fread & fwrite - Test reading and writing using a single resource
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+/* 
+ * proto int fwrite(resource fp, string str [, int length])
+ * Function is implemented in ext/standard/file.c
+ */ 
+ /*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle. 
+   Reading stops when up to length bytes have been read, EOF (end of file) is 
+   reached, (for network streams) when a packet becomes available, or (after 
+   opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+
+$outputfile = __FILE__.".tmp";
+
+echo "--- testing rw moving about the file ---\n";
+$h = fopen($outputfile, 'wb+');
+$out1 = "The 1st prrt";
+$out2 = " part of the ttxt";
+$out3 = "text";
+fwrite($h, $out1);
+fseek($h, 0, SEEK_SET);
+echo "start:".fread($h, strlen($out1) - 5). "\n";
+fwrite($h, $out2);
+echo "at end:".fread($h,100)."\n";
+var_dump(feof($h));
+fseek($h, -4, SEEK_CUR);
+fwrite($h, $out3);
+fseek($h, 0, SEEK_SET);
+echo "final:".fread($h, 100)."\n";
+fclose($h);
+
+echo "--- testing eof ---\n";
+$h = fopen($outputfile, 'ab+');
+fread($h,1024);
+var_dump(feof($h));
+fread($h,1);
+var_dump(feof($h));
+$out = "extra";
+fwrite($h, $out);
+var_dump(feof($h));
+fread($h,1);
+var_dump(feof($h));
+fseek($h, -strlen($out) + 1, SEEK_CUR);
+echo "last bytes: ".fread($h, strlen($out))."\n";
+fclose($h);
+
+unlink($outputfile);
+
+echo "Done";
+?>
+--EXPECT--
+--- testing rw moving about the file ---
+start:The 1st
+at end:
+bool(true)
+final:The 1st part of the text
+--- testing eof ---
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+last bytes: xtra
+Done
\ No newline at end of file
index c6d0816e915867f4a8f31194a8a863faa4ee7bd8..cde0bf25798ede8c4fc1517616218f5f02933636 100644 (file)
@@ -42,7 +42,7 @@ var_dump(rmdir($path));
 ?>
 --EXPECTF--
 call readdir():
-resource(12) of type (stream)
+resource(%d) of type (stream)
 array(6) {
   [0]=>
   bool(false)
index 0af71e65fc85f0f5e6b73e593a1e618bb020a2f6..23eb991ebec1b7abeb8338179417e1b7c40bc7d7 100644 (file)
@@ -91,9 +91,10 @@ bool(false)
 Warning: fseek() expects parameter 1 to be resource, object given in %s on line %d
 bool(false)
 -- Testing fseek() with closed/unset file handle --
-Warning: fseek(): 5 is not a valid stream resource in %s on line %d
+Warning: fseek(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: fseek() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
index 31c9be70be0e9de6d4ed0e29d956a525c7ecfc51..af14dbb270f7c4ad4a8c0d719eea0302bf50bda6 100644 (file)
@@ -87,9 +87,10 @@ bool(false)
 Warning: ftell() expects parameter 1 to be resource, object given in %s on line %d
 bool(false)
 -- Testing ftell with closed/unset file handle --
-Warning: ftell(): 5 is not a valid stream resource in %s on line %d
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: ftell() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
index 09ed54374d9f988a4478725ca1e1e44a2d79c174..2d8f52768ee6329b9486ddbcd75ce5707e008262 100644 (file)
@@ -87,9 +87,10 @@ bool(false)
 Warning: rewind() expects parameter 1 to be resource, object given in %s on line %d
 bool(false)
 -- Testing rewind() with closed/unset file handle --
-Warning: rewind(): 5 is not a valid stream resource in %s on line %d
+Warning: rewind(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: rewind() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
diff --git a/ext/standard/tests/file/fseek_variation1.phpt b/ext/standard/tests/file/fseek_variation1.phpt
new file mode 100644 (file)
index 0000000..ebf3cf6
--- /dev/null
@@ -0,0 +1,198 @@
+--TEST--
+Test fseek() function : usage variations  - different types for offset
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto int fseek(resource fp, int offset [, int whence])
+ * Description: Seek on a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzseek
+ */
+
+echo "*** Testing fseek() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+// Initialise function arguments not being substituted (if any)
+
+$fp = fopen(__FILE__, 'r');
+$whence = SEEK_SET;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+class testClass {
+   public function __toString() {
+      return "testClass";
+   }
+}
+
+
+//array of values to iterate over
+$values = array(
+
+      // float data
+      10.5,
+      -10.5,
+      10.7654321E-10,
+      .5,
+
+      // array data
+      array(),
+      array(0),
+      array(1),
+      array(1, 2),
+      array('color' => 'red', 'item' => 'pen'),
+
+      // null data
+      NULL,
+      null,
+
+      // boolean data
+      true,
+      false,
+      TRUE,
+      FALSE,
+
+      // empty data
+      "",
+      '',
+
+      // string data
+      "string",
+      'string',
+      
+      // object data
+      new testClass(),      
+
+      // undefined data
+      $undefined_var,
+
+      // unset data
+      $unset_var,
+);
+
+// loop through each element of the array for offset
+
+foreach($values as $value) {
+      echo "\nArg value $value \n";
+      var_dump( fseek($fp, $value, $whence) );
+      var_dump( ftell($fp));
+};
+fclose($fp);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fseek() : usage variations ***
+
+Arg value 10.5 
+int(0)
+int(10)
+
+Arg value -10.5 
+int(-1)
+int(10)
+
+Arg value 1.07654321E-9 
+int(0)
+int(0)
+
+Arg value 0.5 
+int(0)
+int(0)
+
+Arg value Array 
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array 
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array 
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array 
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array 
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value  
+int(0)
+int(0)
+
+Arg value  
+int(0)
+int(0)
+
+Arg value 1 
+int(0)
+int(1)
+
+Arg value  
+int(0)
+int(0)
+
+Arg value 1 
+int(0)
+int(1)
+
+Arg value  
+int(0)
+int(0)
+
+Arg value  
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value  
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value string 
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value string 
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value testClass 
+
+Warning: fseek() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+int(0)
+
+Arg value  
+int(0)
+int(0)
+
+Arg value  
+int(0)
+int(0)
+Done
+
diff --git a/ext/standard/tests/file/fseek_variation2.phpt b/ext/standard/tests/file/fseek_variation2.phpt
new file mode 100644 (file)
index 0000000..1524459
--- /dev/null
@@ -0,0 +1,163 @@
+--TEST--
+Test fseek() function : usage variations  - different types for whence
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto int fseek(resource fp, int offset [, int whence])
+ * Description: Seek on a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzseek
+ */
+
+/*
+ * add a comment here to say what the test is supposed to do
+ */
+
+echo "*** Testing fseek() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+$fp = fopen(__FILE__, 'r');
+$offset = 3;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+      // outside of whence range
+      -100,
+      100,
+
+      // float data
+      10.5,
+      -10.5,
+      10.1234567e10,
+      10.7654321E-10,
+      .5,
+
+      // null data
+      NULL,
+      null,
+
+      // boolean data
+      true,
+      false,
+      TRUE,
+      FALSE,
+
+      // empty data
+      "",
+      '',
+
+      // string data
+      "string",
+      'string',
+
+      // undefined data
+      $undefined_var,
+
+      // unset data
+      $unset_var,
+);
+
+// loop through each element of the array for whence
+
+foreach($values as $value) {
+      echo "\nArg value $value \n";
+      var_dump( fseek($fp, $offset, $value) );
+      var_dump( ftell($fp));
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fseek() : usage variations ***
+
+Arg value -100 
+int(-1)
+int(0)
+
+Arg value 100 
+int(-1)
+int(0)
+
+Arg value 10.5 
+int(-1)
+int(0)
+
+Arg value -10.5 
+int(-1)
+int(0)
+
+Arg value 101234567000 
+int(-1)
+int(0)
+
+Arg value 1.07654321E-9 
+int(0)
+int(3)
+
+Arg value 0.5 
+int(0)
+int(3)
+
+Arg value  
+int(0)
+int(3)
+
+Arg value  
+int(0)
+int(3)
+
+Arg value 1 
+int(0)
+int(6)
+
+Arg value  
+int(0)
+int(3)
+
+Arg value 1 
+int(0)
+int(6)
+
+Arg value  
+int(0)
+int(3)
+
+Arg value  
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value  
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value string 
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value string 
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value  
+int(0)
+int(3)
+
+Arg value  
+int(0)
+int(3)
+Done
+
diff --git a/ext/standard/tests/file/fseek_variation3.phpt b/ext/standard/tests/file/fseek_variation3.phpt
new file mode 100644 (file)
index 0000000..57dad36
--- /dev/null
@@ -0,0 +1,58 @@
+--TEST--
+Test fseek() function : variation functionality beyond file boundaries 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : proto int fseek(resource fp, int offset [, int whence])
+ * Description: Seek on a file pointer 
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzseek
+ */
+
+/*
+ * add a comment here to say what the test is supposed to do
+ */
+
+echo "*** Testing fseek() : variation - beyond file boundaries ***\n";
+
+$outputfile = __FILE__.".tmp";
+
+$h = fopen($outputfile, "wb+");
+for ($i = 1; $i < 10; $i++) {
+   fwrite($h, chr(0x30 + $i));
+}
+
+echo "--- fseek beyond start of file ---\n";
+var_dump(fseek($h, -4, SEEK_SET));
+echo "after -4 seek: ".bin2hex(fread($h,1))."\n";
+var_dump(fseek($h, -1, SEEK_CUR));
+echo "after seek back 1: ".bin2hex(fread($h,1))."\n";
+var_dump(fseek($h, -20, SEEK_CUR));
+echo "after seek back 20: ".bin2hex(fread($h,1))."\n";
+
+echo "--- fseek beyond end of file ---\n";
+var_dump(fseek($h, 16, SEEK_SET));
+fwrite($h, b"end");
+fseek($h ,0, SEEK_SET);
+$data = fread($h, 4096);
+echo bin2hex($data)."\n";
+
+fclose($h);
+unlink($outputfile);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fseek() : variation - beyond file boundaries ***
+--- fseek beyond start of file ---
+int(-1)
+after -4 seek: 
+int(0)
+after seek back 1: 39
+int(-1)
+after seek back 20: 
+--- fseek beyond end of file ---
+int(0)
+31323334353637383900000000000000656e64
+Done
index a28095bc2d96b4564b5c2f40ce99b787b5878901..2f22d4e25f5cbffa37f1cbebc8ea7182ff7a8e7f 100644 (file)
@@ -11,7 +11,7 @@ echo "*** Testing ftruncate() : error conditions ***\n";
 
 $filename = dirname(__FILE__)."/ftruncate_error.tmp";
 $file_handle = fopen($filename, "w" );
-fwrite($file_handle, (binary)"Testing ftruncate error conditions \n");
+fwrite($file_handle, "Testing ftruncate error conditions \n");
 fflush($file_handle);
 echo "\n Initial file size = ".filesize($filename)."\n";
 
@@ -23,12 +23,14 @@ var_dump( ftruncate() );
 // arguments less than expected numbers
 var_dump( ftruncate( $file_handle ) );
 // check the first size 
+clearstatcache();
 var_dump( filesize($filename) );
 
 echo "-- Testing ftruncate() with more than expected number of arguments --\n";
 // more than expected number of arguments 
 var_dump( ftruncate($file_handle, 10, 20) );
-// check the first size 
+// check the first size
+clearstatcache(); 
 var_dump( filesize($filename) );
 
 // test invalid arguments : non-resources
@@ -53,14 +55,16 @@ echo "-- Testing ftruncate() with closed/unset file handle --\n";
 // ftruncate on close file handle
 fclose($file_handle);
 var_dump( ftruncate($file_handle,10) );
-// check the first size 
+// check the first size
+clearstatcache(); 
 var_dump( filesize($filename) );
 
 // ftruncate on a file handle which is unset
 $fp = fopen($filename, "w");
 unset($fp); //unset file handle
 var_dump( ftruncate(@$fp,10));
-// check the first size 
+// check the first size
+clearstatcache(); 
 var_dump( filesize($filename) );
 
 echo "Done\n";
@@ -114,11 +118,12 @@ Warning: ftruncate() expects parameter 1 to be resource, object given in %s on l
 bool(false)
 -- Testing ftruncate() with closed/unset file handle --
 
-Warning: ftruncate(): 5 is not a valid stream resource in %s on line %d
+Warning: ftruncate(): %d is not a valid stream resource in %s on line %d
 bool(false)
 int(36)
 
 Warning: ftruncate() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
-int(36)
+int(0)
 Done
+
index 2177c94b253fb2da8e6a42d3822c5ecb761b7235..988d618c6604fadef2006ee2d95f9fc8067173bf 100644 (file)
@@ -112,9 +112,10 @@ Warning: fwrite() expects parameter 1 to be resource, object given in %s on line
 bool(false)
 -- Testing fwrite() with closed/unset file handle --
 
-Warning: fwrite(): 6 is not a valid stream resource in %s on line %d
+Warning: fwrite(): %d is not a valid stream resource in %s on line %d
 bool(false)
 
 Warning: fwrite() expects parameter 1 to be resource, null given in %s on line %d
 bool(false)
 Done
+
diff --git a/ext/standard/tests/file/fwrite_variation5.phpt b/ext/standard/tests/file/fwrite_variation5.phpt
new file mode 100644 (file)
index 0000000..63303af
--- /dev/null
@@ -0,0 +1,173 @@
+--TEST--
+Test fwrite() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int fwrite(resource fp, string str [, int length])
+ * Description: Binary-safe file write 
+ * Source code: ext/standard/file.c
+ * Alias to functions: bzwrite fputs gzwrite
+ */
+
+echo "*** Testing fwrite() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+$filename = 'fwriteVar5.tmp';
+
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for str
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $fp = fopen($filename,'w');
+      fwrite($fp, $value);
+      fclose($fp);
+      readfile($filename);
+};
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fwrite() : usage variation ***
+
+--int 0--
+0
+--int 1--
+1
+--int 12345--
+12345
+--int -12345--
+-2345
+--float 10.5--
+10.5
+--float -10.5--
+-10.5
+--float 12.3456789000e10--
+123456789000
+--float -12.3456789000e10--
+-123456789000
+--float .5--
+0.5
+--empty array--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--associative array--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--uppercase NULL--
+
+--lowercase null--
+
+--lowercase true--
+1
+--lowercase false--
+
+--uppercase TRUE--
+1
+--uppercase FALSE--
+
+--empty string DQ--
+
+--empty string SQ--
+
+--instance of classWithToString--
+Class A object
+--instance of classWithoutToString--
+Error: 2 - fwrite() expects parameter 2 to be string, object given, %s(%d)
+
+--undefined var--
+
+--unset var--
+===DONE===
+
index 68e1bc74b1481dc3fb42bee153a77d71925be09e..fc269c442f5cfb5c50e9163e22533c1d33a45613 100755 (executable)
@@ -25,14 +25,19 @@ $fp = fopen("$dirname/file.text", "w");
 fclose($fp);
 
 // glob() with default arguments
-var_dump( glob($dirname."/*") );
-var_dump( glob($dirname."/*.txt") );
-var_dump( glob($dirname."/*.t?t") );
-var_dump( glob($dirname."/*.t*t") );
-var_dump( glob($dirname."/*.?") );
-var_dump( glob($dirname."/*.*") );
+sort_var_dump( glob($dirname."/*") );
+sort_var_dump( glob($dirname."/*.txt") );
+sort_var_dump( glob($dirname."/*.t?t") );
+sort_var_dump( glob($dirname."/*.t*t") );
+sort_var_dump( glob($dirname."/*.?") );
+sort_var_dump( glob($dirname."/*.*") );
 
 echo "Done\n";
+
+function sort_var_dump($results) {
+   sort($results);
+   var_dump($results);
+}
 ?>
 --CLEAN--
 <?php
diff --git a/ext/standard/tests/file/glob_error_002-win32.phpt b/ext/standard/tests/file/glob_error_002-win32.phpt
new file mode 100644 (file)
index 0000000..a61efd1
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Test glob() function: error condition - pattern too long.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+   Description: Find pathnames matching a pattern
+*/
+
+echo "*** Testing glob() : error condition - pattern too long. ***\n";
+
+var_dump(glob(str_repeat('x', 3000)));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing glob() : error condition - pattern too long. ***
+
+Warning: glob(): Pattern exceeds the maximum allowed length of %d characters in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/glob_error_002.phpt b/ext/standard/tests/file/glob_error_002.phpt
new file mode 100644 (file)
index 0000000..f5bad73
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Test glob() function: long pattern.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+   Description: Find pathnames matching a pattern
+*/
+
+echo "*** Testing glob() : long pattern. ***\n";
+
+var_dump(glob(str_repeat('x', 3000)));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing glob() : long pattern. ***
+array(0) {
+}
+Done
+
index 022e06bb40a3e0c91b8871f13695ec245b3d16c0..881725679328f23d985b76f27c8d92c83a25948e 100644 (file)
@@ -14,7 +14,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
 
 /* Testing is_dir() with dir, soft & hard link to dir,
      and with file, soft & hard link to file */
-
+      
 $file_path = dirname(__FILE__);
 
 echo "*** Testing is_dir() with dir and links to dir ***\n";
@@ -70,7 +70,7 @@ bool(true)
 -- With symlink --
 bool(true)
 -- With hardlink --
-Warning: link(): %s in %s on line %d
+Warning: link(): %s
 bool(false)
 
 *** Testing is_dir() with file and links to a file ***
index 9c2cdf885ac658dc09baa12e5ad4093c06121a7e..2df297843b83eaec599059209d6c6a5f83fbcd61 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test is_dir() function: usage variations - invalid arguments
+Test is_dir() function: usage variations - invalid arguments 
 --FILE--
 <?php
 /* Prototype: bool is_dir ( string $dirname );
@@ -18,9 +18,10 @@ $dirnames = array(
   TRUE,
   FALSE,
   NULL,
+  " ",
   $dir_handle,
 
-  /* Non-existing dirnames */
+  /* scalars */
   0,
   1234
 );
@@ -39,6 +40,7 @@ bool(false)
 bool(false)
 bool(false)
 bool(false)
+bool(false)
 
 Warning: is_dir() expects parameter 1 to be string, resource given in %s on line %d
 NULL
@@ -46,3 +48,4 @@ bool(false)
 bool(false)
 
 *** Done ***
+
index 4ec53a5ab22d373cbdb76f4e48bc8b8e3cbba9c8..634ce1f40c6a5df0945d28c7bf9911bfa71a8190 100644 (file)
@@ -5,6 +5,16 @@ Test is_executable() function: usage variations - invalid file names
 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__)."/is_executable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+        unlink ($filename);
+        die('skip cannot be run as root');
+}
+
+unlink($filename);
 ?>
 --FILE--
 <?php
@@ -27,6 +37,7 @@ $invalid_files = array(
   TRUE,
   FALSE,
   NULL,
+  " ",
   @array(),
   @$file_handle
 );
@@ -49,8 +60,10 @@ bool(false)
 bool(false)
 bool(false)
 bool(false)
+bool(false)
 
 Warning: is_executable() expects parameter 1 to be string, array given in %s on line %d
 NULL
 bool(false)
 Done
+
index fd952fa0966feb03102892d5fa20cb9e2dbac21a..917fa5acc8cdff7caa2196b7f8a7741cf8f97e43 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test is_file() function: usage variations - invalid arguments
+Test is_file() function: usage variations - invalid filenames
 --FILE--
 <?php
 /* Prototype: bool is_file ( string $filename );
@@ -16,17 +16,18 @@ echo "*** Testing Invalid file types ***\n";
 $filenames = array(
   /* Invalid filenames */
   -2.34555,
+  " ",
   "",
   TRUE,
   FALSE,
   NULL,
   $file_handle,
-
+  
   /* scalars */
   1234,
   0
 );
-
+   
 /* loop through to test each element the above array */
 foreach( $filenames as $filename ) {
   var_dump( is_file($filename) );
@@ -48,6 +49,7 @@ bool(false)
 bool(false)
 bool(false)
 bool(false)
+bool(false)
 
 Warning: is_file() expects parameter 1 to be string, resource given in %s on line %d
 NULL
@@ -55,3 +57,4 @@ bool(false)
 bool(false)
 
 *** Done ***
+
index fc0cab85cc3b5d6b9b39aaf351b50a51a87943ca..55aeedfaada50f36acbf5bdcb9343823664cb63d 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test is_file() function: usage variations - diff. path notations (Bug #42027, #42638)
+Test is_file() function: usage variations - diff. path notations (Bug #42027)
 --FILE--
 <?php
 /* Prototype: bool is_file ( string $filename );
index 76eafd0b5abc73b40dfbd984a58ceaffa1ef963a..a1310327b8b3d9926a82a2cac9a48d11d56e86e2 100644 (file)
@@ -2,8 +2,16 @@
 Test is_readable() function: usage variations - diff. file notations
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
-    die('skip not for windows');
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+  // Skip if being run by root (files are always readable, writeable and executable)
+  $filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+  $fp = fopen($filename, 'w');
+  fclose($fp);
+  if(fileowner($filename) == 0) {
+        unlink ($filename);
+        die('skip cannot be run as root');
+  }
+  unlink($filename);
 }
 ?>
 --FILE--
index fefd7a2c4c0c8c97f91f645c42d5cd0dd568a08c..dde47cc3b5cd7e779209c57227a554364d2b0053 100644 (file)
@@ -2,8 +2,17 @@
 Test is_readable() function: usage variations - invalid file names
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
-    die('skip not for windows');
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+
+  // Skip if being run by root (files are always readable, writeable and executable)
+  $filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+  $fp = fopen($filename, 'w');
+  fclose($fp);
+  if(fileowner($filename) == 0) {
+        unlink ($filename);
+        die('skip cannot be run as root');
+  }
+  unlink($filename);
 }
 ?>
 --FILE--
@@ -27,6 +36,7 @@ $misc_files = array(
   TRUE,
   FALSE,
   NULL,
+  " ",
   @array(),
   @$file_handle
 );
@@ -49,8 +59,10 @@ bool(false)
 bool(false)
 bool(false)
 bool(false)
+bool(false)
 
 Warning: is_readable() expects parameter 1 to be string, array given in %s on line %d
 NULL
 bool(false)
 Done
+
diff --git a/ext/standard/tests/file/is_uploaded_file_basic.phpt b/ext/standard/tests/file/is_uploaded_file_basic.phpt
new file mode 100644 (file)
index 0000000..355125e
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+is_uploaded_file() function
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php if (php_sapi_name()=='cli') die('skip'); ?>
+--POST_RAW--
+Content-type: multipart/form-data, boundary=AaB03x
+
+--AaB03x
+content-disposition: form-data; name="field1"
+
+Joe Blow
+--AaB03x
+content-disposition: form-data; name="pics"; filename="file1.txt"
+Content-Type: text/plain
+
+abcdef123456789
+--AaB03x--
+--FILE--
+<?php
+// uploaded file
+var_dump(is_uploaded_file($_FILES['pics']['tmp_name']));
+
+// not an uploaded file
+var_dump(is_uploaded_file($_FILES['pics']['name']));
+
+// not an uploaded file
+var_dump(is_uploaded_file('random_filename.txt'));
+
+// not an uploaded file
+var_dump(is_uploaded_file('__FILE__'));
+
+// Error cases
+var_dump(is_uploaded_file());
+var_dump(is_uploaded_file('a', 'b'));
+
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_uploaded_file() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_uploaded_file() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
index 97232b43204b840640867bdd678beb0c12477491..bf3e7e117199f3fa72e87f9a389b88625fd45e59 100644 (file)
@@ -2,8 +2,18 @@
 Test is_writable() and its alias is_writeable() function: usage variations - diff. path notations
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
-    die('skip.. only on LINUX');
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+
+  // Skip if being run by root (files are always readable, writeable and executable)
+  $filename = dirname(__FILE__)."/is_writable_root_check.tmp";
+  $fp = fopen($filename, 'w');
+  fclose($fp);
+  if(fileowner($filename) == 0) {
+        unlink ($filename);
+        die('skip cannot be run as root');
+  }
+
+  unlink($filename);
 }
 ?>
 --FILE--
@@ -100,4 +110,4 @@ bool(true)
 -- Iteration 11 --
 bool(true)
 bool(true)
-Done
+Done
\ No newline at end of file
index e2cc13c33ab11413398e3914ebfcb0d42ec1389c..4c5bfa9082d3415e6025e880e9019d98ef79ceaf 100644 (file)
@@ -2,8 +2,16 @@
 Test is_writable() and its alias is_writeable() function: usage variations - invalid file names
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
-    die('skip.. only on LINUX');
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+  // Skip if being run by root (files are always readable, writeable and executable)
+  $filename = dirname(__FILE__)."/is_writable_root_check.tmp";
+  $fp = fopen($filename, 'w');
+  fclose($fp);
+  if(fileowner($filename) == 0) {
+        unlink ($filename);
+        die('skip cannot be run as root');
+  }
+  unlink($filename);
 }
 ?>
 --FILE--
@@ -26,6 +34,7 @@ $misc_files = array(
   TRUE,
   FALSE,
   NULL,
+  " ",
   @array(),
   @$file_handle
 );
@@ -55,6 +64,8 @@ bool(false)
 bool(false)
 bool(false)
 bool(false)
+bool(false)
+bool(false)
 
 Warning: is_writable() expects parameter 1 to be string, array given in %s on line %d
 NULL
@@ -64,3 +75,4 @@ NULL
 bool(false)
 bool(false)
 Done
+
index c845bb478a40b116897e2576273e226d848cada4..e7d704a20b3a98855de00aee52bf30f86958ec00 100755 (executable)
@@ -21,13 +21,12 @@ $file_path = dirname(__FILE__);
 require("file.inc");
 
 /* create temp directory */
-@rmdir("$file_path/lstat_stat_variation2/");  //ensure that dir doesn't exists 
-mkdir("$file_path/lstat_stat_variation2/");  // temp dir
+mkdir("$file_path/lstat_stat_variation1/");  // temp dir
 
 // renaming a directory and check stat
 echo "*** Testing stat() for directory after being renamed ***\n";
-$old_dirname = "$file_path/lstat_stat_variation2";
-$new_dirname = "$file_path/lstat_stat_variation2a";
+$old_dirname = "$file_path/lstat_stat_variation1";
+$new_dirname = "$file_path/lstat_stat_variation1a";
 $old_stat = stat($old_dirname);
 clearstatcache();
 var_dump( rename($old_dirname, $new_dirname) );
@@ -37,8 +36,11 @@ $new_stat = stat($new_dirname);
 var_dump( compare_self_stat($old_stat) );
 var_dump( compare_self_stat($new_stat) );
 
-// compare the two stats
-var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
+// compare the two stats - all except ctime
+$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 
+                       "dev", "ino", "mode", "nlink", "uid", "gid",
+                       "rdev", "size", "atime", "mtime", "blksize", "blocks");
+var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
 // clear the cache
 clearstatcache();
 
@@ -48,7 +50,7 @@ echo "\n--- Done ---";
 --CLEAN--
 <?php
 $file_path = dirname(__FILE__);
-rmdir("$file_path/lstat_stat_variation2a");
+rmdir("$file_path/lstat_stat_variation1a");
 ?>
 --EXPECTF--
 *** Testing stat() for directory after being renamed ***
diff --git a/ext/standard/tests/file/lstat_stat_variation22.phpt b/ext/standard/tests/file/lstat_stat_variation22.phpt
new file mode 100644 (file)
index 0000000..c9072ce
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+   Description: Gives information about a file or symbolic link
+
+   Prototype: array stat ( string $filename );
+   Description: Gives information about a file
+*/
+echo "*** testing stat ***\n";
+var_dump(stat(NULL));
+var_dump(stat(false));
+var_dump(stat(''));
+var_dump(stat(' '));
+var_dump(stat('|'));
+
+echo "*** testing lstat ***\n";
+var_dump(lstat(NULL));
+var_dump(lstat(false));
+var_dump(lstat(''));
+var_dump(lstat(' '));
+var_dump(lstat('|'));
+echo "Done";
+?>
+--EXPECTF--
+*** testing stat ***
+bool(false)
+bool(false)
+bool(false)
+
+Warning: stat(): stat failed for   in %s on line %d
+bool(false)
+
+Warning: stat(): stat failed for | in %s on line %d
+bool(false)
+*** testing lstat ***
+bool(false)
+bool(false)
+bool(false)
+
+Warning: lstat(): Lstat failed for   in %s on line %d
+bool(false)
+
+Warning: lstat(): Lstat failed for | in %s on line %d
+bool(false)
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/mkdir_variation1-win32.phpt b/ext/standard/tests/file/mkdir_variation1-win32.phpt
new file mode 100644 (file)
index 0000000..507a97b
--- /dev/null
@@ -0,0 +1,123 @@
+--TEST--
+Test mkdir() function : usage variation: try invalid pathname
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase false' =>false,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // other
+      // php.net bug outputs message File Exists
+      'single space' => ' ',
+);
+
+// loop through each element of the array for pathname
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $res = mkdir($value);
+      if ($res == true) {
+         echo "directory created\n";
+         rmdir($value);
+      }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--lowercase null--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--lowercase false--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--uppercase FALSE--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--empty string DQ--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--undefined var--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--unset var--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--single space--
+Error: 2 - mkdir(): %s, %s(%d)
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/mkdir_variation1.phpt b/ext/standard/tests/file/mkdir_variation1.phpt
new file mode 100644 (file)
index 0000000..e8c5006
--- /dev/null
@@ -0,0 +1,122 @@
+--TEST--
+Test mkdir() function : usage variation: try invalid pathname 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase false' =>false,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // other
+      'single space' => ' ',
+);
+
+// loop through each element of the array for pathname
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $res = mkdir($value);
+      if ($res == true) {
+         echo "directory created\n";
+         rmdir($value);
+      }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--lowercase null--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--lowercase false--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--uppercase FALSE--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--empty string DQ--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--undefined var--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--unset var--
+Error: 2 - mkdir(): No such file or directory, %s(%d)
+
+--single space--
+directory created
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/mkdir_variation2.phpt b/ext/standard/tests/file/mkdir_variation2.phpt
new file mode 100644 (file)
index 0000000..ab9a676
--- /dev/null
@@ -0,0 +1,189 @@
+--TEST--
+Test mkdir() function : usage variation: different types for mode
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$pathname = 'mkdirVar2.tmp';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for mode
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $h = mkdir($pathname, $value);
+      if ($h === true) {
+         echo "Directory created\n";
+         rmdir($pathname);
+      }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--float 10.5--
+Directory created
+
+--float -10.5--
+Directory created
+
+--float 12.3456789000e10--
+Directory created
+
+--float -12.3456789000e10--
+Directory created
+
+--float .5--
+Directory created
+
+--empty array--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--associative array--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--uppercase NULL--
+Directory created
+
+--lowercase null--
+Directory created
+
+--lowercase true--
+Directory created
+
+--lowercase false--
+Directory created
+
+--uppercase TRUE--
+Directory created
+
+--uppercase FALSE--
+Directory created
+
+--empty string DQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--string DQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--string SQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--mixed case string--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--heredoc--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--instance of classWithToString--
+Error: 2 - mkdir() expects parameter 2 to be long, object given, %s(%d)
+
+--instance of classWithoutToString--
+Error: 2 - mkdir() expects parameter 2 to be long, object given, %s(%d)
+
+--undefined var--
+Directory created
+
+--unset var--
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation3.phpt b/ext/standard/tests/file/mkdir_variation3.phpt
new file mode 100644 (file)
index 0000000..7622e5f
--- /dev/null
@@ -0,0 +1,208 @@
+--TEST--
+Test mkdir() function : usage variation: different types for recursive
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$pathname = 'mkdirVar3.tmp';
+$mode = 0777;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for recursive
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $h = mkdir($pathname, $mode, $value);
+      if ($h === true) {
+         echo "Directory created\n";
+         rmdir($pathname);
+      }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--int 0--
+Directory created
+
+--int 1--
+Directory created
+
+--int 12345--
+Directory created
+
+--int -12345--
+Directory created
+
+--float 10.5--
+Directory created
+
+--float -10.5--
+Directory created
+
+--float 12.3456789000e10--
+Directory created
+
+--float -12.3456789000e10--
+Directory created
+
+--float .5--
+Directory created
+
+--empty array--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--associative array--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--uppercase NULL--
+Directory created
+
+--lowercase null--
+Directory created
+
+--lowercase true--
+Directory created
+
+--lowercase false--
+Directory created
+
+--uppercase TRUE--
+Directory created
+
+--uppercase FALSE--
+Directory created
+
+--empty string DQ--
+Directory created
+
+--empty string SQ--
+Directory created
+
+--string DQ--
+Directory created
+
+--string SQ--
+Directory created
+
+--mixed case string--
+Directory created
+
+--heredoc--
+Directory created
+
+--instance of classWithToString--
+Error: 2 - mkdir() expects parameter 3 to be boolean, object given, %s(%d)
+
+--instance of classWithoutToString--
+Error: 2 - mkdir() expects parameter 3 to be boolean, object given, %s(%d)
+
+--undefined var--
+Directory created
+
+--unset var--
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation4.phpt b/ext/standard/tests/file/mkdir_variation4.phpt
new file mode 100644 (file)
index 0000000..b97d4eb
--- /dev/null
@@ -0,0 +1,220 @@
+--TEST--
+Test mkdir() function : usage variation: different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$pathname = 'mkdirVar4.tmp';
+$mode = 0777;
+$recursive = false;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+$fileRes = fopen(__FILE__,'r');
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // non stream context resource
+      'file resource' => $fileRes,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $h =  mkdir($pathname, $mode, $recursive, $value);
+      if ($h === true) {
+         echo "Directory created\n";
+         rmdir($pathname);
+      }
+};
+
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--int 0--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--int 1--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--int 12345--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--int -12345--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--float 10.5--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float -10.5--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float 12.3456789000e10--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float -12.3456789000e10--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float .5--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--empty array--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--associative array--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--uppercase NULL--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--lowercase null--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--lowercase true--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--lowercase false--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--uppercase TRUE--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--uppercase FALSE--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--empty string DQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--string DQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--string SQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--mixed case string--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--heredoc--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--instance of classWithToString--
+Error: 2 - mkdir() expects parameter 4 to be resource, object given, %s(%d)
+
+--instance of classWithoutToString--
+Error: 2 - mkdir() expects parameter 4 to be resource, object given, %s(%d)
+
+--undefined var--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--unset var--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--file resource--
+Error: 2 - mkdir(): supplied resource is not a valid Stream-Context resource, %s(%d)
+Directory created
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/mkdir_variation5-win32.phpt b/ext/standard/tests/file/mkdir_variation5-win32.phpt
new file mode 100644 (file)
index 0000000..d93f6c6
--- /dev/null
@@ -0,0 +1,106 @@
+--TEST--
+Test mkdir() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?> 
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : variation ***\n";
+
+$workDir = "mkdirVar5.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDir, 3);
+
+$dirs = array(
+             // relative
+             $workDir.'\\'.$subDir,
+             '.\\'.$workDir.'\\'.$subDir,
+             $workDir.'\\..\\'.$workDir.'\\'.$subDir,
+             
+             // relative bad path
+             $workDir.'\\..\\BADDIR\\'.$subDir,
+             'BADDIR\\'.$subDir,
+             
+             //absolute
+             $cwd.'\\'.$workDir.'\\'.$subDir,
+             $cwd.'\\.\\'.$workDir.'\\'.$subDir,
+             $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDir,
+
+             //absolute bad path             
+             $cwd.'\\BADDIR\\'.$subDir,
+             
+             //trailing separators
+             $workDir.'\\'.$subDir.'\\',
+             $cwd.'\\'.$workDir.'\\'.$subDir.'\\',
+             
+             // multiple separators
+             $workDir.'\\\\'.$subDir,
+             $cwd.'\\\\'.$workDir.'\\\\'.$subDir,
+             
+             // Unixified Dir
+             $unixifiedDir,
+             
+             );
+             
+
+foreach($dirs as $dir) {
+   echo "-- creating $dir --\n";           
+   $res = mkdir($dir);
+   if ($res === true) {
+      echo "Directory created\n";
+      rmdir($workDir.'\\'.$subDir);
+   }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : variation ***
+-- creating mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating .\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating mkdirVar5.tmp\..\BADDIR\aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating BADDIR\aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating %s\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating %s\.\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating %s\mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating %s\BADDIR\aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating mkdirVar5.tmp\aSubDir\ --
+Directory created
+-- creating %s\mkdirVar5.tmp\aSubDir\ --
+Directory created
+-- creating mkdirVar5.tmp\\aSubDir --
+Directory created
+-- creating %s\\mkdirVar5.tmp\\aSubDir --
+Directory created
+-- creating /%s/mkdirVar5.tmp/aSubDir --
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation5.phpt b/ext/standard/tests/file/mkdir_variation5.phpt
new file mode 100644 (file)
index 0000000..51fb826
--- /dev/null
@@ -0,0 +1,99 @@
+--TEST--
+Test mkdir() function : variation: various valid and invalid paths 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?> 
+--FILE--
+<?php
+/* Prototype  : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing mkdir() : variation ***\n";
+
+$workDir = "mkdirVar5.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$dirs = array(
+             // relative
+             $workDir.'/'.$subDir,
+             './'.$workDir.'/'.$subDir,
+             $workDir.'/../'.$workDir.'/'.$subDir,
+             
+             // relative bad path
+             $workDir.'/../BADDIR/'.$subDir,
+             'BADDIR/'.$subDir,
+             
+             //absolute
+             $cwd.'/'.$workDir.'/'.$subDir,
+             $cwd.'/./'.$workDir.'/'.$subDir,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDir,
+
+             //absolute bad path             
+             $cwd.'/BADDIR/'.$subDir,
+             
+             //trailing separators
+             $workDir.'/'.$subDir.'/',
+             $cwd.'/'.$workDir.'/'.$subDir.'/',
+             
+             // multiple separators
+             $workDir.'//'.$subDir,
+             $cwd.'//'.$workDir.'//'.$subDir,
+             
+             );
+             
+
+foreach($dirs as $dir) {
+   echo "-- creating $dir --\n";           
+   $res = mkdir($dir);
+   if ($res === true) {
+      echo "Directory created\n";
+      rmdir($dir);
+   }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : variation ***
+-- creating mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating ./mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating mkdirVar5.tmp/../mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating mkdirVar5.tmp/../BADDIR/aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating BADDIR/aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating %s/mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating %s/./mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating %s/mkdirVar5.tmp/../mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating %s/BADDIR/aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating mkdirVar5.tmp/aSubDir/ --
+Directory created
+-- creating %s/mkdirVar5.tmp/aSubDir/ --
+Directory created
+-- creating mkdirVar5.tmp//aSubDir --
+Directory created
+-- creating %s//mkdirVar5.tmp//aSubDir --
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/move_uploaded_file_basic.phpt b/ext/standard/tests/file/move_uploaded_file_basic.phpt
new file mode 100644 (file)
index 0000000..f008304
--- /dev/null
@@ -0,0 +1,78 @@
+--TEST--
+move_uploaded_file() function
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php if (php_sapi_name()=='cli') die('skip'); ?>
+--POST_RAW--
+Content-type: multipart/form-data, boundary=AaB03x
+
+--AaB03x
+content-disposition: form-data; name="field1"
+
+Joe Blow
+--AaB03x
+content-disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain
+
+abcdef123456789xxxDDDxxxDDDxxxDDD
+--AaB03x
+content-disposition: form-data; name="file2"; filename="file2.txt"
+Content-Type: text/plain
+
+abcdef123456789
+--AaB03x--
+--FILE--
+<?php
+
+echo "Valid move\n";
+$destination1 = __FILE__ . ".tmp";
+
+var_dump(move_uploaded_file($_FILES['file1']['tmp_name'], $destination1));
+$file_contents = file_get_contents($destination1);
+$contents_matches = ($file_contents == b"abcdef123456789xxxDDDxxxDDDxxxDDD");
+var_dump($contents_matches);
+unlink($destination1);
+echo "\n";
+
+echo "Original name of uploaded file\n";
+$destination2 = __FILE__ . ".tmp2";
+var_dump(move_uploaded_file($_FILES['file1']['name'], $destination2));
+
+echo "Non-uploaded source file\n";
+$source = __FILE__;
+$destination3 = __FILE__ . ".tmp3";
+var_dump(move_uploaded_file($source, $destination3));
+
+echo "Valid move to existing file\n";
+$destination4 = __FILE__ . ".tmp4";
+$fd = fopen($destination4, "w");
+fclose($fd);
+var_dump(move_uploaded_file($_FILES['file2']['tmp_name'], $destination4));
+unlink($destination4);
+
+echo "Wrong parameters\n";
+var_dump(move_uploaded_file());
+var_dump(move_uploaded_file(1, 2, 3));
+
+
+?>
+--EXPECTF--
+Valid move
+bool(true)
+bool(true)
+
+Original name of uploaded file
+bool(false)
+Non-uploaded source file
+bool(false)
+Valid move to existing file
+bool(true)
+Wrong parameters
+
+Warning: move_uploaded_file() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: move_uploaded_file() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
diff --git a/ext/standard/tests/file/parse_ini_file_variation1.phpt b/ext/standard/tests/file/parse_ini_file_variation1.phpt
new file mode 100644 (file)
index 0000000..a24bc1c
--- /dev/null
@@ -0,0 +1,68 @@
+--TEST--
+Test parse_ini_file() function : variation: identical properties and values are not referenced.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$output_file = __FILE__.".ini";
+$iniFile = <<<FILE
+[section1]
+value1=original
+value2=original
+[section2]
+value1=original
+value2=different
+FILE;
+
+file_put_contents($output_file, $iniFile);
+
+$a = parse_ini_file($output_file, true);
+var_dump($a);
+$a['section1']['value1'] = 'changed';
+var_dump($a);
+
+unlink($output_file);
+?>
+===DONE===
+--EXPECT--
+*** Testing parse_ini_file() : variation ***
+array(2) {
+  ["section1"]=>
+  array(2) {
+    ["value1"]=>
+    string(8) "original"
+    ["value2"]=>
+    string(8) "original"
+  }
+  ["section2"]=>
+  array(2) {
+    ["value1"]=>
+    string(8) "original"
+    ["value2"]=>
+    string(9) "different"
+  }
+}
+array(2) {
+  ["section1"]=>
+  array(2) {
+    ["value1"]=>
+    string(7) "changed"
+    ["value2"]=>
+    string(8) "original"
+  }
+  ["section2"]=>
+  array(2) {
+    ["value1"]=>
+    string(8) "original"
+    ["value2"]=>
+    string(9) "different"
+  }
+}
+===DONE===
diff --git a/ext/standard/tests/file/parse_ini_file_variation2.phpt b/ext/standard/tests/file/parse_ini_file_variation2.phpt
new file mode 100644 (file)
index 0000000..20ad6bb
--- /dev/null
@@ -0,0 +1,111 @@
+--TEST--
+Test parse_ini_file() function : variation: handling different boolean values
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$output_file = __FILE__.".ini";
+$iniFile = <<<FILE
+[section1]
+value1=on
+value2=off
+[section2]
+value1=true
+value2=false
+[section3]
+value1=yes
+value2=no
+[section4]
+value1=null
+value2=
+
+[section5]
+value1="on"
+value2="off"
+[section6]
+value1="true"
+value2="false"
+[section7]
+value1="yes"
+value2="no"
+[section8]
+value1="null"
+value2=""
+
+FILE;
+
+file_put_contents($output_file, $iniFile);
+
+$a = parse_ini_file($output_file, true);
+var_dump($a);
+unlink($output_file);
+?>
+===DONE===
+--EXPECT--
+*** Testing parse_ini_file() : variation ***
+array(8) {
+  ["section1"]=>
+  array(2) {
+    ["value1"]=>
+    string(1) "1"
+    ["value2"]=>
+    string(0) ""
+  }
+  ["section2"]=>
+  array(2) {
+    ["value1"]=>
+    string(1) "1"
+    ["value2"]=>
+    string(0) ""
+  }
+  ["section3"]=>
+  array(2) {
+    ["value1"]=>
+    string(1) "1"
+    ["value2"]=>
+    string(0) ""
+  }
+  ["section4"]=>
+  array(2) {
+    ["value1"]=>
+    string(0) ""
+    ["value2"]=>
+    string(0) ""
+  }
+  ["section5"]=>
+  array(2) {
+    ["value1"]=>
+    string(2) "on"
+    ["value2"]=>
+    string(3) "off"
+  }
+  ["section6"]=>
+  array(2) {
+    ["value1"]=>
+    string(4) "true"
+    ["value2"]=>
+    string(5) "false"
+  }
+  ["section7"]=>
+  array(2) {
+    ["value1"]=>
+    string(3) "yes"
+    ["value2"]=>
+    string(2) "no"
+  }
+  ["section8"]=>
+  array(2) {
+    ["value1"]=>
+    string(4) "null"
+    ["value2"]=>
+    string(0) ""
+  }
+}
+===DONE===
diff --git a/ext/standard/tests/file/parse_ini_file_variation3.phpt b/ext/standard/tests/file/parse_ini_file_variation3.phpt
new file mode 100644 (file)
index 0000000..be14750
--- /dev/null
@@ -0,0 +1,99 @@
+--TEST--
+Test parse_ini_file() function : variation: include path searching
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$pwd = getcwd();
+$f = basename(__FILE__);
+$dir1 = $pwd."/".$f.".dir1";
+$dir2 = $pwd."/".$f.".dir2";
+$dir3 = $pwd."/".$f.".dir3";
+$iniFile = "php.ini";
+
+$newdirs = array($dir1, $dir2, $dir3);
+$pathSep = ":";
+$newIncludePath = "";
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+   $pathSep = ";";
+}
+foreach($newdirs as $newdir) {
+   mkdir($newdir);
+   $newIncludePath .= $newdir.$pathSep;
+}
+
+
+var_dump(parse_ini_file($iniFile));
+set_include_path($newIncludePath);
+var_dump(parse_ini_file($iniFile));
+
+
+$output_file = $dir2."/".$iniFile;
+$iniContent = <<<FILE
+error_reporting  =  E_ALL
+display_errors = On
+display_startup_errors = Off
+log_errors = Off
+log_errors_max_len = 1024
+ignore_repeated_errors = Off
+ignore_repeated_source = Off
+report_memleaks = On
+track_errors = Off
+docref_root = "/phpmanual/"
+docref_ext = .html
+
+FILE;
+
+file_put_contents($output_file, $iniContent);
+var_dump(parse_ini_file($iniFile));
+
+unlink($output_file);
+foreach($newdirs as $newdir) {
+   rmdir($newdir);
+}
+
+
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing parse_ini_file() : variation ***
+
+Warning: parse_ini_file(php.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: parse_ini_file(php.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+array(11) {
+  ["error_reporting"]=>
+  string(%d) "%d"
+  ["display_errors"]=>
+  string(1) "1"
+  ["display_startup_errors"]=>
+  string(0) ""
+  ["log_errors"]=>
+  string(0) ""
+  ["log_errors_max_len"]=>
+  string(4) "1024"
+  ["ignore_repeated_errors"]=>
+  string(0) ""
+  ["ignore_repeated_source"]=>
+  string(0) ""
+  ["report_memleaks"]=>
+  string(1) "1"
+  ["track_errors"]=>
+  string(0) ""
+  ["docref_root"]=>
+  string(11) "/phpmanual/"
+  ["docref_ext"]=>
+  string(5) ".html"
+}
+===DONE===
diff --git a/ext/standard/tests/file/parse_ini_file_variation4.phpt b/ext/standard/tests/file/parse_ini_file_variation4.phpt
new file mode 100644 (file)
index 0000000..55bc22f
--- /dev/null
@@ -0,0 +1,211 @@
+--TEST--
+Test parse_ini_file() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$process_sections = false;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for filename
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( parse_ini_file($value, $process_sections) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing parse_ini_file() : usage variation ***
+
+--int 0--
+Error: 2 - parse_ini_file(0): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - parse_ini_file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - parse_ini_file(12345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - parse_ini_file(-2345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - parse_ini_file(10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - parse_ini_file(-10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - parse_ini_file(123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - parse_ini_file(-123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - parse_ini_file(0.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - parse_ini_file() expects parameter 1 to be string, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - parse_ini_file() expects parameter 1 to be string, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - parse_ini_file() expects parameter 1 to be string, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - parse_ini_file() expects parameter 1 to be string, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - parse_ini_file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - parse_ini_file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - parse_ini_file(Class A object): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - parse_ini_file() expects parameter 1 to be string, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - parse_ini_file(): Filename can not be empty!, %s(%d)
+bool(false)
+===DONE===
+
diff --git a/ext/standard/tests/file/parse_ini_file_variation5.phpt b/ext/standard/tests/file/parse_ini_file_variation5.phpt
new file mode 100644 (file)
index 0000000..eea7b7d
--- /dev/null
@@ -0,0 +1,254 @@
+--TEST--
+Test parse_ini_file() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__."ParseIniFileVar5.ini";
+$contents = "a=test";
+@unlink($filename);
+file_put_contents($filename, $contents);
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for process_sections
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( parse_ini_file($filename, $value) );
+};
+
+unlink($filename);
+?>
+===DONE===
+--EXPECTF--
+*** Testing parse_ini_file() : usage variation ***
+
+--int 0--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--int 1--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--int 12345--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--int -12345--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--float 10.5--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--float -10.5--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--float 12.3456789000e10--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--float -12.3456789000e10--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--float .5--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--empty array--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--lowercase null--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--empty string DQ--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--empty string SQ--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--string DQ--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--string SQ--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--mixed case string--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--heredoc--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--instance of classWithToString--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--undefined var--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+--unset var--
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+===DONE===
+
diff --git a/ext/standard/tests/file/parse_ini_file_variation6-win32.phpt b/ext/standard/tests/file/parse_ini_file_variation6-win32.phpt
new file mode 100644 (file)
index 0000000..6dfbee9
--- /dev/null
@@ -0,0 +1,143 @@
+--TEST--
+Test parse_ini_file() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$mainDir = "parseIniFileVar6.dir";
+$subDir = "parseIniFileVar6Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir\\",
+  "$absSubDir\\..\\".$subDir,
+  "$absSubDir\\\\..\\.\\".$subDir,
+  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+  "$absSubDir\\BADDIR",
+  
+  // relative paths
+  $mainDir."\\".$subDir,
+  $mainDir."\\\\".$subDir, 
+   $mainDir."\\\\\\".$subDir, 
+  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+  "BADDIR",  
+  
+  // unixifed path
+  $unixifiedDir,
+);
+
+$filename = 'ParseIniFileVar6.ini';
+$content="a=test";
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, $content);
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  var_dump(parse_ini_file($dir."\\".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 2 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 3 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 4 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 5 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir\parseIniFileVar6Sub\..\\\parseIniFileVar6Sub\\..\\..\parseIniFileVar6Sub\ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir\parseIniFileVar6Sub\BADDIR\ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 8 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 9 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 10 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 11 --
+
+Warning: parse_ini_file(BADDIR\ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/parse_ini_file_variation6.phpt b/ext/standard/tests/file/parse_ini_file_variation6.phpt
new file mode 100644 (file)
index 0000000..e9844e9
--- /dev/null
@@ -0,0 +1,129 @@
+--TEST--
+Test parse_ini_file() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file 
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$mainDir = "parseIniFileVar6.dir";
+$subDir = "parseIniFileVar6Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+  
+);
+
+$filename = 'ParseIniFileVar6.ini';
+$content="a=test";
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, $content);
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  var_dump(parse_ini_file($dir."/".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 2 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 3 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 4 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 5 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/..///parseIniFileVar6Sub//..//../parseIniFileVar6Sub/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 8 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 9 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 10 --
+array(1) {
+  ["a"]=>
+  string(4) "test"
+}
+
+-- Iteration 11 --
+
+Warning: parse_ini_file(BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_basic1-win32.phpt b/ext/standard/tests/file/pathinfo_basic1-win32.phpt
new file mode 100644 (file)
index 0000000..9e84b99
--- /dev/null
@@ -0,0 +1,609 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+   Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+                               '',
+                       ' ',
+                       'c:',
+                       'c:\\',
+                       'c:/',
+                       'afile',
+                       'c:\test\adir',
+                       'c:\test\adir\\',
+                       '/usr/include/arpa',
+                       '/usr/include/arpa/',
+                       'usr/include/arpa',
+                       'usr/include/arpa/',                    
+                       'c:\test\afile',
+                       'c:\\test\\afile',
+                       'c://test//afile',
+                       'c:\test\afile\\',
+                       'c:\test\prog.exe',
+                       'c:\\test\\prog.exe',
+                       'c:/test/prog.exe',                     
+                       '/usr/include/arpa/inet.h',
+                       '//usr/include//arpa/inet.h',
+                       '\\',
+                       '\\\\',
+                       '/',
+                       '//',
+                       '///',
+                       '/usr/include/arpa/inet.h',
+                       'c:\windows/system32\drivers/etc\hosts',
+                       '/usr\include/arpa\inet.h',
+                       '   c:\test\adir\afile.txt',
+                       'c:\test\adir\afile.txt   ',
+                       '   c:\test\adir\afile.txt   ',
+                       '   /usr/include/arpa/inet.h',
+                       '/usr/include/arpa/inet.h   ',
+                       '   /usr/include/arpa/inet.h   ',
+                       ' c:',
+                       '               c:\test\adir\afile.txt',
+                       '/usr',
+                       '/usr/'
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+  echo "-- Iteration $counter --\n";
+  var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+  var_dump( pathinfo($path, PATHINFO_BASENAME) );
+  var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+  var_dump( pathinfo($path, PATHINFO_FILENAME) );
+  var_dump( pathinfo($path) );
+  $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+array(2) {
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 2 --
+string(1) "."
+string(1) " "
+string(0) ""
+string(1) " "
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(1) " "
+  ["filename"]=>
+  string(1) " "
+}
+-- Iteration 3 --
+string(2) "c:"
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+  ["dirname"]=>
+  string(2) "c:"
+  ["basename"]=>
+  string(2) "c:"
+  ["filename"]=>
+  string(2) "c:"
+}
+-- Iteration 4 --
+string(3) "c:\"
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+  ["dirname"]=>
+  string(3) "c:\"
+  ["basename"]=>
+  string(2) "c:"
+  ["filename"]=>
+  string(2) "c:"
+}
+-- Iteration 5 --
+string(3) "c:\"
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+  ["dirname"]=>
+  string(3) "c:\"
+  ["basename"]=>
+  string(2) "c:"
+  ["filename"]=>
+  string(2) "c:"
+}
+-- Iteration 6 --
+string(1) "."
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 7 --
+string(7) "c:\test"
+string(4) "adir"
+string(0) ""
+string(4) "adir"
+array(3) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(4) "adir"
+  ["filename"]=>
+  string(4) "adir"
+}
+-- Iteration 8 --
+string(7) "c:\test"
+string(4) "adir"
+string(0) ""
+string(4) "adir"
+array(3) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(4) "adir"
+  ["filename"]=>
+  string(4) "adir"
+}
+-- Iteration 9 --
+string(12) "/usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(12) "/usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 10 --
+string(12) "/usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(12) "/usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 11 --
+string(11) "usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(11) "usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 12 --
+string(11) "usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(11) "usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 13 --
+string(7) "c:\test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 14 --
+string(7) "c:\test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 15 --
+string(8) "c://test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(8) "c://test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 16 --
+string(7) "c:\test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 17 --
+string(7) "c:\test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(8) "prog.exe"
+  ["extension"]=>
+  string(3) "exe"
+  ["filename"]=>
+  string(4) "prog"
+}
+-- Iteration 18 --
+string(7) "c:\test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+  ["dirname"]=>
+  string(7) "c:\test"
+  ["basename"]=>
+  string(8) "prog.exe"
+  ["extension"]=>
+  string(3) "exe"
+  ["filename"]=>
+  string(4) "prog"
+}
+-- Iteration 19 --
+string(7) "c:/test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+  ["dirname"]=>
+  string(7) "c:/test"
+  ["basename"]=>
+  string(8) "prog.exe"
+  ["extension"]=>
+  string(3) "exe"
+  ["filename"]=>
+  string(4) "prog"
+}
+-- Iteration 20 --
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 21 --
+string(19) "//usr/include//arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(19) "//usr/include//arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 22 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 23 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 24 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 25 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 26 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 27 --
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 28 --
+string(31) "c:\windows/system32\drivers/etc"
+string(5) "hosts"
+string(0) ""
+string(5) "hosts"
+array(3) {
+  ["dirname"]=>
+  string(31) "c:\windows/system32\drivers/etc"
+  ["basename"]=>
+  string(5) "hosts"
+  ["filename"]=>
+  string(5) "hosts"
+}
+-- Iteration 29 --
+string(17) "/usr\include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr\include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 30 --
+string(15) "   c:\test\adir"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(15) "   c:\test\adir"
+  ["basename"]=>
+  string(9) "afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 31 --
+string(12) "c:\test\adir"
+string(12) "afile.txt   "
+string(6) "txt   "
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(12) "c:\test\adir"
+  ["basename"]=>
+  string(12) "afile.txt   "
+  ["extension"]=>
+  string(6) "txt   "
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 32 --
+string(15) "   c:\test\adir"
+string(12) "afile.txt   "
+string(6) "txt   "
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(15) "   c:\test\adir"
+  ["basename"]=>
+  string(12) "afile.txt   "
+  ["extension"]=>
+  string(6) "txt   "
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 33 --
+string(20) "   /usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(20) "   /usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 34 --
+string(17) "/usr/include/arpa"
+string(9) "inet.h   "
+string(4) "h   "
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(9) "inet.h   "
+  ["extension"]=>
+  string(4) "h   "
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 35 --
+string(20) "   /usr/include/arpa"
+string(9) "inet.h   "
+string(4) "h   "
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(20) "   /usr/include/arpa"
+  ["basename"]=>
+  string(9) "inet.h   "
+  ["extension"]=>
+  string(4) "h   "
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 36 --
+string(1) "."
+string(3) " c:"
+string(0) ""
+string(3) " c:"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(3) " c:"
+  ["filename"]=>
+  string(3) " c:"
+}
+-- Iteration 37 --
+string(14) "           c:\test\adir"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(14) "         c:\test\adir"
+  ["basename"]=>
+  string(9) "afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 38 --
+string(1) "\"
+string(3) "usr"
+string(0) ""
+string(3) "usr"
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(3) "usr"
+  ["filename"]=>
+  string(3) "usr"
+}
+-- Iteration 39 --
+string(1) "\"
+string(3) "usr"
+string(0) ""
+string(3) "usr"
+array(3) {
+  ["dirname"]=>
+  string(1) "\"
+  ["basename"]=>
+  string(3) "usr"
+  ["filename"]=>
+  string(3) "usr"
+}
+Done
diff --git a/ext/standard/tests/file/pathinfo_basic1.phpt b/ext/standard/tests/file/pathinfo_basic1.phpt
new file mode 100644 (file)
index 0000000..61b183f
--- /dev/null
@@ -0,0 +1,609 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+   Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+                               '',
+                       ' ',
+                       'c:',
+                       'c:\\',
+                       'c:/',
+                       'afile',
+                       'c:\test\adir',
+                       'c:\test\adir\\',
+                       '/usr/include/arpa',
+                       '/usr/include/arpa/',
+                       'usr/include/arpa',
+                       'usr/include/arpa/',                    
+                       'c:\test\afile',
+                       'c:\\test\\afile',
+                       'c://test//afile',
+                       'c:\test\afile\\',
+                       'c:\test\prog.exe',
+                       'c:\\test\\prog.exe',
+                       'c:/test/prog.exe',                     
+                       '/usr/include/arpa/inet.h',
+                       '//usr/include//arpa/inet.h',
+                       '\\',
+                       '\\\\',
+                       '/',
+                       '//',
+                       '///',
+                       '/usr/include/arpa/inet.h',
+                       'c:\windows/system32\drivers/etc\hosts',
+                       '/usr\include/arpa\inet.h',
+                       '   c:\test\adir\afile.txt',
+                       'c:\test\adir\afile.txt   ',
+                       '   c:\test\adir\afile.txt   ',
+                       '   /usr/include/arpa/inet.h',
+                       '/usr/include/arpa/inet.h   ',
+                       '   /usr/include/arpa/inet.h   ',
+                       ' c:',
+                       '               c:\test\adir\afile.txt',
+                       '/usr',
+                       '/usr/'
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+  echo "-- Iteration $counter --\n";
+  var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+  var_dump( pathinfo($path, PATHINFO_BASENAME) );
+  var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+  var_dump( pathinfo($path, PATHINFO_FILENAME) );
+  var_dump( pathinfo($path) );
+  $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+array(2) {
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 2 --
+string(1) "."
+string(1) " "
+string(0) ""
+string(1) " "
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(1) " "
+  ["filename"]=>
+  string(1) " "
+}
+-- Iteration 3 --
+string(1) "."
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(2) "c:"
+  ["filename"]=>
+  string(2) "c:"
+}
+-- Iteration 4 --
+string(1) "."
+string(3) "c:\"
+string(0) ""
+string(3) "c:\"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(3) "c:\"
+  ["filename"]=>
+  string(3) "c:\"
+}
+-- Iteration 5 --
+string(1) "."
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(2) "c:"
+  ["filename"]=>
+  string(2) "c:"
+}
+-- Iteration 6 --
+string(1) "."
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 7 --
+string(1) "."
+string(12) "c:\test\adir"
+string(0) ""
+string(12) "c:\test\adir"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(12) "c:\test\adir"
+  ["filename"]=>
+  string(12) "c:\test\adir"
+}
+-- Iteration 8 --
+string(1) "."
+string(13) "c:\test\adir\"
+string(0) ""
+string(13) "c:\test\adir\"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(13) "c:\test\adir\"
+  ["filename"]=>
+  string(13) "c:\test\adir\"
+}
+-- Iteration 9 --
+string(12) "/usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(12) "/usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 10 --
+string(12) "/usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(12) "/usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 11 --
+string(11) "usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(11) "usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 12 --
+string(11) "usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+  ["dirname"]=>
+  string(11) "usr/include"
+  ["basename"]=>
+  string(4) "arpa"
+  ["filename"]=>
+  string(4) "arpa"
+}
+-- Iteration 13 --
+string(1) "."
+string(13) "c:\test\afile"
+string(0) ""
+string(13) "c:\test\afile"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(13) "c:\test\afile"
+  ["filename"]=>
+  string(13) "c:\test\afile"
+}
+-- Iteration 14 --
+string(1) "."
+string(13) "c:\test\afile"
+string(0) ""
+string(13) "c:\test\afile"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(13) "c:\test\afile"
+  ["filename"]=>
+  string(13) "c:\test\afile"
+}
+-- Iteration 15 --
+string(8) "c://test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(8) "c://test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 16 --
+string(1) "."
+string(14) "c:\test\afile\"
+string(0) ""
+string(14) "c:\test\afile\"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(14) "c:\test\afile\"
+  ["filename"]=>
+  string(14) "c:\test\afile\"
+}
+-- Iteration 17 --
+string(1) "."
+string(16) "c:\test\prog.exe"
+string(3) "exe"
+string(12) "c:\test\prog"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(16) "c:\test\prog.exe"
+  ["extension"]=>
+  string(3) "exe"
+  ["filename"]=>
+  string(12) "c:\test\prog"
+}
+-- Iteration 18 --
+string(1) "."
+string(16) "c:\test\prog.exe"
+string(3) "exe"
+string(12) "c:\test\prog"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(16) "c:\test\prog.exe"
+  ["extension"]=>
+  string(3) "exe"
+  ["filename"]=>
+  string(12) "c:\test\prog"
+}
+-- Iteration 19 --
+string(7) "c:/test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+  ["dirname"]=>
+  string(7) "c:/test"
+  ["basename"]=>
+  string(8) "prog.exe"
+  ["extension"]=>
+  string(3) "exe"
+  ["filename"]=>
+  string(4) "prog"
+}
+-- Iteration 20 --
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 21 --
+string(19) "//usr/include//arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(19) "//usr/include//arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 22 --
+string(1) "."
+string(1) "\"
+string(0) ""
+string(1) "\"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(1) "\"
+  ["filename"]=>
+  string(1) "\"
+}
+-- Iteration 23 --
+string(1) "."
+string(2) "\\"
+string(0) ""
+string(2) "\\"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(2) "\\"
+  ["filename"]=>
+  string(2) "\\"
+}
+-- Iteration 24 --
+string(1) "/"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "/"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 25 --
+string(1) "/"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "/"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 26 --
+string(1) "/"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+  ["dirname"]=>
+  string(1) "/"
+  ["basename"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 27 --
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 28 --
+string(27) "c:\windows/system32\drivers"
+string(9) "etc\hosts"
+string(0) ""
+string(9) "etc\hosts"
+array(3) {
+  ["dirname"]=>
+  string(27) "c:\windows/system32\drivers"
+  ["basename"]=>
+  string(9) "etc\hosts"
+  ["filename"]=>
+  string(9) "etc\hosts"
+}
+-- Iteration 29 --
+string(12) "/usr\include"
+string(11) "arpa\inet.h"
+string(1) "h"
+string(9) "arpa\inet"
+array(4) {
+  ["dirname"]=>
+  string(12) "/usr\include"
+  ["basename"]=>
+  string(11) "arpa\inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(9) "arpa\inet"
+}
+-- Iteration 30 --
+string(1) "."
+string(25) "   c:\test\adir\afile.txt"
+string(3) "txt"
+string(21) "   c:\test\adir\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(25) "   c:\test\adir\afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(21) "   c:\test\adir\afile"
+}
+-- Iteration 31 --
+string(1) "."
+string(25) "c:\test\adir\afile.txt   "
+string(6) "txt   "
+string(18) "c:\test\adir\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(25) "c:\test\adir\afile.txt   "
+  ["extension"]=>
+  string(6) "txt   "
+  ["filename"]=>
+  string(18) "c:\test\adir\afile"
+}
+-- Iteration 32 --
+string(1) "."
+string(28) "   c:\test\adir\afile.txt   "
+string(6) "txt   "
+string(21) "   c:\test\adir\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(28) "   c:\test\adir\afile.txt   "
+  ["extension"]=>
+  string(6) "txt   "
+  ["filename"]=>
+  string(21) "   c:\test\adir\afile"
+}
+-- Iteration 33 --
+string(20) "   /usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(20) "   /usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 34 --
+string(17) "/usr/include/arpa"
+string(9) "inet.h   "
+string(4) "h   "
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(9) "inet.h   "
+  ["extension"]=>
+  string(4) "h   "
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 35 --
+string(20) "   /usr/include/arpa"
+string(9) "inet.h   "
+string(4) "h   "
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(20) "   /usr/include/arpa"
+  ["basename"]=>
+  string(9) "inet.h   "
+  ["extension"]=>
+  string(4) "h   "
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 36 --
+string(1) "."
+string(3) " c:"
+string(0) ""
+string(3) " c:"
+array(3) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(3) " c:"
+  ["filename"]=>
+  string(3) " c:"
+}
+-- Iteration 37 --
+string(1) "."
+string(24) "           c:\test\adir\afile.txt"
+string(3) "txt"
+string(20) "           c:\test\adir\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(24) "         c:\test\adir\afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(20) "         c:\test\adir\afile"
+}
+-- Iteration 38 --
+string(1) "/"
+string(3) "usr"
+string(0) ""
+string(3) "usr"
+array(3) {
+  ["dirname"]=>
+  string(1) "/"
+  ["basename"]=>
+  string(3) "usr"
+  ["filename"]=>
+  string(3) "usr"
+}
+-- Iteration 39 --
+string(1) "/"
+string(3) "usr"
+string(0) ""
+string(3) "usr"
+array(3) {
+  ["dirname"]=>
+  string(1) "/"
+  ["basename"]=>
+  string(3) "usr"
+  ["filename"]=>
+  string(3) "usr"
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_basic2-win32.phpt b/ext/standard/tests/file/pathinfo_basic2-win32.phpt
new file mode 100644 (file)
index 0000000..c88bc25
--- /dev/null
@@ -0,0 +1,270 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+   Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+                       'c:\..\dir1',
+                       'c:\test\..\test2\.\adir\afile.txt',
+                       '/usr/include/../arpa/./inet.h',
+                       'c:\test\adir\afile..txt',
+                       '/usr/include/arpa/inet..h',
+                       'c:\test\adir\afile.',
+                       '/usr/include/arpa/inet.',
+                       '/usr/include/arpa/inet,h',
+                       'c:afile.txt',
+                       '..\.\..\test\afile.txt',
+                       '.././../test/afile',
+                       '.',
+                       '..',
+                       '...',
+                       '/usr/lib/.../afile'
+                                               
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+  echo "-- Iteration $counter --\n";
+  var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+  var_dump( pathinfo($path, PATHINFO_BASENAME) );
+  var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+  var_dump( pathinfo($path, PATHINFO_FILENAME) );
+  var_dump( pathinfo($path) );
+  $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+string(5) "c:\.."
+string(4) "dir1"
+string(0) ""
+string(4) "dir1"
+array(3) {
+  ["dirname"]=>
+  string(5) "c:\.."
+  ["basename"]=>
+  string(4) "dir1"
+  ["filename"]=>
+  string(4) "dir1"
+}
+-- Iteration 2 --
+string(23) "c:\test\..\test2\.\adir"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(23) "c:\test\..\test2\.\adir"
+  ["basename"]=>
+  string(9) "afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 3 --
+string(22) "/usr/include/../arpa/."
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(22) "/usr/include/../arpa/."
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 4 --
+string(12) "c:\test\adir"
+string(10) "afile..txt"
+string(3) "txt"
+string(6) "afile."
+array(4) {
+  ["dirname"]=>
+  string(12) "c:\test\adir"
+  ["basename"]=>
+  string(10) "afile..txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(6) "afile."
+}
+-- Iteration 5 --
+string(17) "/usr/include/arpa"
+string(7) "inet..h"
+string(1) "h"
+string(5) "inet."
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(7) "inet..h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(5) "inet."
+}
+-- Iteration 6 --
+string(12) "c:\test\adir"
+string(6) "afile."
+string(0) ""
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(12) "c:\test\adir"
+  ["basename"]=>
+  string(6) "afile."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 7 --
+string(17) "/usr/include/arpa"
+string(5) "inet."
+string(0) ""
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(5) "inet."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 8 --
+string(17) "/usr/include/arpa"
+string(6) "inet,h"
+string(0) ""
+string(6) "inet,h"
+array(3) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet,h"
+  ["filename"]=>
+  string(6) "inet,h"
+}
+-- Iteration 9 --
+string(3) "c:."
+string(11) "c:afile.txt"
+string(3) "txt"
+string(7) "c:afile"
+array(4) {
+  ["dirname"]=>
+  string(3) "c:."
+  ["basename"]=>
+  string(11) "c:afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(7) "c:afile"
+}
+-- Iteration 10 --
+string(12) "..\.\..\test"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+  ["dirname"]=>
+  string(12) "..\.\..\test"
+  ["basename"]=>
+  string(9) "afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 11 --
+string(12) ".././../test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(12) ".././../test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 12 --
+string(1) "."
+string(1) "."
+string(0) ""
+string(0) ""
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(1) "."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 13 --
+string(1) "."
+string(2) ".."
+string(0) ""
+string(1) "."
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(2) ".."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(1) "."
+}
+-- Iteration 14 --
+string(1) "."
+string(3) "..."
+string(0) ""
+string(2) ".."
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(3) "..."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(2) ".."
+}
+-- Iteration 15 --
+string(12) "/usr/lib/..."
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(12) "/usr/lib/..."
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_basic2.phpt b/ext/standard/tests/file/pathinfo_basic2.phpt
new file mode 100644 (file)
index 0000000..7bddda0
--- /dev/null
@@ -0,0 +1,272 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+   Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+                       'c:\..\dir1',
+                       'c:\test\..\test2\.\adir\afile.txt',
+                       '/usr/include/../arpa/./inet.h',
+                       'c:\test\adir\afile..txt',
+                       '/usr/include/arpa/inet..h',
+                       'c:\test\adir\afile.',
+                       '/usr/include/arpa/inet.',
+                       '/usr/include/arpa/inet,h',
+                       'c:afile.txt',
+                       '..\.\..\test\afile.txt',
+                       '.././../test/afile',
+                       '.',
+                       '..',
+                       '...',
+                       '/usr/lib/.../afile'
+                                               
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+  echo "-- Iteration $counter --\n";
+  var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+  var_dump( pathinfo($path, PATHINFO_BASENAME) );
+  var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+  var_dump( pathinfo($path, PATHINFO_FILENAME) );
+  var_dump( pathinfo($path) );
+  $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+string(1) "."
+string(10) "c:\..\dir1"
+string(5) "\dir1"
+string(4) "c:\."
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(10) "c:\..\dir1"
+  ["extension"]=>
+  string(5) "\dir1"
+  ["filename"]=>
+  string(4) "c:\."
+}
+-- Iteration 2 --
+string(1) "."
+string(33) "c:\test\..\test2\.\adir\afile.txt"
+string(3) "txt"
+string(29) "c:\test\..\test2\.\adir\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(33) "c:\test\..\test2\.\adir\afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(29) "c:\test\..\test2\.\adir\afile"
+}
+-- Iteration 3 --
+string(22) "/usr/include/../arpa/."
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(22) "/usr/include/../arpa/."
+  ["basename"]=>
+  string(6) "inet.h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 4 --
+string(1) "."
+string(23) "c:\test\adir\afile..txt"
+string(3) "txt"
+string(19) "c:\test\adir\afile."
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(23) "c:\test\adir\afile..txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(19) "c:\test\adir\afile."
+}
+-- Iteration 5 --
+string(17) "/usr/include/arpa"
+string(7) "inet..h"
+string(1) "h"
+string(5) "inet."
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(7) "inet..h"
+  ["extension"]=>
+  string(1) "h"
+  ["filename"]=>
+  string(5) "inet."
+}
+-- Iteration 6 --
+string(1) "."
+string(19) "c:\test\adir\afile."
+string(0) ""
+string(18) "c:\test\adir\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(19) "c:\test\adir\afile."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(18) "c:\test\adir\afile"
+}
+-- Iteration 7 --
+string(17) "/usr/include/arpa"
+string(5) "inet."
+string(0) ""
+string(4) "inet"
+array(4) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(5) "inet."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(4) "inet"
+}
+-- Iteration 8 --
+string(17) "/usr/include/arpa"
+string(6) "inet,h"
+string(0) ""
+string(6) "inet,h"
+array(3) {
+  ["dirname"]=>
+  string(17) "/usr/include/arpa"
+  ["basename"]=>
+  string(6) "inet,h"
+  ["filename"]=>
+  string(6) "inet,h"
+}
+-- Iteration 9 --
+string(1) "."
+string(11) "c:afile.txt"
+string(3) "txt"
+string(7) "c:afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(11) "c:afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(7) "c:afile"
+}
+-- Iteration 10 --
+string(1) "."
+string(22) "..\.\..\test\afile.txt"
+string(3) "txt"
+string(18) "..\.\..\test\afile"
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(22) "..\.\..\test\afile.txt"
+  ["extension"]=>
+  string(3) "txt"
+  ["filename"]=>
+  string(18) "..\.\..\test\afile"
+}
+-- Iteration 11 --
+string(12) ".././../test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(12) ".././../test"
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+-- Iteration 12 --
+string(1) "."
+string(1) "."
+string(0) ""
+string(0) ""
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(1) "."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+-- Iteration 13 --
+string(1) "."
+string(2) ".."
+string(0) ""
+string(1) "."
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(2) ".."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(1) "."
+}
+-- Iteration 14 --
+string(1) "."
+string(3) "..."
+string(0) ""
+string(2) ".."
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(3) "..."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(2) ".."
+}
+-- Iteration 15 --
+string(12) "/usr/lib/..."
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+  ["dirname"]=>
+  string(12) "/usr/lib/..."
+  ["basename"]=>
+  string(5) "afile"
+  ["filename"]=>
+  string(5) "afile"
+}
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_variation1.phpt b/ext/standard/tests/file/pathinfo_variation1.phpt
new file mode 100644 (file)
index 0000000..ff4c1eb
--- /dev/null
@@ -0,0 +1,190 @@
+--TEST--
+Test pathinfo() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array pathinfo(string path[, int options])
+ * Description: Returns information about a certain string 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing pathinfo() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$options = PATHINFO_DIRNAME;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for path
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( pathinfo($value, $options) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pathinfo() : usage variation ***
+
+--int 0--
+string(1) "."
+
+--int 1--
+string(1) "."
+
+--int 12345--
+string(1) "."
+
+--int -12345--
+string(1) "."
+
+--float 10.5--
+string(1) "."
+
+--float -10.5--
+string(1) "."
+
+--float 12.3456789000e10--
+string(1) "."
+
+--float -12.3456789000e10--
+string(1) "."
+
+--float .5--
+string(1) "."
+
+--empty array--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(1) "."
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(1) "."
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+string(0) ""
+
+--empty string SQ--
+string(0) ""
+
+--instance of classWithToString--
+string(1) "."
+
+--instance of classWithoutToString--
+Error: 2 - pathinfo() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
diff --git a/ext/standard/tests/file/pathinfo_variation2.phpt b/ext/standard/tests/file/pathinfo_variation2.phpt
new file mode 100644 (file)
index 0000000..9d18a4b
--- /dev/null
@@ -0,0 +1,197 @@
+--TEST--
+Test pathinfo() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array pathinfo(string path[, int options])
+ * Description: Returns information about a certain string 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing pathinfo() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$path = '/usr/include/arpa/inet.h';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for options
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( pathinfo($path, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pathinfo() : usage variation ***
+
+--float 10.5--
+string(6) "inet.h"
+
+--float -10.5--
+string(6) "inet.h"
+
+--float 12.3456789000e10--
+string(%d) %s
+
+--float -12.3456789000e10--
+string(%d) %s
+
+--float .5--
+string(%d) %s
+
+--empty array--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(17) "/usr/include/arpa"
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(17) "/usr/include/arpa"
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - pathinfo() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - pathinfo() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
diff --git a/ext/standard/tests/file/pathinfo_variation3.phpt b/ext/standard/tests/file/pathinfo_variation3.phpt
new file mode 100644 (file)
index 0000000..333aa56
--- /dev/null
@@ -0,0 +1,80 @@
+--TEST--
+Test pathinfo() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : array pathinfo(string path[, int options])
+ * Description: Returns information about a certain string 
+ * Source code: ext/standard/string.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing pathinfo() : usage variation ***\n";
+
+$testfile = "/usr/include/arpa/inet.h";
+
+var_dump(pathinfo("./"));
+var_dump(pathinfo("/."));
+var_dump(pathinfo(".cvsignore"));
+var_dump(pathinfo($testfile, PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_FILENAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION));
+var_dump(pathinfo($testfile, PATHINFO_DIRNAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_FILENAME|PATHINFO_DIRNAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_FILENAME|PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_FILENAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_FILENAME|PATHINFO_DIRNAME));
+var_dump(pathinfo($testfile, PATHINFO_FILENAME|PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_DIRNAME|PATHINFO_EXTENSION));
+var_dump(pathinfo($testfile, PATHINFO_DIRNAME|PATHINFO_BASENAME));
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pathinfo() : usage variation ***
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(1) "."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+array(4) {
+  ["dirname"]=>
+  string(1) "%s"
+  ["basename"]=>
+  string(1) "."
+  ["extension"]=>
+  string(0) ""
+  ["filename"]=>
+  string(0) ""
+}
+array(4) {
+  ["dirname"]=>
+  string(1) "."
+  ["basename"]=>
+  string(10) ".cvsignore"
+  ["extension"]=>
+  string(9) "cvsignore"
+  ["filename"]=>
+  string(0) ""
+}
+string(6) "inet.h"
+string(4) "inet"
+string(1) "h"
+string(17) "/usr/include/arpa"
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(6) "inet.h"
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(17) "/usr/include/arpa"
+string(17) "/usr/include/arpa"
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/pclose_variation1.phpt b/ext/standard/tests/file/pclose_variation1.phpt
new file mode 100644 (file)
index 0000000..07b5f3f
--- /dev/null
@@ -0,0 +1,232 @@
+--TEST--
+Test pclose() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int pclose(resource fp)
+ * Description: Close a file pointer opened by popen() 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing pclose() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for fp
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( pclose($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pclose() : usage variation ***
+
+--int 0--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - pclose() expects parameter 1 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - pclose() expects parameter 1 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+===DONE===
+
index 4c85c9e49425b3e6e27254fd7a3d95368ea130c6..b63dbeb7eadfabfa4b2d90e953a199b1494f62a2 100644 (file)
@@ -2,8 +2,8 @@
 Test popen() and pclose function: error conditions
 --SKIPIF--
 <?php
-if(substr(PHP_OS, 0, 3) != 'Sun' )
-  die("skip Only Valid for Sun Solaris");
+if( substr(PHP_OS, 0, 3) != 'Sun')
+  die("skip Only valid for Sun Solaris");
 ?>
 
 --FILE--
@@ -35,13 +35,13 @@ unlink($file_path."/popen.tmp");
 --EXPECTF--
 *** Testing for error conditions ***
 
-Warning: popen() expects exactly 2 parameters, 0 given in %s on line %d
+Warning: Wrong parameter count for popen() in %s on line %d
 NULL
 
-Warning: popen() expects exactly 2 parameters, 1 given in %s on line %d
+Warning: Wrong parameter count for popen() in %s on line %d
 NULL
-resource(%d) of type (stream)
 sh: abc.txt: not found
+resource(%d) of type (stream)
 
 Warning: Wrong parameter count for pclose() in %s on line %d
 NULL
diff --git a/ext/standard/tests/file/readfile_variation10-win32.phpt b/ext/standard/tests/file/readfile_variation10-win32.phpt
new file mode 100644 (file)
index 0000000..6fa905a
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+Test readfile() function : variation - various invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+
+
+/* An array of files */ 
+$names_arr = array(
+  /* Invalid args */ 
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  "\0",
+  array(),
+
+  /* prefix with path separator of a non existing directory*/
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  $name = $names_arr[$i];
+  echo "-- testing '$name' --\n";  
+  readfile($name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing readfile() : variation ***
+-- testing '-1' --
+
+Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d
+-- testing '1' --
+
+Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
+-- testing '' --
+-- testing '' --
+-- testing '' --
+-- testing ' ' --
+
+Warning: readfile( ): failed to open stream: Permission denied in %s on line %d
+-- testing '%s' --
+-- testing 'Array' --
+
+Warning: readfile() expects parameter 1 to be string, array given in %s on line %d
+-- testing '/no/such/file/dir' --
+
+Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+-- testing 'php/php' --
+
+Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/readfile_variation10.phpt b/ext/standard/tests/file/readfile_variation10.phpt
new file mode 100644 (file)
index 0000000..3ee1a90
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+Test readfile() function : variation - various invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+
+
+/* An array of files */ 
+$names_arr = array(
+  /* Invalid args */ 
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  "\0",
+  array(),
+
+  /* prefix with path separator of a non existing directory*/
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  $name = $names_arr[$i];
+  echo "-- testing '$name' --\n";  
+  readfile($name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing readfile() : variation ***
+-- testing '-1' --
+
+Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d
+-- testing '1' --
+
+Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
+-- testing '' --
+-- testing '' --
+-- testing '' --
+-- testing ' ' --
+
+Warning: readfile( ): failed to open stream: No such file or directory in %s on line %d
+-- testing '%s' --
+-- testing 'Array' --
+
+Warning: readfile() expects parameter 1 to be string, array given in %s on line %d
+-- testing '/no/such/file/dir' --
+
+Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+-- testing 'php/php' --
+
+Warning: readfile(php/php): failed to open stream: %s directory in %s on line %d
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/readfile_variation4.phpt b/ext/standard/tests/file/readfile_variation4.phpt
new file mode 100644 (file)
index 0000000..94b3326
--- /dev/null
@@ -0,0 +1,251 @@
+--TEST--
+Test readfile() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing readfile() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'readFileVar4.tmp';
+$use_include_path = false;
+$h = fopen($filename,'wb');
+fwrite($h, "testing readfile");
+fclose($h);
+
+
+$fileRes = fopen(__FILE__, 'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // file resource
+      'file resource' => $fileRes,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $h = readfile($filename, $use_include_path, $value);
+      if ($h == false) {
+         echo "file not read\n";
+      }
+      else {
+         echo "\n";
+      }
+};
+
+unlink($filename);
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing readfile() : usage variation ***
+
+--int 0--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--int 1--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--int 12345--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--int -12345--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--float 10.5--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float -10.5--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float 12.3456789000e10--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float -12.3456789000e10--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float .5--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--empty array--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--int indexed array--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--associative array--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--nested arrays--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--uppercase NULL--
+testing readfile
+
+--lowercase null--
+testing readfile
+
+--lowercase true--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--lowercase false--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--uppercase TRUE--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--uppercase FALSE--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--empty string DQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--empty string SQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--string DQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--string SQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--mixed case string--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--heredoc--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--instance of classWithToString--
+Error: 2 - readfile() expects parameter 3 to be resource, object given, %s(%d)
+file not read
+
+--instance of classWithoutToString--
+Error: 2 - readfile() expects parameter 3 to be resource, object given, %s(%d)
+file not read
+
+--undefined var--
+testing readfile
+
+--unset var--
+testing readfile
+
+--file resource--
+Error: 2 - readfile(): supplied resource is not a valid Stream-Context resource, %s(%d)
+testing readfile
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation5.phpt b/ext/standard/tests/file/readfile_variation5.phpt
new file mode 100644 (file)
index 0000000..21856f8
--- /dev/null
@@ -0,0 +1,221 @@
+--TEST--
+Test readfile() function : usage variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing readfile() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'readFileVar5.tmp';
+$use_include_path = false;
+$h = fopen($filename,'wb');
+fwrite($h, "testing readfile");
+fclose($h);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for use_include_path
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      $res = readfile($filename, $value);
+      if ($res == false) {
+         echo "File not read\n";
+      }
+      else {
+         echo "\n";
+      }
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing readfile() : usage variation ***
+
+--int 0--
+testing readfile
+
+--int 1--
+testing readfile
+
+--int 12345--
+testing readfile
+
+--int -12345--
+testing readfile
+
+--float 10.5--
+testing readfile
+
+--float -10.5--
+testing readfile
+
+--float 12.3456789000e10--
+testing readfile
+
+--float -12.3456789000e10--
+testing readfile
+
+--float .5--
+testing readfile
+
+--empty array--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--int indexed array--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--associative array--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--nested arrays--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--uppercase NULL--
+testing readfile
+
+--lowercase null--
+testing readfile
+
+--lowercase true--
+testing readfile
+
+--lowercase false--
+testing readfile
+
+--uppercase TRUE--
+testing readfile
+
+--uppercase FALSE--
+testing readfile
+
+--empty string DQ--
+testing readfile
+
+--empty string SQ--
+testing readfile
+
+--string DQ--
+testing readfile
+
+--string SQ--
+testing readfile
+
+--mixed case string--
+testing readfile
+
+--heredoc--
+testing readfile
+
+--instance of classWithToString--
+Error: 2 - readfile() expects parameter 2 to be boolean, object given, %s(%d)
+File not read
+
+--instance of classWithoutToString--
+Error: 2 - readfile() expects parameter 2 to be boolean, object given, %s(%d)
+File not read
+
+--undefined var--
+testing readfile
+
+--unset var--
+testing readfile
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation6.phpt b/ext/standard/tests/file/readfile_variation6.phpt
new file mode 100644 (file)
index 0000000..02e7082
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+Test readfile() function : variation - test include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing readfile() : variation ***\n";
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "readfileVar6.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "afile.txt";
+$secondFile = $dir2."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $secondFile, $filename;
+   $h = fopen($secondFile, "w");
+   fwrite($h, "File in include path");
+   fclose($h);
+   readfile($filename, true);
+   echo "\n";
+   unlink($secondFile);  
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing readfile() : variation ***
+File in include path
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation7.phpt b/ext/standard/tests/file/readfile_variation7.phpt
new file mode 100644 (file)
index 0000000..d26f52f
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+Test readfile() function : variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing readfile() : variation ***\n";
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "readfileVar7.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "readFileVar7.tmp";
+$scriptLocFile = dirname(__FILE__)."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+   global $scriptLocFile, $filename;
+   $h = fopen($scriptLocFile, "w");
+   fwrite($h, "File in script location");
+   fclose($h);
+   readfile($filename, true);
+   echo "\n";
+   unlink($scriptLocFile);  
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing readfile() : variation ***
+File in script location
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation8-win32.phpt b/ext/standard/tests/file/readfile_variation8-win32.phpt
new file mode 100644 (file)
index 0000000..a66af5d
--- /dev/null
@@ -0,0 +1,109 @@
+--TEST--
+Test readfile() function : variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+$mainDir = "readfileVar8";
+$subDir = "readfileVar8Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$theFile = "fileToRead.tmp";
+$absFile = $absSubDir.'/'.$theFile;
+
+// create the file
+$h = fopen($absFile,"w");
+fwrite($h, "The File Contents");
+fclose($h);
+
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir\\",
+  "$absSubDir\\..\\".$subDir,
+  "$absSubDir\\\\..\\.\\".$subDir,
+  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+  "$absSubDir\\BADDIR",
+  
+  // relative paths
+  $mainDir."\\".$subDir,
+  $mainDir."\\\\".$subDir, 
+   $mainDir."\\\\\\".$subDir, 
+  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+  "BADDIR",  
+  
+  // unixifed path
+  $unixifiedDir,
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- $dir --\n";
+  $ok = readfile($dir.'\\'.$theFile);
+  if ($ok === 1) {
+     echo "\n";
+  }
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing readfile() : variation ***
+
+-- %s\readfileVar8\readfileVar8Sub\ --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\..\readfileVar8Sub --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\\..\.\readfileVar8Sub --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\..\..\readfileVar8\.\readfileVar8Sub --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\..\\\readfileVar8Sub\\..\\..\readfileVar8Sub --
+
+Warning: readfile(%s\readfileVar8\readfileVar8Sub\..\\\readfileVar8Sub\\..\\..\readfileVar8Sub\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- %s\readfileVar8\readfileVar8Sub\BADDIR --
+
+Warning: readfile(%s\readfileVar8\readfileVar8Sub\BADDIR\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- readfileVar8\readfileVar8Sub --
+The File Contents
+-- readfileVar8\\readfileVar8Sub --
+The File Contents
+-- readfileVar8\\\readfileVar8Sub --
+The File Contents
+-- .\readfileVar8\..\readfileVar8\readfileVar8Sub --
+The File Contents
+-- BADDIR --
+
+Warning: readfile(BADDIR\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- /%s/readfileVar8/readfileVar8Sub --
+The File Contents
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/readfile_variation9.phpt b/ext/standard/tests/file/readfile_variation9.phpt
new file mode 100644 (file)
index 0000000..c802f40
--- /dev/null
@@ -0,0 +1,99 @@
+--TEST--
+Test readfile() function : variation - variable types of path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+$mainDir = "readfileVar8";
+$subDir = "readfileVar8Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$theFile = "fileToRead.tmp";
+$absFile = $absSubDir.'/'.$theFile;
+
+// create the file
+$h = fopen($absFile,"w");
+fwrite($h, "The File Contents");
+fclose($h);
+
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  $ok = readfile($dir.'/'.$theFile);
+  if ($ok === 1) {
+     echo "\n";
+  }
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing readfile() : variation ***
+
+-- Iteration 1 --
+The File Contents
+-- Iteration 2 --
+The File Contents
+-- Iteration 3 --
+The File Contents
+-- Iteration 4 --
+The File Contents
+-- Iteration 5 --
+
+Warning: readfile(%sreadfileVar8Sub/..///readfileVar8Sub//..//../readfileVar8Sub/fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- Iteration 6 --
+
+Warning: readfile(%sreadfileVar8Sub/BADDIR/fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- Iteration 7 --
+The File Contents
+-- Iteration 8 --
+The File Contents
+-- Iteration 9 --
+The File Contents
+-- Iteration 10 --
+The File Contents
+-- Iteration 11 --
+
+Warning: readfile(BADDIR/fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+*** Done ***
\ No newline at end of file
index e2a076c947c32faaf5d34d5d72cf2d0e60c3cf56..99195e2b2436f53736ec363ebfffb677209de7b6 100644 (file)
@@ -39,9 +39,6 @@ $linknames = array (
   "$file_path/readlink_realpath_basic1/home/test/readlink_realpath_basic1_link.tmp",
   "$file_path/readlink_realpath_basic1//home/test//../test/./readlink_realpath_basic1_link.tmp",
   
-  // checking for binary safe
-  b"$file_path/readlink_realpath_basic1/home/readlink_realpath_basic1_link.tmp",
-
   /* linknames with invalid linkpath */
   "$file_path///readlink_realpath_basic1/home//..//././test//readlink_realpath_basic1_link.tmp",
   "$file_path/readlink_realpath_basic1/home/../home/../test/../readlink_realpath_basic1_link.tmp",
@@ -89,28 +86,24 @@ string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp"
 string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp"
 
 -- Iteration 4 --
-string(%d) "%s/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp"
-string(%d) "%s/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp"
-
--- Iteration 5 --
 
 Warning: readlink(): No such file or directory in %s on line %d
 bool(false)
 bool(false)
 
--- Iteration 6 --
+-- Iteration 5 --
 
 Warning: readlink(): No such file or directory in %s on line %d
 bool(false)
 bool(false)
 
--- Iteration 7 --
+-- Iteration 6 --
 
 Warning: readlink(): No such file or directory in %s on line %d
 bool(false)
 %s
 
--- Iteration 8 --
+-- Iteration 7 --
 
 Warning: readlink(): %s in %s on line %d
 bool(false)
index 7a9e741ef0b921e333527ffbb1ece60ca9775adc..91955cd4f5fd60a2d7ed88bee7de312ed3f01eac 100644 (file)
@@ -34,9 +34,6 @@ $filenames = array (
   "$file_path/readlink_realpath_basic2//home/test//../test/./readlink_realpath_basic2.tmp",
   "$file_path/readlink_realpath_basic2/home//../././readlink_realpath_basic2.tmp",
 
-  // checking for binary safe
-  b"$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp",
-
   /* filenames with invalid path */
   "$file_path///readlink_realpath_basic2/home//..//././test//readlink_realpath_basic2.tmp",
   "$file_path/readlink_realpath_basic2/home/../home/../test/../readlink_realpath_basic2.tmp",
@@ -79,14 +76,11 @@ string(%d) "%s/readlink_realpath_basic2/home/test/readlink_realpath_basic2.tmp"
 string(%d) "%s/readlink_realpath_basic2/readlink_realpath_basic2.tmp"
 
 -- Iteration 5 --
-string(%d) "%s/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp"
+bool(false)
 
 -- Iteration 6 --
 bool(false)
 
 -- Iteration 7 --
-bool(false)
-
--- Iteration 8 --
 %s
 Done
diff --git a/ext/standard/tests/file/readlink_variation1.phpt b/ext/standard/tests/file/readlink_variation1.phpt
new file mode 100644 (file)
index 0000000..49dc6a5
--- /dev/null
@@ -0,0 +1,78 @@
+--TEST--
+Test readlink() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no links on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+   Description: Returns the target of a symbolic link */
+
+/* Testing readlink() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/readlink_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+  /* Invalid filenames */
+  -2.34555,
+  "",
+  TRUE,
+  FALSE,
+  NULL,
+  $file_handle,
+  
+  /* scalars */
+  1234,
+  0
+);
+   
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+  var_dump( readlink($filename) );
+  clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/readlink_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/realpath_variation2.phpt b/ext/standard/tests/file/realpath_variation2.phpt
new file mode 100644 (file)
index 0000000..a5031aa
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+Test realpath() function : variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+  die("skip Not Valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : string realpath(string path)
+ * Description: Return the resolved path 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing realpath() : variation ***\n";
+
+$paths = array('c:\\', 
+               'c:', 
+               'c' , 
+               '\\' , 
+               '/', 
+               'c:temp', 
+               'c:\\/', 
+               '/tmp/',
+               '/tmp/\\', 
+               '\\tmp',                 
+               '\\tmp\\');
+
+foreach($paths as $path) {
+      echo "\n--$path--\n";
+      var_dump( realpath($path) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing realpath() : variation ***
+
+--c:\--
+bool(false)
+
+--c:--
+bool(false)
+
+--c--
+bool(false)
+
+--\--
+bool(false)
+
+--/--
+string(1) "/"
+
+--c:temp--
+bool(false)
+
+--c:\/--
+bool(false)
+
+--/tmp/--
+string(%d) %s/tmp"
+
+--/tmp/\--
+bool(false)
+
+--\tmp--
+bool(false)
+
+--\tmp\--
+bool(false)
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/rename_variation10.phpt b/ext/standard/tests/file/rename_variation10.phpt
new file mode 100644 (file)
index 0000000..fbb109c
--- /dev/null
@@ -0,0 +1,253 @@
+--TEST--
+Test rename() function : usage variation - different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rename() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$old_name = __FILE__.'.tmp';
+$new_name = __FILE__.'.renamed';
+
+//file resource
+$fileRes = fopen(__FILE__, 'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // file resource
+      'file resource' => $fileRes,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      touch($old_name);
+      $res = rename($old_name, $new_name, $value);
+      var_dump($res);
+      if ($res == true) {
+         unlink($new_name);
+      }
+      else {
+         unlink($old_name);
+      }
+};
+
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rename() : usage variation ***
+
+--int 0--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - rename() expects parameter 3 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - rename() expects parameter 3 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--file resource--
+Error: 2 - rename(): supplied resource is not a valid Stream-Context resource, %s(%d)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/rename_variation11-win32.phpt b/ext/standard/tests/file/rename_variation11-win32.phpt
new file mode 100644 (file)
index 0000000..d17b0d2
--- /dev/null
@@ -0,0 +1,128 @@
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir\\",
+  "$absSubDir\\..\\".$subDir,
+  "$absSubDir\\\\..\\.\\".$subDir,
+  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+  "$absSubDir\\BADDIR",
+  
+  // relative paths
+  $mainDir."\\".$subDir,
+  $mainDir."\\\\".$subDir, 
+   $mainDir."\\\\\\".$subDir, 
+  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+  "BADDIR",  
+  
+  // unixifed path
+  $unixifiedDir,
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  touch($absSubDir."\\".$fromFile);
+  $res = rename($dir."\\".$fromFile, $dir."\\".$toFile);
+  var_dump($res);
+  if ($res == true) {
+     $res = rename($dir."\\".$toFile, $dir."\\".$fromFile);
+     var_dump($res);
+  }
+  unlink($absSubDir."\\".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+bool(true)
+bool(true)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/rename_variation12.phpt b/ext/standard/tests/file/rename_variation12.phpt
new file mode 100644 (file)
index 0000000..11274f0
--- /dev/null
@@ -0,0 +1,117 @@
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+  // absolute paths
+  "$absSubDir/",
+  "$absSubDir/../".$subDir,
+  "$absSubDir//.././".$subDir,
+  "$absSubDir/../../".$mainDir."/./".$subDir,
+  "$absSubDir/..///".$subDir."//..//../".$subDir,
+  "$absSubDir/BADDIR",
+  
+  
+  // relative paths
+  $mainDir."/".$subDir,
+  $mainDir."//".$subDir, 
+   $mainDir."///".$subDir, 
+  "./".$mainDir."/../".$mainDir."/".$subDir,
+  "BADDIR",  
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+  $j = $i+1;
+  $dir = $allDirs[$i];
+  echo "\n-- Iteration $j --\n";
+  touch($absSubDir."/".$fromFile);
+  $res = rename($dir."/".$fromFile, $dir."/".$toFile);
+  var_dump($res);
+  if ($res == true) {
+     $res = rename($dir."/".$toFile, $dir."/".$fromFile);
+     var_dump($res);
+  }
+  unlink($absSubDir."/".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt
new file mode 100644 (file)
index 0000000..2900956
Binary files /dev/null and b/ext/standard/tests/file/rename_variation13-win32.phpt differ
diff --git a/ext/standard/tests/file/rename_variation13.phpt b/ext/standard/tests/file/rename_variation13.phpt
new file mode 100644 (file)
index 0000000..1237604
--- /dev/null
@@ -0,0 +1,132 @@
+--TEST--
+Test rename() function : variation - various invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+
+echo "*** Testing rename() with obscure files ***\n";
+$file_path = dirname(__FILE__)."/renameVar13";
+$aFile = $file_path.'/afile.tmp';
+
+mkdir($file_path);
+
+/* An array of files */ 
+$names_arr = array(
+  /* Invalid args */ 
+  -1,
+  TRUE,
+  FALSE,
+  NULL,
+  "",
+  " ",
+  "\0",
+  array(),
+
+  /* prefix with path separator of a non existing directory*/
+  "/no/such/file/dir", 
+  "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+  $name = $names_arr[$i];
+  echo "-- testing '$name' --\n";  
+  touch($aFile);
+  var_dump(rename($aFile, $name));
+  if (file_exists($name)) {
+     unlink($name);
+  }
+  if (file_exists($aFile)) {
+     unlink($aFile);
+  }
+  var_dump(rename($name, $aFile));
+  if (file_exists($aFile)) {
+     unlink($aFile);
+  }
+}
+
+rmdir($file_path);
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with obscure files ***
+-- testing '-1' --
+bool(true)
+
+Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '1' --
+bool(true)
+
+Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing ' ' --
+bool(true)
+
+Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '%s' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing 'Array' --
+
+Warning: rename() expects parameter 2 to be string, array given in %s on line %d
+bool(false)
+
+Warning: file_exists() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: rename() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+-- testing '/no/such/file/dir' --
+
+Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
+bool(false)
+
+Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing 'php/php' --
+
+Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
+bool(false)
+
+Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/rmdir_variation1-win32.phpt b/ext/standard/tests/file/rmdir_variation1-win32.phpt
new file mode 100644 (file)
index 0000000..0732821
--- /dev/null
@@ -0,0 +1,127 @@
+--TEST--
+Test rmdir() function : usage variation - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rmdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase false' =>false,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // other
+      // php outputs Permission Denied, p8 outputs no suck file or dir
+      'single space' => ' ',
+);
+
+// loop through each element of the array for dirname
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( rmdir($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--single space--
+Error: 2 - rmdir( ): %s, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/rmdir_variation1.phpt b/ext/standard/tests/file/rmdir_variation1.phpt
new file mode 100644 (file)
index 0000000..d219e6c
--- /dev/null
@@ -0,0 +1,127 @@
+--TEST--
+Test rmdir() function : usage variation - invalid file names
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype  : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rmdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase false' =>false,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // other
+      'single space' => ' ',
+);
+
+// loop through each element of the array for dirname
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( rmdir($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rmdir(): No such file or directory, %s(%d)
+bool(false)
+
+--single space--
+Error: 2 - rmdir( ): No such file or directory, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/rmdir_variation2.phpt b/ext/standard/tests/file/rmdir_variation2.phpt
new file mode 100644 (file)
index 0000000..2cee440
--- /dev/null
@@ -0,0 +1,244 @@
+--TEST--
+Test rmdir() function : usage variation - different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rmdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$dirname = 'rmdirVar2.tmp';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+$fileres = fopen(__FILE__, 'r');
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // non stream context resource
+      $fileres,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      @mkdir($dirname);
+      var_dump( rmdir($dirname, $value) );
+};
+
+@rmdir($dirname);
+fclose($fileres);
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : usage variation ***
+
+--int 0--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--0--
+Error: 2 - rmdir(): supplied resource is not a valid Stream-Context resource, %s(%d)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/rmdir_variation3-win32.phpt b/ext/standard/tests/file/rmdir_variation3-win32.phpt
new file mode 100644 (file)
index 0000000..e6b3eaa
--- /dev/null
@@ -0,0 +1,108 @@
+--TEST--
+Test rmdir() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>  
+--FILE--
+<?php
+/* Prototype  : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rmdir() : variation ***\n";
+
+$workDir = "rmdirVar3.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDir, 3);
+
+$dirs = array(
+             // relative
+             $workDir.'\\'.$subDir,
+             '.\\'.$workDir.'\\'.$subDir,
+             $workDir.'\\..\\'.$workDir.'\\'.$subDir,
+             
+             // relative bad path
+             $workDir.'\\..\\BADDIR\\'.$subDir,
+             'BADDIR\\'.$subDir,
+             
+             //absolute
+             $cwd.'\\'.$workDir.'\\'.$subDir,
+             $cwd.'\\.\\'.$workDir.'\\'.$subDir,
+             $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDir,
+
+             //absolute bad path             
+             $cwd.'\\BADDIR\\'.$subDir,
+             
+             //trailing separators
+             $workDir.'\\'.$subDir.'\\',
+             $cwd.'\\'.$workDir.'\\'.$subDir.'\\',
+             
+             // multiple separators
+             $workDir.'\\\\'.$subDir,
+             $cwd.'\\\\'.$workDir.'\\\\'.$subDir,
+             
+             // Unixified Dir
+             $unixifiedDir,             
+             
+             );
+             
+
+foreach($dirs as $dir) {
+   mkdir($workDir.'/'.$subDir);
+   echo "-- removing $dir --\n";           
+   $res = rmdir($dir);
+   if ($res === true) {
+      echo "Directory removed\n";
+   }
+   else {
+      rmdir($workDir.'/'.$subDir);
+   }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : variation ***
+-- removing rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing .\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp\..\BADDIR\aSubDir --
+
+Warning: rmdir(rmdirVar3.tmp\..\BADDIR\aSubDir): No such file or directory in %s on line %d
+-- removing BADDIR\aSubDir --
+
+Warning: rmdir(BADDIR\aSubDir): No such file or directory in %s on line %d
+-- removing %s\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing %s\.\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing %s\rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing %s\BADDIR\aSubDir --
+
+Warning: rmdir(%s\BADDIR\aSubDir): No such file or directory in %s on line %d
+-- removing rmdirVar3.tmp\aSubDir\ --
+Directory removed
+-- removing %s\rmdirVar3.tmp\aSubDir\ --
+Directory removed
+-- removing rmdirVar3.tmp\\aSubDir --
+Directory removed
+-- removing %s\\rmdirVar3.tmp\\aSubDir --
+Directory removed
+-- removing /%s/rmdirVar3.tmp/aSubDir --
+Directory removed
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/rmdir_variation3.phpt b/ext/standard/tests/file/rmdir_variation3.phpt
new file mode 100644 (file)
index 0000000..5848007
--- /dev/null
@@ -0,0 +1,96 @@
+--TEST--
+Test rmdir() function : variation: various valid and invalid paths 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing rmdir() : variation ***\n";
+
+$workDir = "rmdirVar3.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$dirs = array(
+             // relative
+             $workDir.'/'.$subDir,
+             './'.$workDir.'/'.$subDir,
+             $workDir.'/../'.$workDir.'/'.$subDir,
+             
+             // relative bad path
+             $workDir.'/../BADDIR/'.$subDir,
+             'BADDIR/'.$subDir,
+             
+             //absolute
+             $cwd.'/'.$workDir.'/'.$subDir,
+             $cwd.'/./'.$workDir.'/'.$subDir,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDir,
+
+             //absolute bad path             
+             $cwd.'/BADDIR/'.$subDir,
+             
+             //trailing separators
+             $workDir.'/'.$subDir.'/',
+             $cwd.'/'.$workDir.'/'.$subDir.'/',
+             
+             // multiple separators
+             $workDir.'//'.$subDir,
+             $cwd.'//'.$workDir.'//'.$subDir,
+             
+             );
+             
+
+foreach($dirs as $dir) {
+   mkdir($workDir.'/'.$subDir);
+   echo "-- removing $dir --\n";           
+   $res = rmdir($dir);
+   if ($res === true) {
+      echo "Directory removed\n";
+   }
+   else {
+      rmdir($workDir.'/'.$subDir);
+   }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : variation ***
+-- removing rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing ./rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp/../rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp/../BADDIR/aSubDir --
+
+Warning: rmdir(rmdirVar3.tmp/../BADDIR/aSubDir): No such file or directory in %s on line %d
+-- removing BADDIR/aSubDir --
+
+Warning: rmdir(BADDIR/aSubDir): No such file or directory in %s on line %d
+-- removing %s/rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing %s/./rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing %s/rmdirVar3.tmp/../rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing %s/BADDIR/aSubDir --
+
+Warning: rmdir(%s/BADDIR/aSubDir): No such file or directory in %s on line %d
+-- removing rmdirVar3.tmp/aSubDir/ --
+Directory removed
+-- removing %s/rmdirVar3.tmp/aSubDir/ --
+Directory removed
+-- removing rmdirVar3.tmp//aSubDir --
+Directory removed
+-- removing %s//rmdirVar3.tmp//aSubDir --
+Directory removed
+===DONE===
\ No newline at end of file
index 3bee688d87f13cb99d7ce5d69e1a449577de5038..98ce6211dad8f8ac6ad6d38c7a41175376457650 100644 (file)
@@ -5,7 +5,7 @@ Test symlink(), linkinfo(), link() and is_link() functions : error conditions -
 if (substr(PHP_OS, 0, 3) == 'WIN') {
     die('skip no symlinks on Windows');
 }
-if (PHP_INT_SIZE != 4 ) {
+if (PHP_INT_SIZE != 4) {
   die("skip this test is for 32bit platform only");
 }
 ?>
@@ -42,6 +42,7 @@ var_dump( link($filename, $linkname, false) );
 //invalid arguments
 var_dump( link(NULL, $linkname) );  // NULL as filename
 var_dump( link('', $linkname) );  // empty string as filename
+var_dump( link(' ', $linkname) );  // space as filename
 var_dump( link(false, $linkname) );  // boolean false as filename
 var_dump( link($filename, NULL) );  // NULL as linkname
 var_dump( link($filename, '') );  // '' as linkname
@@ -57,6 +58,7 @@ var_dump( is_link($linkname, "/") );
 //invalid arguments
 var_dump( is_link(NULL) );  // NULL as linkname
 var_dump( is_link('') );  // empty string as linkname
+var_dump( is_link(' ') );  // space as linkname
 var_dump( is_link(false) );  // boolean false as linkname
 var_dump( is_link($filename) );  // file given to is_link
 
@@ -75,22 +77,25 @@ NULL
 Warning: link() expects exactly 2 parameters, 3 given in %s on line %d
 NULL
 
-Warning: link(): %s in %s on line %d
+Warning: link(): No such file or directory in %s on line %d
 bool(false)
 
-Warning: link(): %s in %s on line %d
+Warning: link(): No such file or directory in %s on line %d
 bool(false)
 
-Warning: link(): %s in %s on line %d
+Warning: link(): No such file or directory in %s on line %d
 bool(false)
 
-Warning: link(): %s in %s on line %d
+Warning: link(): No such file or directory in %s on line %d
 bool(false)
 
-Warning: link(): %s in %s on line %d
+Warning: link(): No such file or directory in %s on line %d
 bool(false)
 
-Warning: link(): %s in %s on line %d
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
 bool(false)
 
 *** Testing is_link() for error conditions ***
@@ -104,4 +109,6 @@ bool(false)
 bool(false)
 bool(false)
 bool(false)
+bool(false)
 Done
+
index 907595033000cc137b8815662caaeba15eb7e16e..a3dd7e9d6256a478f198f338be496fa509a66bd8 100644 (file)
@@ -3,7 +3,7 @@ Test tempnam() function: usage variations - creating files
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
-  die("skip Run only on Windows");
+  die("skip Only valid for Windows");
 ?>
 --FILE--
 <?php
@@ -13,7 +13,8 @@ if(substr(PHP_OS, 0, 3) != "WIN")
 
 /* Creating number of unique files by passing a file name as prefix */
 
-$file_path = dirname(__FILE__);
+$file_path = dirname(__FILE__)."/tempnamVar1";
+mkdir($file_path);
 
 echo "*** Testing tempnam() in creation of unique files ***\n";
 for($i=1; $i<=10; $i++) {
@@ -31,6 +32,19 @@ for($i=1; $i<=10; $i++) {
     echo "\n";
     clearstatcache();
 
+    echo "File created in => ";
+    $file_dir = dirname($files[$i]);    
+        
+    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {    
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }
+    clearstatcache();
   }
   else {
     print("- File is not created -");
@@ -39,39 +53,51 @@ for($i=1; $i<=10; $i++) {
 for($i=1; $i<=10; $i++) {
   unlink($files[$i]);
 }
+rmdir($file_path);
+
 
 echo "*** Done ***\n";
 ?>
 --EXPECTF--
 *** Testing tempnam() in creation of unique files ***
 -- Iteration 1 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 2 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 3 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 4 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 5 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 6 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 7 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 8 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 9 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 10 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => directory specified
 *** Done ***
index c94a65ba21719f5d463d8b861f3766c56f52f68a..0745f5397c9db8b2c89cd31099ac2e36af63e100 100644 (file)
@@ -13,7 +13,8 @@ if(substr(PHP_OS, 0, 3) == "WIN")
 
 /* Creating number of unique files by passing a file name as prefix */
 
-$file_path = dirname(__FILE__);
+$file_path = dirname(__FILE__)."/tempnamVar1";
+mkdir($file_path);
 
 echo "*** Testing tempnam() in creation of unique files ***\n";
 for($i=1; $i<=10; $i++) {
@@ -34,6 +35,19 @@ for($i=1; $i<=10; $i++) {
     echo "File inode is => ";
     print_r( fileinode($files[$i]) ); //checking inodes
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($files[$i]);    
+        
+    if ($file_dir == sys_get_temp_dir()) {
+       echo "temp dir\n";
+    }
+    else if ($file_dir == $file_path) {
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }
     clearstatcache();
   }
   else {
@@ -44,48 +58,59 @@ for($i=1; $i<=10; $i++) {
   unlink($files[$i]);
 }
 
+rmdir($file_path);
 echo "*** Done ***\n";
 ?>
 --EXPECTF--
 *** Testing tempnam() in creation of unique files ***
 -- Iteration 1 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 2 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 3 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 4 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 5 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 6 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 7 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 8 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 9 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 -- Iteration 10 --
-File name is => %s
+File name is => %s%etempnam_variation1.tmp%s
 File permissions are => 100600
 File inode is => %d
+File created in => directory specified
 *** Done ***
index a9fe4fd2d6c80ba3260930c27b63aeb70b2ee4b2..4224966daf99433bca491036dd3c05afb344cd6d 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
-Test tempnam() function: usage variations - relative paths
+Test tempnam() function: usage variations - various absolute and relative paths
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
-  die("skip Run only on Windows");
+  die("skip Only valid for Windows");
 ?>
 --FILE--
 <?php
@@ -13,7 +13,7 @@ if(substr(PHP_OS, 0, 3) != "WIN")
 
 /* Creating unique files in various dirs by passing relative paths to $dir arg */
 
-echo "*** Testing tempnam() with relative paths ***\n";
+echo "*** Testing tempnam() with absolute and relative paths ***\n";
 $dir_name = dirname(__FILE__)."/tempnam_variation2";
 mkdir($dir_name);
 $dir_path = $dir_name."/tempnam_variation2_sub";
@@ -23,14 +23,24 @@ $old_dir_path = getcwd();
 chdir(dirname(__FILE__));
 
 $dir_paths = array(
+  // absolute paths
   "$dir_path",
   "$dir_path/",
   "$dir_path/..",
   "$dir_path//../",
   "$dir_path/../.././tempnam_variation2",
   "$dir_path/..///tempnam_variation2_sub//..//../tempnam_variation2",
+  "$dir_path/BADDIR",
+  
+  
+  // relative paths
   ".",
-  "./tempnam_variation2/../tempnam_variation2/tempnam_variation2_sub"
+  "tempname_variation2",
+  "tempname_variation2/",
+  "tempnam_variation2/tempnam_variation2_sub",
+  "tempnam_variation2//tempnam_variation2_sub",  
+  "./tempnam_variation2/../tempnam_variation2/tempnam_variation2_sub",
+  "BADDIR",  
 );
 
 for($i = 0; $i<count($dir_paths); $i++) {
@@ -47,10 +57,28 @@ for($i = 0; $i<count($dir_paths); $i++) {
     echo "File permissions are => ";
     printf("%o", fileperms($file_name) );
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+    $dir_req = $dir_paths[$i];
+        
+    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else if (realpath($file_dir) == realpath($dir_req) || realpath($file_dir."\\") == realpath($dir_req)) {    
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }    
+    
+
   }
-  else
+  else {
     echo "-- File is not created --";
-    unlink($file_name);
+  }
+  
+  unlink($file_name);
 }
 
 chdir($old_dir_path);
@@ -60,38 +88,76 @@ rmdir($dir_name);
 echo "\n*** Done ***\n";
 ?>
 --EXPECTF--
-*** Testing tempnam() with relative paths ***
+*** Testing tempnam() with absolute and relative paths ***
 
 -- Iteration 1 --
-File name is => %s
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
 File permissions are => 100666
+File created in => directory specified
 
 -- Iteration 2 --
-File name is => %s
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
 File permissions are => 100666
+File created in => directory specified
 
 -- Iteration 3 --
-File name is => %s
+File name is => %s\tempnam_variation2\t%s
 File permissions are => 100666
+File created in => directory specified
 
 -- Iteration 4 --
-File name is => %s
+File name is => %s\tempnam_variation2\t%s
 File permissions are => 100666
+File created in => directory specified
 
 -- Iteration 5 --
-File name is => %s
+File name is => %s\tempnam_variation2\t%s
 File permissions are => 100666
+File created in => directory specified
 
 -- Iteration 6 --
-File name is => %s
+File name is => %s\tempnam_variation2\t%s
 File permissions are => 100666
+File created in => directory specified
 
 -- Iteration 7 --
-File name is => %s
+File name is => %s\t%s
 File permissions are => 100666
+File created in => temp dir
 
 -- Iteration 8 --
-File name is => %s
+File name is => %s\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 9 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 10 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 11 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 12 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 13 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 14 --
+File name is => %s\t%s
 File permissions are => 100666
+File created in => temp dir
 
-*** Done ***
+*** Done ***
\ No newline at end of file
index 6d85e2562834857dd2788e0bfd3c8d4f35f5e16f..b7e5cdc058b40bdc4eaa10423db3b7e3334ec6cc 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test tempnam() function: usage variations - relative paths
+Test tempnam() function: usage variations - various absolute and relative paths
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) == "WIN")
@@ -13,7 +13,7 @@ if(substr(PHP_OS, 0, 3) == "WIN")
 
 /* Creating unique files in various dirs by passing relative paths to $dir arg */
 
-echo "*** Testing tempnam() with relative paths ***\n";
+echo "*** Testing tempnam() with absolute and relative paths ***\n";
 $dir_name = dirname(__FILE__)."/tempnam_variation2";
 mkdir($dir_name);
 $dir_path = $dir_name."/tempnam_variation2_sub";
@@ -23,14 +23,24 @@ $old_dir_path = getcwd();
 chdir(dirname(__FILE__));
 
 $dir_paths = array(
+  // absolute paths
   "$dir_path",
   "$dir_path/",
   "$dir_path/..",
   "$dir_path//../",
   "$dir_path/../.././tempnam_variation2",
   "$dir_path/..///tempnam_variation2_sub//..//../tempnam_variation2",
+  "$dir_path/BADDIR",
+  
+  
+  // relative paths
   ".",
-  "./tempnam_variation2/../tempnam_variation2/tempnam_variation2_sub"
+  "tempname_variation2",
+  "tempname_variation2/",
+  "tempnam_variation2/tempnam_variation2_sub",
+  "tempnam_variation2//tempnam_variation2_sub",  
+  "./tempnam_variation2/../tempnam_variation2/tempnam_variation2_sub",
+  "BADDIR",  
 );
 
 for($i = 0; $i<count($dir_paths); $i++) {
@@ -47,10 +57,28 @@ for($i = 0; $i<count($dir_paths); $i++) {
     echo "File permissions are => ";
     printf("%o", fileperms($file_name) );
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+    $dir_req = $dir_paths[$i];
+        
+    if (realpath($file_dir) == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else if ($file_dir == realpath($dir_req)) {
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }    
+    
+
   }
-  else
+  else {
     echo "-- File is not created --";
-    unlink($file_name);
+  }
+  
+  unlink($file_name);
 }
 
 chdir($old_dir_path);
@@ -60,38 +88,76 @@ rmdir($dir_name);
 echo "\n*** Done ***\n";
 ?>
 --EXPECTF--
-*** Testing tempnam() with relative paths ***
+*** Testing tempnam() with absolute and relative paths ***
 
 -- Iteration 1 --
-File name is => %s
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => directory specified
 
 -- Iteration 2 --
-File name is => %s
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => directory specified
 
 -- Iteration 3 --
-File name is => %s
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => directory specified
 
 -- Iteration 4 --
-File name is => %s
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => directory specified
 
 -- Iteration 5 --
-File name is => %s
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => directory specified
 
 -- Iteration 6 --
-File name is => %s
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => directory specified
 
 -- Iteration 7 --
-File name is => %s
+File name is => %s/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => temp dir
 
 -- Iteration 8 --
-File name is => %s
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 9 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+-- Iteration 10 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+-- Iteration 11 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 12 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 13 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 14 --
+File name is => %s/tempnam_variation2.tmp%s
 File permissions are => 100600
+File created in => temp dir
 
-*** Done ***
+*** Done ***
\ No newline at end of file
index 4e9eb76b5ce368698258c5308b6cf49c2921efcd..ec7718f970cb94e761847b971980ed95658cd139 100644 (file)
@@ -1,9 +1,9 @@
 --TEST--
-Test tempnam() function: usage variations - invalid/non-existing file
+Test tempnam() function: usage variations - obscure prefixes
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
-  die("skip Run only on Windows");
+  die("skip run only on Windows");
 ?>
 --FILE--
 <?php
@@ -13,10 +13,11 @@ if(substr(PHP_OS, 0, 3) != "WIN")
 
 /* Passing invalid/non-existing args for $prefix */
 
-echo "*** Testing tempnam() with invalid/non-existing file names ***\n";
-$file_path = dirname(__FILE__);
+echo "*** Testing tempnam() with obscure prefixes ***\n";
+$file_path = dirname(__FILE__)."/tempnamVar3";
+mkdir($file_path);
 
-/* An array of names, which will be passed as a file name */ 
+/* An array of prefixes */ 
 $names_arr = array(
   /* Invalid args */ 
   -1,
@@ -25,16 +26,16 @@ $names_arr = array(
   NULL,
   "",
   " ",
-  "/0",
+  "\0",
   array(),
 
-  /* Non-existing dirs */
+  /* prefix with path separator of a non existing directory*/
   "/no/such/file/dir", 
-  "php"
+  "php/php"
 
 );
 
-for( $i=1; $i<count($names_arr); $i++ ) {
+for( $i=0; $i<count($names_arr); $i++ ) {
   echo "-- Iteration $i --\n";
   $file_name = tempnam("$file_path", $names_arr[$i]);
 
@@ -47,46 +48,73 @@ for( $i=1; $i<count($names_arr); $i++ ) {
     echo "File permissions are => ";
     printf("%o", fileperms($file_name) );
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {    
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }         
   }
-  else
+  else {
     echo "-- File is not created --\n";
+  }
 
   unlink($file_name);
 }
 
+rmdir($file_path);
 echo "\n*** Done ***\n";
 ?>
 --EXPECTF--
-*** Testing tempnam() with invalid/non-existing file names ***
+*** Testing tempnam() with obscure prefixes ***
+-- Iteration 0 --
+File name is => %s\%s
+File permissions are => 100666
+File created in => directory specified
 -- Iteration 1 --
-File name is => %s
+File name is => %s\%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 2 --
-File name is => %s
+File name is => %s\%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 3 --
-File name is => %s
+File name is => %s\%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 4 --
-File name is => %s
+File name is => %s\%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 5 --
-File name is => %s
+File name is => %s\%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 6 --
-File name is => %s
+File name is => %s\%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
 -- File is not created --
 
-Warning: unlink(): %s in %s on line %d
+Warning: unlink(): No such file or directory in %s on line %d
 -- Iteration 8 --
-File name is => %s
+File name is => %s\di%s
 File permissions are => 100666
+File created in => directory specified
 -- Iteration 9 --
-File name is => %s
+File name is => %s\ph%s
 File permissions are => 100666
+File created in => directory specified
 
 *** Done ***
+
index cbc8e8523968ef4af46a407fb2d36ca5c0bff921..a0b9511b6364f6965117262eb17f4aebd7ee0c8e 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test tempnam() function: usage variations - invalid/non-existing file
+Test tempnam() function: usage variations - obscure prefixes
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) == "WIN")
@@ -13,10 +13,11 @@ if(substr(PHP_OS, 0, 3) == "WIN")
 
 /* Passing invalid/non-existing args for $prefix */
 
-echo "*** Testing tempnam() with invalid/non-existing file names ***\n";
-$file_path = dirname(__FILE__);
+echo "*** Testing tempnam() with obscure prefixes ***\n";
+$file_path = dirname(__FILE__)."/tempnamVar3";
+mkdir($file_path);
 
-/* An array of names, which will be passed as a file name */ 
+/* An array of prefixes */ 
 $names_arr = array(
   /* Invalid args */ 
   -1,
@@ -25,16 +26,16 @@ $names_arr = array(
   NULL,
   "",
   " ",
-  "/0",
+  "\0",
   array(),
 
-  /* Non-existing dirs */
+  /* prefix with path separator of a non existing directory*/
   "/no/such/file/dir", 
-  "php"
+  "php/php"
 
 );
 
-for( $i=1; $i<count($names_arr); $i++ ) {
+for( $i=0; $i<count($names_arr); $i++ ) {
   echo "-- Iteration $i --\n";
   $file_name = tempnam("$file_path", $names_arr[$i]);
 
@@ -47,46 +48,75 @@ for( $i=1; $i<count($names_arr); $i++ ) {
     echo "File permissions are => ";
     printf("%o", fileperms($file_name) );
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+        
+    if ($file_dir == sys_get_temp_dir()) {
+       echo "temp dir\n";
+    }
+    else if ($file_dir == $file_path) {
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }
+    
   }
-  else
+  else {
     echo "-- File is not created --\n";
+  }
 
   unlink($file_name);
 }
 
+rmdir($file_path);
 echo "\n*** Done ***\n";
 ?>
 --EXPECTF--
-*** Testing tempnam() with invalid/non-existing file names ***
+*** Testing tempnam() with obscure prefixes ***
+-- Iteration 0 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
 -- Iteration 1 --
-File name is => %s
+File name is => %s/%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 2 --
-File name is => %s
+File name is => %s/%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 3 --
-File name is => %s
+File name is => %s/%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 4 --
-File name is => %s
+File name is => %s/%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 5 --
-File name is => %s
+File name is => %s/%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 6 --
-File name is => %s
+File name is => %s/%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
 -- File is not created --
 
-Warning: unlink(): %s in %s on line %d
+Warning: unlink(): No such file or directory in %s on line %d
 -- Iteration 8 --
-File name is => %s
+File name is => %s/dir%s
 File permissions are => 100600
+File created in => directory specified
 -- Iteration 9 --
-File name is => %s
+File name is => %s/php%s
 File permissions are => 100600
+File created in => directory specified
 
 *** Done ***
+
index 491eae7343dff9484cd388c0ba77d74a4ef50479..8fec4019fce33bc28d8e0615f371eca202446b7b 100644 (file)
@@ -20,22 +20,34 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
 echo "*** Testing tempnam() with dir of permissions from 0000 to 0777 ***\n";
 $file_path = dirname(__FILE__);
 $dir_name = $file_path."/tempnam_variation4";
+$prefix = "tempnamVar4.";
+
 mkdir($dir_name);
 
-for($mode = 0000; $mode<=0777; $mode++) {
+for($mode = 0000; $mode <= 0777; $mode++) {
   echo "-- dir perms ";
   printf("%o", $mode);
   echo " --\n";
   chmod($dir_name, $mode);
-  $file_name = tempnam($dir_name, "tempnam_variation4.tmp");
+  $file_name = tempnam($dir_name, $prefix);
 
   if(file_exists($file_name) ) {
-    print($file_name);
-    echo "\n";
+    if (realpath(dirname($file_name)) == realpath(sys_get_temp_dir())) {
+       $msg = " created in temp directory";
+    }
+    else if (dirname($file_name) == $dir_name) {
+       $msg = " created in requested directory";
+    }
+    else {
+       $msg = " created in unexpected directory";
+    }   
+  
+    echo basename($file_name).$msg."\n";
+    unlink($file_name);    
+  }
+  else {
+    print("FAILED: File is not created\n");
   }
-  else
-    print("-- File is not created --");
-  unlink($file_name);
 }
 
 rmdir($dir_name);
@@ -45,1027 +57,1027 @@ echo "*** Done ***\n";
 --EXPECTF--
 *** Testing tempnam() with dir of permissions from 0000 to 0777 ***
 -- dir perms 0 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 1 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 2 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 3 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 4 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 5 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 6 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 7 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 10 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 11 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 12 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 13 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 14 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 15 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 16 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 17 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 20 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 21 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 22 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 23 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 24 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 25 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 26 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 27 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 30 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 31 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 32 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 33 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 34 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 35 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 36 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 37 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 40 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 41 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 42 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 43 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 44 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 45 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 46 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 47 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 50 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 51 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 52 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 53 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 54 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 55 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 56 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 57 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 60 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 61 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 62 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 63 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 64 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 65 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 66 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 67 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 70 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 71 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 72 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 73 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 74 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 75 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 76 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 77 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 100 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 101 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 102 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 103 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 104 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 105 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 106 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 107 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 110 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 111 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 112 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 113 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 114 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 115 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 116 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 117 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 120 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 121 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 122 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 123 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 124 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 125 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 126 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 127 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 130 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 131 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 132 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 133 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 134 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 135 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 136 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 137 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 140 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 141 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 142 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 143 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 144 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 145 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 146 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 147 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 150 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 151 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 152 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 153 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 154 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 155 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 156 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 157 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 160 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 161 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 162 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 163 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 164 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 165 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 166 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 167 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 170 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 171 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 172 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 173 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 174 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 175 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 176 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 177 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 200 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 201 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 202 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 203 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 204 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 205 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 206 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 207 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 210 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 211 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 212 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 213 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 214 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 215 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 216 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 217 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 220 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 221 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 222 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 223 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 224 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 225 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 226 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 227 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 230 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 231 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 232 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 233 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 234 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 235 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 236 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 237 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 240 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 241 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 242 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 243 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 244 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 245 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 246 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 247 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 250 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 251 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 252 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 253 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 254 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 255 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 256 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 257 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 260 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 261 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 262 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 263 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 264 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 265 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 266 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 267 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 270 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 271 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 272 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 273 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 274 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 275 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 276 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 277 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 300 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 301 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 302 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 303 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 304 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 305 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 306 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 307 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 310 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 311 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 312 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 313 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 314 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 315 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 316 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 317 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 320 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 321 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 322 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 323 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 324 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 325 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 326 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 327 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 330 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 331 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 332 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 333 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 334 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 335 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 336 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 337 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 340 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 341 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 342 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 343 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 344 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 345 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 346 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 347 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 350 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 351 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 352 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 353 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 354 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 355 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 356 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 357 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 360 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 361 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 362 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 363 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 364 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 365 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 366 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 367 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 370 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 371 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 372 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 373 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 374 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 375 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 376 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 377 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 400 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 401 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 402 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 403 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 404 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 405 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 406 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 407 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 410 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 411 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 412 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 413 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 414 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 415 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 416 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 417 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 420 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 421 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 422 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 423 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 424 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 425 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 426 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 427 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 430 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 431 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 432 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 433 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 434 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 435 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 436 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 437 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 440 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 441 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 442 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 443 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 444 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 445 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 446 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 447 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 450 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 451 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 452 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 453 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 454 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 455 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 456 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 457 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 460 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 461 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 462 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 463 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 464 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 465 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 466 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 467 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 470 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 471 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 472 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 473 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 474 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 475 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 476 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 477 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 500 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 501 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 502 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 503 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 504 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 505 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 506 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 507 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 510 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 511 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 512 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 513 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 514 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 515 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 516 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 517 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 520 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 521 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 522 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 523 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 524 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 525 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 526 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 527 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 530 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 531 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 532 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 533 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 534 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 535 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 536 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 537 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 540 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 541 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 542 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 543 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 544 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 545 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 546 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 547 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 550 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 551 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 552 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 553 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 554 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 555 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 556 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 557 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 560 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 561 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 562 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 563 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 564 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 565 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 566 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 567 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 570 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 571 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 572 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 573 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 574 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 575 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 576 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 577 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 600 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 601 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 602 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 603 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 604 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 605 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 606 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 607 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 610 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 611 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 612 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 613 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 614 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 615 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 616 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 617 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 620 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 621 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 622 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 623 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 624 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 625 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 626 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 627 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 630 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 631 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 632 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 633 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 634 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 635 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 636 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 637 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 640 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 641 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 642 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 643 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 644 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 645 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 646 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 647 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 650 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 651 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 652 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 653 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 654 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 655 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 656 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 657 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 660 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 661 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 662 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 663 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 664 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 665 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 666 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 667 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 670 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 671 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 672 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 673 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 674 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 675 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 676 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 677 --
-%s
+tempnamVar4.%s created in temp directory
 -- dir perms 700 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 701 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 702 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 703 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 704 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 705 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 706 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 707 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 710 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 711 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 712 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 713 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 714 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 715 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 716 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 717 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 720 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 721 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 722 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 723 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 724 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 725 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 726 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 727 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 730 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 731 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 732 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 733 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 734 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 735 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 736 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 737 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 740 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 741 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 742 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 743 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 744 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 745 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 746 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 747 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 750 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 751 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 752 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 753 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 754 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 755 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 756 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 757 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 760 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 761 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 762 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 763 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 764 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 765 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 766 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 767 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 770 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 771 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 772 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 773 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 774 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 775 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 776 --
-%s
+tempnamVar4.%s created in requested directory
 -- dir perms 777 --
-%s
-*** Done ***
+tempnamVar4.%s created in requested directory
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/tempnam_variation5-win32.phpt b/ext/standard/tests/file/tempnam_variation5-win32.phpt
new file mode 100644 (file)
index 0000000..3e39352
--- /dev/null
@@ -0,0 +1,54 @@
+--TEST--
+Test tempnam() function: usage variations - existing file
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Windows only");
+?>
+--FILE--
+<?php
+/* Prototype:  string tempnam ( string $dir, string $prefix );
+   Description: Create file with unique file name.
+*/
+
+/* Passing an existing file as $prefix for tempnam() fn */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
+$dir_name = $file_path."/tempnam_variation6";
+mkdir($dir_name);
+$h = fopen($dir_name."/tempnam_variation6.tmp", "w");
+
+for($i=1; $i<=3; $i++) {
+  echo "-- Iteration $i --\n";
+  $created_file = tempnam("$dir_name", "tempnam_variation6.tmp");
+  
+  if( file_exists($created_file) ) {
+    echo "File name is => ";
+    print($created_file);
+    echo "\n";
+  }
+  else
+    print("File is not created");
+
+  unlink($created_file);
+}
+fclose($h);
+unlink($dir_name."/tempnam_variation6.tmp");
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Test tempnam() function: by passing an existing filename as prefix ***
+-- Iteration 1 --
+File name is => %stempnam_variation6%et%s
+-- Iteration 2 --
+File name is => %stempnam_variation6%et%s
+-- Iteration 3 --
+File name is => %stempnam_variation6%et%s
+
+*** Done ***
index 2d5f53dcd3344eab1a40cbfffa7227e9db2dd02e..26c3f91f1f9d4c77c81e953b55b8d7fef091ac17 100644 (file)
@@ -1,5 +1,10 @@
 --TEST--
 Test tempnam() function: usage variations - existing file
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Do not run on Windows");
+?>
 --FILE--
 <?php
 /* Prototype:  string tempnam ( string $dir, string $prefix );
@@ -13,7 +18,7 @@ $file_path = dirname(__FILE__);
 echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
 $dir_name = $file_path."/tempnam_variation6";
 mkdir($dir_name);
-fopen($dir_name."/tempnam_variation6.tmp", "w");
+$h = fopen($dir_name."/tempnam_variation6.tmp", "w");
 
 for($i=1; $i<=3; $i++) {
   echo "-- Iteration $i --\n";
@@ -29,6 +34,7 @@ for($i=1; $i<=3; $i++) {
 
   unlink($created_file);
 }
+fclose($h);
 unlink($dir_name."/tempnam_variation6.tmp");
 rmdir($dir_name);
 
@@ -37,10 +43,10 @@ echo "\n*** Done ***\n";
 --EXPECTF--
 *** Test tempnam() function: by passing an existing filename as prefix ***
 -- Iteration 1 --
-File name is => %s
+File name is => %stempnam_variation6%etempnam_variation6.tmp%s
 -- Iteration 2 --
-File name is => %s
+File name is => %stempnam_variation6%etempnam_variation6.tmp%s
 -- Iteration 3 --
-File name is => %s
+File name is => %stempnam_variation6%etempnam_variation6.tmp%s
 
 *** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation6-win32.phpt b/ext/standard/tests/file/tempnam_variation6-win32.phpt
new file mode 100644 (file)
index 0000000..efe7e86
--- /dev/null
@@ -0,0 +1,62 @@
+--TEST--
+Test tempnam() function: usage variations - Using previous unique filename
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Windows Only");
+?> 
+--FILE--
+<?php
+/* Prototype:  string tempnam ( string $dir, string $prefix );
+   Description: Create file with unique file name.
+*/
+
+/* Trying to create unique files by passing previously created unique file name as prefix */
+
+$file_path = dirname(__FILE__);
+
+echo "\n*** Test tempnam(): by passing previously created filenames ***\n";
+$file_name = "tempnam_variation6.tmp";
+for($i=1; $i<=3; $i++) {
+  echo "-- Iteration $i --\n";
+  $file_name = tempnam("$file_path", $file_name);
+
+  if( file_exists($file_name) ) {
+    echo "File name is => ";
+    print($file_name);
+    echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+        
+    if ($file_dir == sys_get_temp_dir()) {
+       echo "temp dir\n";
+    }
+    else if ($file_dir == $file_path) {
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }    
+ }
+
+  unlink($file_name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Test tempnam(): by passing previously created filenames ***
+-- Iteration 1 --
+File name is => %s%et%s
+File created in => directory specified
+-- Iteration 2 --
+File name is => %s%et%s
+File created in => directory specified
+-- Iteration 3 --
+File name is => %s%et%s
+File created in => directory specified
+
+*** Done ***
index 51ecde9a73afa1d5b2ce8a26888727321708f676..5eb6e6fc868a7a2c6fb8cfe6c233c41b1a17552f 100644 (file)
@@ -1,5 +1,10 @@
 --TEST--
-Test tempnam() function: usage variations - Using previous unique filename 
+Test tempnam() function: usage variations - Using previous unique filename
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Do not run on Windows");
+?> 
 --FILE--
 <?php
 /* Prototype:  string tempnam ( string $dir, string $prefix );
@@ -20,7 +25,20 @@ for($i=1; $i<=3; $i++) {
     echo "File name is => ";
     print($file_name);
     echo "\n";
-  }
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+        
+    if ($file_dir == sys_get_temp_dir()) {
+       echo "temp dir\n";
+    }
+    else if ($file_dir == $file_path) {
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }    
+ }
 
   unlink($file_name);
 }
@@ -30,10 +48,13 @@ echo "\n*** Done ***\n";
 --EXPECTF--
 *** Test tempnam(): by passing previously created filenames ***
 -- Iteration 1 --
-File name is => %s
+File name is => %s%etempnam_variation6.tmp%s
+File created in => directory specified
 -- Iteration 2 --
-File name is => %s
+File name is => %s%etempnam_variation6.tmp%s
+File created in => directory specified
 -- Iteration 3 --
-File name is => %s
+File name is => %s%etempnam_variation6.tmp%s
+File created in => directory specified
 
 *** Done ***
index 486240146fac617de5677abf3bfcdc8348e2e7b9..5096934e039cb44df2ebdea46078fa76c9fe5b57 100644 (file)
@@ -3,7 +3,7 @@ Test tempnam() function: usage variations - invalid/non-existing dir
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) != "WIN")
-  die("skip Run only on Windows");
+  die("skip Only run on Windows");
 ?>
 --FILE--
 <?php
@@ -15,8 +15,6 @@ if(substr(PHP_OS, 0, 3) != "WIN")
      hence the unique files will be created in temporary dir */
 
 echo "*** Testing tempnam() with invalid/non-existing directory names ***\n";
-$file_path = dirname(__FILE__);
-
 /* An array of names, which will be passed as a dir name */ 
 $names_arr = array(
   /* Invalid args */ 
@@ -26,7 +24,7 @@ $names_arr = array(
   NULL,
   "",
   " ",
-  "/0",
+  "\0",
   array(),
 
   /* Non-existing dirs */
@@ -35,7 +33,7 @@ $names_arr = array(
 
 );
 
-for( $i=1; $i<count($names_arr); $i++ ) {
+for( $i=0; $i<count($names_arr); $i++ ) {
   echo "-- Iteration $i --\n";
   $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
 
@@ -48,9 +46,19 @@ for( $i=1; $i<count($names_arr); $i++ ) {
     echo "File permissions are => ";
     printf("%o", fileperms($file_name) );
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else {
+       echo "unknown location\n";
+    }                
   }
-  else 
+  else 
     echo "-- File is not created --\n";
+  }
  
   unlink($file_name);
 }
@@ -59,24 +67,34 @@ echo "\n*** Done ***\n";
 ?>
 --EXPECTF--
 *** Testing tempnam() with invalid/non-existing directory names ***
+-- Iteration 0 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
 -- Iteration 1 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 2 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 3 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 4 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 5 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 6 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
@@ -84,10 +102,13 @@ Warning: tempnam() expects parameter 1 to be string, array given in %s on line %
 
 Warning: unlink(): No such file or directory in %s on line %d
 -- Iteration 8 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 -- Iteration 9 --
-File name is => %s
+File name is => %s%et%s
 File permissions are => 100666
+File created in => temp dir
 
 *** Done ***
+
index ebecd1601f9ed4e53de5e26c9dbdd875f60ad560..0e314dabe3c0c613f06b3486df682ebedad78cbb 100644 (file)
@@ -3,7 +3,7 @@ Test tempnam() function: usage variations - invalid/non-existing dir
 --SKIPIF--
 <?php
 if(substr(PHP_OS, 0, 3) == "WIN")
-  die("skip DO not run on Windows");
+  die("skip Do not run on Windows");
 ?>
 --FILE--
 <?php
@@ -15,8 +15,6 @@ if(substr(PHP_OS, 0, 3) == "WIN")
      hence the unique files will be created in temporary dir */
 
 echo "*** Testing tempnam() with invalid/non-existing directory names ***\n";
-$file_path = dirname(__FILE__);
-
 /* An array of names, which will be passed as a dir name */ 
 $names_arr = array(
   /* Invalid args */ 
@@ -26,7 +24,7 @@ $names_arr = array(
   NULL,
   "",
   " ",
-  "/0",
+  "\0",
   array(),
 
   /* Non-existing dirs */
@@ -35,7 +33,7 @@ $names_arr = array(
 
 );
 
-for( $i=1; $i<count($names_arr); $i++ ) {
+for( $i=0; $i<count($names_arr); $i++ ) {
   echo "-- Iteration $i --\n";
   $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
 
@@ -48,9 +46,21 @@ for( $i=1; $i<count($names_arr); $i++ ) {
     echo "File permissions are => ";
     printf("%o", fileperms($file_name) );
     echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+        
+    if (realpath($file_dir) == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else {
+       echo "unknown location\n";
+    }    
+    
   }
-  else 
+  else 
     echo "-- File is not created --\n";
+  }
  
   unlink($file_name);
 }
@@ -59,24 +69,34 @@ echo "\n*** Done ***\n";
 ?>
 --EXPECTF--
 *** Testing tempnam() with invalid/non-existing directory names ***
+-- Iteration 0 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
 -- Iteration 1 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 2 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 3 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 4 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 5 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 6 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
@@ -84,10 +104,13 @@ Warning: tempnam() expects parameter 1 to be string, array given in %s on line %
 
 Warning: unlink(): No such file or directory in %s on line %d
 -- Iteration 8 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 -- Iteration 9 --
-File name is => %s
+File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
+File created in => temp dir
 
 *** Done ***
+
diff --git a/ext/standard/tests/file/tempnam_variation8-win32.phpt b/ext/standard/tests/file/tempnam_variation8-win32.phpt
new file mode 100644 (file)
index 0000000..8df67b6
--- /dev/null
@@ -0,0 +1,147 @@
+--TEST--
+Test tempnam() function: usage variations - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+  die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype:  string tempnam ( string $dir, string $prefix );
+   Description: Create file with unique file name.
+*/
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing tempnam() with absolute and relative paths ***\n";
+$dir_name = dirname(__FILE__)."\\tempnam_variation2";
+mkdir($dir_name);
+$dir_path = $dir_name."/tempnam_variation2_sub";
+mkdir($dir_path);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$dir_paths = array(
+  // absolute paths
+  "$dir_path\\",
+  "$dir_path\\..",
+  "$dir_path\\\\..\\",
+  "$dir_path\\..\\..\\.\\tempnam_variation2",
+  "$dir_path\\..\\\\\\tempnam_variation2_sub\\\\..\\\\..\\tempnam_variation2",
+  "$dir_path\\BADDIR",
+  
+  
+  // relative paths
+  "tempname_variation2\\",
+  "tempnam_variation2\\tempnam_variation2_sub",
+  "tempnam_variation2\\\\tempnam_variation2_sub",  
+  ".\\tempnam_variation2\\..\\tempnam_variation2\\tempnam_variation2_sub",
+  "BADDIR",  
+);
+
+for($i = 0; $i<count($dir_paths); $i++) {
+  $j = $i+1;
+  echo "\n-- Iteration $j --\n";
+  $file_name = tempnam($dir_paths[$i], "tempnam_variation2.tmp");
+  
+  if( file_exists($file_name) ){
+
+    echo "File name is => ";
+    print(realpath($file_name));
+    echo "\n";
+
+    echo "File permissions are => ";
+    printf("%o", fileperms($file_name) );
+    echo "\n";
+    
+    echo "File created in => ";
+    $file_dir = dirname($file_name);
+    $dir_req = $dir_paths[$i];
+        
+    if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+       echo "temp dir\n";
+    }
+    else if (realpath($file_dir) == realpath($dir_req) || realpath($file_dir."\\") == realpath($dir_req)) {    
+       echo "directory specified\n";
+    }
+    else {
+       echo "unknown location\n";
+    }    
+    
+
+  }
+  else {
+    echo "-- File is not created --";
+  }
+  
+  unlink($file_name);
+}
+
+chdir($old_dir_path);
+rmdir($dir_path);
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with absolute and relative paths ***
+
+-- Iteration 1 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 2 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 3 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 4 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 5 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 6 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 7 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 8 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 9 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 10 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 11 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+*** Done ***
index aea68b0d44dd9efcb3685507d0aace379e929e7b..c6c270d065a95d21c3b26bfc7ac30e5b54deb18a 100644 (file)
@@ -1,8 +1,16 @@
 --TEST--
 touch() tests
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. only for Non Windows.');
+}
+?>
 --FILE--
 <?php
 
+// This doesn't work for windows, time, atime usage results in very different
+// output to linux. This could be a php.net bug on windows or a windows querk.
 $filename = dirname(__FILE__)."/touch.dat";
 
 var_dump(touch());
@@ -44,6 +52,7 @@ int(100)
 bool(true)
 int(100)
 
-Warning: touch(): Unable to create file /no/such/file/or/directory because No such file or directory in %s on line %d
+Warning: touch(): Unable to create file /no/such/file/or/directory because %s in %s on line %d
 bool(false)
 Done
+
diff --git a/ext/standard/tests/file/touch_basic-win32.phpt b/ext/standard/tests/file/touch_basic-win32.phpt
new file mode 100644 (file)
index 0000000..3f473fc
--- /dev/null
@@ -0,0 +1,97 @@
+--TEST--
+Test touch() function : basic functionality 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--XFAIL--
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : proto bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing touch() : basic functionality ***\n";
+
+$filename = dirname(__FILE__)."/touch.dat";
+
+echo "\n--- testing touch creates a file ---\n";
+@unlink($filename);
+if (file_exists($filename)) {
+   die("touch_basic failed");
+}
+var_dump( touch($filename) );
+if (file_exists($filename) == false) {
+   die("touch_basic failed");
+}
+
+echo "\n --- testing touch doesn't alter file contents ---\n";
+$testln = "Here is a test line";
+$h = fopen($filename, "wb");
+fwrite($h, $testln);
+fclose($h);
+touch($filename);
+$h = fopen($filename, "rb");
+echo fgets($h);
+fclose($h);
+
+echo "\n\n --- testing touch alters the correct file metadata ---\n";
+$init_meta = stat($filename);
+clearstatcache();
+sleep(1);
+touch($filename);
+$next_meta = stat($filename);
+$type = array("dev", "ino", "mode", "nlink", "uid", "gid",
+              "rdev", "size", "atime", "mtime", "ctime",
+              "blksize", "blocks");
+
+for ($i = 0; $i < count($type); $i++) {
+   if ($init_meta[$i] != $next_meta[$i]) {
+      echo "stat data differs at $type[$i]\n";
+   }
+}
+
+
+// Initialise all required variables
+$time = 10000;
+$atime = 20470;
+
+// Calling touch() with all possible arguments
+echo "\n --- testing touch using all parameters ---\n";
+var_dump( touch($filename, $time, $atime) );
+clearstatcache();
+$init_meta = stat($filename);
+echo "ctime=".$init_meta['ctime']."\n";
+echo "mtime=".$init_meta['mtime']."\n";
+echo "atime=".$init_meta['atime']."\n";
+
+unlink($filename);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing touch() : basic functionality ***
+
+--- testing touch creates a file ---
+bool(true)
+
+ --- testing touch doesn't alter file contents ---
+Here is a test line
+
+ --- testing touch alters the correct file metadata ---
+stat data differs at atime
+stat data differs at mtime
+
+ --- testing touch using all parameters ---
+bool(true)
+ctime=%d
+mtime=10000
+atime=20470
+Done
+
diff --git a/ext/standard/tests/file/touch_basic.phpt b/ext/standard/tests/file/touch_basic.phpt
new file mode 100644 (file)
index 0000000..fb042df
--- /dev/null
@@ -0,0 +1,96 @@
+--TEST--
+Test touch() function : basic functionality 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. only for Non Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : proto bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing touch() : basic functionality ***\n";
+
+$filename = dirname(__FILE__)."/touch.dat";
+
+echo "\n--- testing touch creates a file ---\n";
+@unlink($filename);
+if (file_exists($filename)) {
+   die("touch_basic failed");
+}
+var_dump( touch($filename) );
+if (file_exists($filename) == false) {
+   die("touch_basic failed");
+}
+
+echo "\n --- testing touch doesn't alter file contents ---\n";
+$testln = "Here is a test line";
+$h = fopen($filename, "wb");
+fwrite($h, $testln);
+fclose($h);
+touch($filename);
+$h = fopen($filename, "rb");
+echo fgets($h);
+fclose($h);
+
+echo "\n\n --- testing touch alters the correct file metadata ---\n";
+$init_meta = stat($filename);
+clearstatcache();
+sleep(1);
+touch($filename);
+$next_meta = stat($filename);
+$type = array("dev", "ino", "mode", "nlink", "uid", "gid",
+              "rdev", "size", "atime", "mtime", "ctime",
+              "blksize", "blocks");
+
+for ($i = 0; $i < count($type); $i++) {
+   if ($init_meta[$i] != $next_meta[$i]) {
+      echo "stat data differs at $type[$i]\n";
+   }
+}
+
+
+// Initialise all required variables
+$time = 10000;
+$atime = 20470;
+
+// Calling touch() with all possible arguments
+echo "\n --- testing touch using all parameters ---\n";
+var_dump( touch($filename, $time, $atime) );
+clearstatcache();
+$init_meta = stat($filename);
+echo "ctime=".$init_meta['ctime']."\n";
+echo "mtime=".$init_meta['mtime']."\n";
+echo "atime=".$init_meta['atime']."\n";
+
+unlink($filename);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing touch() : basic functionality ***
+
+--- testing touch creates a file ---
+bool(true)
+
+ --- testing touch doesn't alter file contents ---
+Here is a test line
+
+ --- testing touch alters the correct file metadata ---
+stat data differs at atime
+stat data differs at mtime
+stat data differs at ctime
+
+ --- testing touch using all parameters ---
+bool(true)
+ctime=%d
+mtime=10000
+atime=20470
+Done
diff --git a/ext/standard/tests/file/touch_error.phpt b/ext/standard/tests/file/touch_error.phpt
new file mode 100644 (file)
index 0000000..ec58fee
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+touch() error tests
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+var_dump(touch());
+var_dump(touch(1, 2, 3, 4));
+var_dump(touch("/no/such/file/or/directory"));
+
+?>
+--EXPECTF--    
+Warning: touch() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+Warning: touch(): Unable to create file /no/such/file/or/directory because No such file or directory in %s on line %d
+bool(false)
+
diff --git a/ext/standard/tests/file/touch_variation1.phpt b/ext/standard/tests/file/touch_variation1.phpt
new file mode 100644 (file)
index 0000000..dba41a6
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+touch() with times
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/touch.dat";
+
+
+var_dump(touch($filename, 101));
+var_dump(filemtime($filename));
+var_dump(fileatime($filename));
+
+@unlink($filename);
+
+@unlink($filename);
+var_dump(touch($filename, 100, 102));
+var_dump(filemtime($filename));
+var_dump(fileatime($filename));
+
+@unlink($filename);
+echo "Done\n";
+
+?>
+--EXPECTF--    
+bool(true)
+int(101)
+int(101)
+bool(true)
+int(100)
+int(102)
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/touch_variation2.phpt b/ext/standard/tests/file/touch_variation2.phpt
new file mode 100644 (file)
index 0000000..9ccb90c
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+touch() - ensure touch does not delete existing file.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+
+$filename = dirname(__FILE__)."/touch.dat";
+$fp=fopen($filename,"w");
+fwrite ($fp,"mydata");
+fclose($fp);
+
+var_dump(touch($filename, 101));
+var_dump(file_get_contents($filename));
+
+@unlink($filename);
+echo "Done\n";
+
+?>
+--EXPECT--     
+bool(true)
+string(6) "mydata"
+Done
diff --git a/ext/standard/tests/file/touch_variation3-win32.phpt b/ext/standard/tests/file/touch_variation3-win32.phpt
new file mode 100644 (file)
index 0000000..43556b8
--- /dev/null
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for time
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar2.tmp';
+$atime = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for time
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( touch($filename, $value, $atime) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation3.phpt b/ext/standard/tests/file/touch_variation3.phpt
new file mode 100644 (file)
index 0000000..810cd71
--- /dev/null
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for time
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar2.tmp';
+$atime = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for time
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( touch($filename, $value, $atime) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation4-win32.phpt b/ext/standard/tests/file/touch_variation4-win32.phpt
new file mode 100644 (file)
index 0000000..ee2639a
--- /dev/null
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for atime
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar3.tmp';
+$time = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for atime
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( touch($filename, $time, $value) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation4.phpt b/ext/standard/tests/file/touch_variation4.phpt
new file mode 100644 (file)
index 0000000..b0238b1
--- /dev/null
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for atime
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar3.tmp';
+$time = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // float data
+      'float 10.5' => 10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for atime
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( touch($filename, $time, $value) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation5-win32.phpt b/ext/standard/tests/file/touch_variation5-win32.phpt
new file mode 100644 (file)
index 0000000..6b7bde4
--- /dev/null
@@ -0,0 +1,249 @@
+--TEST--
+Test touch() function : variation: various valid and invalid paths 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+$workDir = "touchVar5.tmp";
+$subDirOrFile = "aSubDirOrFile";
+mkdir($workDir);
+$cwd = getcwd();
+
+$paths = array(
+                        // relative
+             $workDir.'/'.$subDirOrFile,
+             './'.$workDir.'/'.$subDirOrFile,
+             $workDir.'/../'.$workDir.'/'.$subDirOrFile,
+             
+             // relative bad path (note p8 msgs differ)
+             $workDir.'/../BADDIR/'.$subDirOrFile,
+             'BADDIR/'.$subDirOrFile,
+             
+             //absolute
+             $cwd.'/'.$workDir.'/'.$subDirOrFile,
+             $cwd.'/./'.$workDir.'/'.$subDirOrFile,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDirOrFile,
+
+             //absolute bad path (note p8 msgs differ)             
+             $cwd.'/BADDIR/'.$subDirOrFile,
+             
+             //trailing separators
+             $workDir.'/'.$subDirOrFile.'/',
+             $cwd.'/'.$workDir.'/'.$subDirOrFile.'/',
+             
+             // multiple separators
+             $workDir.'//'.$subDirOrFile,
+             $cwd.'//'.$workDir.'//'.$subDirOrFile,
+             
+             );
+             
+echo "*** Testing touch() : variation ***\n";
+
+echo "\n*** testing nonexisting paths ***\n";      
+test_nonexisting($paths);
+
+echo "\n*** testing existing files ***\n";      
+test_existing($paths, false);
+
+echo "\n*** testing existing directories ***\n";      
+test_existing($paths, true);
+
+
+rmdir($workDir);
+
+
+
+function test_nonexisting($paths) {
+       foreach($paths as $path) {
+          echo "--- testing $path ---\n";
+          
+          if (is_dir($path) || is_file($path)) {
+             echo "FAILED: $path - exists\n";
+          }
+          else {
+             $res = touch($path);
+             if ($res === true) {
+                // something was created
+                if (file_exists($path)) {
+                     // something found
+                             if (is_dir($path)) {
+                                echo "FAILED: $path - unexpected directory\n";
+                             }
+                             else {
+                                echo "PASSED: $path - created\n";
+                                unlink($path);
+                             }
+                }
+                else {
+                   // nothing found
+                   echo "FAILED: $path - touch returned true, nothing there\n";
+                }
+             }
+             else {
+                // nothing created
+                if (file_exists($path)) {
+                     //something found
+                     echo "FAILED: $path - touch returned false, something there\n";
+                     if (is_dir($path)) {
+                        rmdir($path);
+                             }
+                             else {
+                                unlink($path);
+                             }
+                }
+             }
+          }
+       }
+}
+
+function test_existing($paths, $are_dirs) {
+       foreach($paths as $path) {
+          if ($are_dirs) {
+             $res = @mkdir($path);
+             if ($res == true) {
+             test_path($path);
+             rmdir($path);
+          }       
+          }
+          else {
+             $h = @fopen($path,"w");
+             if ($h !== false) {
+                fclose($h);
+             test_path($path);
+             unlink($path);
+          }       
+          }
+       }
+}
+          
+       
+function test_path($path) {
+   echo "--- testing $path ---\n";
+   $org_atime = get_atime($path);
+   clearstatcache();
+   $res = touch($path,0,0);
+   $next_atime = get_atime($path);
+   if ($next_atime == $org_atime) {
+      echo "FAILED: $path - access time not changed\n";
+   }
+   else {
+      echo "PASSED: $path - touched\n";
+   }
+}
+
+function get_atime($path) {
+   $temp = stat($path);
+   return $temp['atime'];
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : variation ***
+
+*** testing nonexisting paths ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - created
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/../BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing %s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/aSubDirOrFile - created
+--- testing %s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/./touchVar5.tmp/aSubDirOrFile - created
+--- testing %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing %s/BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file %s/BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/aSubDirOrFile/ because Invalid argument in %s on line %d
+--- testing %s/touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file %s/touchVar5.tmp/aSubDirOrFile/ because Invalid argument in %s on line %d
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - created
+--- testing %s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: %s//touchVar5.tmp//aSubDirOrFile - created
+
+*** testing existing files ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing %s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: %s//touchVar5.tmp//aSubDirOrFile - touched
+
+*** testing existing directories ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp/aSubDirOrFile - access time not changed
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: ./touchVar5.tmp/aSubDirOrFile - access time not changed
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - access time not changed
+--- testing %s/touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s/touchVar5.tmp/aSubDirOrFile - access time not changed
+--- testing %s/./touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s/./touchVar5.tmp/aSubDirOrFile - access time not changed
+--- testing %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - access time not changed
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp/aSubDirOrFile/ - access time not changed
+--- testing %s/touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s/touchVar5.tmp/aSubDirOrFile/ - access time not changed
+--- testing touchVar5.tmp//aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp//aSubDirOrFile - access time not changed
+--- testing %s//touchVar5.tmp//aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s//touchVar5.tmp//aSubDirOrFile - access time not changed
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation5.phpt b/ext/standard/tests/file/touch_variation5.phpt
new file mode 100644 (file)
index 0000000..f0e1f78
--- /dev/null
@@ -0,0 +1,230 @@
+--TEST--
+Test touch() function : variation: various valid and invalid paths 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+$workDir = "touchVar5.tmp";
+$subDirOrFile = "aSubDirOrFile";
+mkdir($workDir);
+$cwd = getcwd();
+
+$paths = array(
+                        // relative
+             $workDir.'/'.$subDirOrFile,
+             './'.$workDir.'/'.$subDirOrFile,
+             $workDir.'/../'.$workDir.'/'.$subDirOrFile,
+             
+             // relative bad path
+             $workDir.'/../BADDIR/'.$subDirOrFile,
+             'BADDIR/'.$subDirOrFile,
+             
+             //absolute
+             $cwd.'/'.$workDir.'/'.$subDirOrFile,
+             $cwd.'/./'.$workDir.'/'.$subDirOrFile,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDirOrFile,
+
+             //absolute bad path             
+             $cwd.'/BADDIR/'.$subDirOrFile,
+             
+             //trailing separators
+             $workDir.'/'.$subDirOrFile.'/',
+             $cwd.'/'.$workDir.'/'.$subDirOrFile.'/',
+             
+             // multiple separators
+             $workDir.'//'.$subDirOrFile,
+             $cwd.'//'.$workDir.'//'.$subDirOrFile,
+             
+             );
+             
+echo "*** Testing touch() : variation ***\n";
+
+echo "\n*** testing nonexisting paths ***\n";      
+test_nonexisting($paths);
+
+echo "\n*** testing existing files ***\n";      
+test_existing($paths, false);
+
+echo "\n*** testing existing directories ***\n";      
+test_existing($paths, true);
+
+
+rmdir($workDir);
+
+
+
+function test_nonexisting($paths) {
+       foreach($paths as $path) {
+          echo "--- testing $path ---\n";
+          
+          if (is_dir($path) || is_file($path)) {
+             echo "FAILED: $path - exists\n";
+          }
+          else {
+             $res = touch($path);
+             if ($res === true) {
+                // something was created
+                if (file_exists($path)) {
+                     // something found
+                             if (is_dir($path)) {
+                                echo "FAILED: $path - unexpected directory\n";
+                             }
+                             else {
+                                echo "PASSED: $path - created\n";
+                                unlink($path);
+                             }
+                }
+                else {
+                   // nothing found
+                   echo "FAILED: $path - touch returned true, nothing there\n";
+                }
+             }
+             else {
+                // nothing created
+                if (file_exists($path)) {
+                     //something found
+                     echo "FAILED: $path - touch returned false, something there\n";
+                     if (is_dir($path)) {
+                        rmdir($path);
+                             }
+                             else {
+                                unlink($path);
+                             }
+                }
+             }
+          }
+       }
+}
+
+function test_existing($paths, $are_dirs) {
+       foreach($paths as $path) {
+          if ($are_dirs) {
+             $res = @mkdir($path);
+             if ($res == true) {
+             test_path($path);
+             rmdir($path);
+          }       
+          }
+          else {
+             $h = @fopen($path,"w");
+             if ($h !== false) {
+                fclose($h);
+             test_path($path);
+             unlink($path);
+          }       
+          }
+       }
+}
+          
+       
+function test_path($path) {
+   echo "--- testing $path ---\n";
+   $org_atime = get_atime($path);
+   clearstatcache();
+   $res = touch($path,0,0);
+   $next_atime = get_atime($path);
+   if ($next_atime == $org_atime) {
+      echo "FAILED: $path - access time not changed\n";
+   }
+   else {
+      echo "PASSED: $path - touched\n";
+   }
+}
+
+function get_atime($path) {
+   $temp = stat($path);
+   return $temp['atime'];
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : variation ***
+
+*** testing nonexisting paths ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - created
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/../BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - created
+--- testing /%s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/./touchVar5.tmp/aSubDirOrFile - created
+--- testing /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing /%s/BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file /%s/BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/aSubDirOrFile/ because Is a directory in %s on line %d
+--- testing /%s/touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file /%s/touchVar5.tmp/aSubDirOrFile/ because Is a directory in %s on line %d
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - created
+--- testing /%s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: /%s//touchVar5.tmp//aSubDirOrFile - created
+
+*** testing existing files ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing /%s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: /%s//touchVar5.tmp//aSubDirOrFile - touched
+
+*** testing existing directories ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+PASSED: touchVar5.tmp/aSubDirOrFile/ - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile/ ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile/ - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing /%s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: /%s//touchVar5.tmp//aSubDirOrFile - touched
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation6-win32.phpt b/ext/standard/tests/file/touch_variation6-win32.phpt
new file mode 100644 (file)
index 0000000..8c87d49
--- /dev/null
@@ -0,0 +1,263 @@
+--TEST--
+Test touch() function : variation: various valid and invalid paths 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file 
+ * Source code: ext/standard/filestat.c
+ * Alias to functions: 
+ */
+
+$workDir = "touchVar5.tmp";
+$subDirOrFile = "aSubDirOrFile";
+mkdir($workDir);
+$cwd = getcwd();
+
+$unixifiedDirOrFile = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDirOrFile, 3);
+
+$paths = array(
+                        // relative
+             $workDir.'\\'.$subDirOrFile,
+             '.\\'.$workDir.'\\'.$subDirOrFile,
+             $workDir.'\\..\\'.$workDir.'\\'.$subDirOrFile,
+             
+             // relative bad path (note p8 msgs differ)
+             $workDir.'\\..\\BADDIR\\'.$subDirOrFile,
+             'BADDIR\\'.$subDirOrFile,
+             
+             //absolute
+             $cwd.'\\'.$workDir.'\\'.$subDirOrFile,
+             $cwd.'\\.\\'.$workDir.'\\'.$subDirOrFile,
+             $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDirOrFile,
+
+             //absolute bad path (note p8 msgs differ)             
+             $cwd.'\\BADDIR\\'.$subDirOrFile,
+             
+             //trailing separators
+             $workDir.'\\'.$subDirOrFile.'\\',
+             $cwd.'\\'.$workDir.'\\'.$subDirOrFile.'\\',
+             
+             // multiple separators
+             $workDir.'\\\\'.$subDirOrFile,
+             $cwd.'\\\\'.$workDir.'\\\\'.$subDirOrFile,
+             
+             // Unixified Dir Or File
+             $unixifiedDirOrFile,                         
+             
+             );
+             
+echo "*** Testing touch() : variation ***\n";
+
+echo "\n*** testing nonexisting paths ***\n";      
+test_nonexisting($paths);
+
+echo "\n*** testing existing files ***\n";      
+test_existing($paths, false);
+
+echo "\n*** testing existing directories ***\n";      
+test_existing($paths, true);
+
+
+rmdir($workDir);
+
+
+
+function test_nonexisting($paths) {
+       foreach($paths as $path) {
+          echo "--- testing $path ---\n";
+          
+          if (is_dir($path) || is_file($path)) {
+             echo "FAILED: $path - exists\n";
+          }
+          else {
+             $res = touch($path);
+             if ($res === true) {
+                // something was created
+                if (file_exists($path)) {
+                     // something found
+                             if (is_dir($path)) {
+                                echo "FAILED: $path - unexpected directory\n";
+                             }
+                             else {
+                                echo "PASSED: $path - created\n";
+                                unlink($path);
+                             }
+                }
+                else {
+                   // nothing found
+                   echo "FAILED: $path - touch returned true, nothing there\n";
+                }
+             }
+             else {
+                // nothing created
+                if (file_exists($path)) {
+                     //something found
+                     echo "FAILED: $path - touch returned false, something there\n";
+                     if (is_dir($path)) {
+                        rmdir($path);
+                             }
+                             else {
+                                unlink($path);
+                             }
+                }
+             }
+          }
+       }
+}
+
+function test_existing($paths, $are_dirs) {
+       foreach($paths as $path) {
+          if ($are_dirs) {
+             $res = @mkdir($path);
+             if ($res == true) {
+             test_path($path);
+             rmdir($path);
+          }       
+          }
+          else {
+             $h = @fopen($path,"w");
+             if ($h !== false) {
+                fclose($h);
+             test_path($path);
+             unlink($path);
+          }       
+          }
+       }
+}
+          
+       
+function test_path($path) {
+   echo "--- testing $path ---\n";
+   $org_atime = get_atime($path);
+   clearstatcache();
+   $res = touch($path,0,0);
+   $next_atime = get_atime($path);
+   if ($next_atime == $org_atime) {
+      echo "FAILED: $path - access time not changed\n";
+   }
+   else {
+      echo "PASSED: $path - touched\n";
+   }
+}
+
+function get_atime($path) {
+   $temp = stat($path);
+   return $temp['atime'];
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : variation ***
+
+*** testing nonexisting paths ***
+--- testing touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\aSubDirOrFile - created
+--- testing .\touchVar5.tmp\aSubDirOrFile ---
+PASSED: .\touchVar5.tmp\aSubDirOrFile - created
+--- testing touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - created
+--- testing touchVar5.tmp\..\BADDIR\aSubDirOrFile ---
+
+Warning: touch(): Unable to create file touchVar5.tmp\..\BADDIR\aSubDirOrFile because %s in %s on line %d
+--- testing BADDIR\aSubDirOrFile ---
+
+Warning: touch(): Unable to create file BADDIR\aSubDirOrFile because %s in %s on line %d
+--- testing %s\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\aSubDirOrFile - created
+--- testing %s\.\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\.\touchVar5.tmp\aSubDirOrFile - created
+--- testing %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - created
+--- testing %s\BADDIR\aSubDirOrFile ---
+
+Warning: touch(): Unable to create file %s\BADDIR\aSubDirOrFile because %s in %s on line %d
+--- testing touchVar5.tmp\aSubDirOrFile\ ---
+
+Warning: touch(): Unable to create file touchVar5.tmp\aSubDirOrFile\ because Invalid argument in %s on line %d
+--- testing %s\touchVar5.tmp\aSubDirOrFile\ ---
+
+Warning: touch(): Unable to create file %s\touchVar5.tmp\aSubDirOrFile\ because Invalid argument in %s on line %d
+--- testing touchVar5.tmp\\aSubDirOrFile ---
+PASSED: touchVar5.tmp\\aSubDirOrFile - created
+--- testing %s\\touchVar5.tmp\\aSubDirOrFile ---
+PASSED: %s\\touchVar5.tmp\\aSubDirOrFile - created
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - created
+
+*** testing existing files ***
+--- testing touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\aSubDirOrFile - touched
+--- testing .\touchVar5.tmp\aSubDirOrFile ---
+PASSED: .\touchVar5.tmp\aSubDirOrFile - touched
+--- testing touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\.\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\.\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - touched
+--- testing touchVar5.tmp\\aSubDirOrFile ---
+PASSED: touchVar5.tmp\\aSubDirOrFile - touched
+--- testing %s\\touchVar5.tmp\\aSubDirOrFile ---
+PASSED: %s\\touchVar5.tmp\\aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+
+*** testing existing directories ***
+--- testing touchVar5.tmp\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp\aSubDirOrFile - access time not changed
+--- testing .\touchVar5.tmp\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: .\touchVar5.tmp\aSubDirOrFile - access time not changed
+--- testing touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - access time not changed
+--- testing %s\touchVar5.tmp\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s\touchVar5.tmp\aSubDirOrFile - access time not changed
+--- testing %s\.\touchVar5.tmp\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s\.\touchVar5.tmp\aSubDirOrFile - access time not changed
+--- testing %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - access time not changed
+--- testing touchVar5.tmp\aSubDirOrFile\ ---
+
+Warning: touch(): Utime failed: No such file or directory in %s on line %d
+FAILED: touchVar5.tmp\aSubDirOrFile\ - access time not changed
+--- testing %s\touchVar5.tmp\aSubDirOrFile\ ---
+
+Warning: touch(): Utime failed: No such file or directory in %s on line %d
+FAILED: %s\touchVar5.tmp\aSubDirOrFile\ - access time not changed
+--- testing touchVar5.tmp\\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: touchVar5.tmp\\aSubDirOrFile - access time not changed
+--- testing %s\\touchVar5.tmp\\aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: %s\\touchVar5.tmp\\aSubDirOrFile - access time not changed
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+
+Warning: touch(): Utime failed: Permission denied in %s on line %d
+FAILED: /%s/touchVar5.tmp/aSubDirOrFile - access time not changed
+===DONE===
+
diff --git a/ext/standard/tests/file/umask_variation3.phpt b/ext/standard/tests/file/umask_variation3.phpt
new file mode 100644 (file)
index 0000000..1483dc4
--- /dev/null
@@ -0,0 +1,237 @@
+--TEST--
+Test umask() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. only for Non Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype  : int umask([int mask])
+ * Description: Return or change the umask 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing umask() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+      //out of boundary integers
+      'int -100' => -100,
+      'int 99999' => 99999,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      //'float -12.3456789000e10' => -12.3456789000e10, different in p8
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for mask
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      umask(0);
+      var_dump(umask($value));
+      var_dump( umask());
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing umask() : usage variation ***
+
+--int -100--
+int(0)
+int(412)
+
+--int 99999--
+int(0)
+int(159)
+
+--float 10.5--
+int(0)
+int(10)
+
+--float -10.5--
+int(0)
+int(502)
+
+--float 12.3456789000e10--
+int(0)
+int(%d)
+
+--float .5--
+int(0)
+int(0)
+
+--empty array--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--int indexed array--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--associative array--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--nested arrays--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--uppercase NULL--
+int(0)
+int(0)
+
+--lowercase null--
+int(0)
+int(0)
+
+--lowercase true--
+int(0)
+int(1)
+
+--lowercase false--
+int(0)
+int(0)
+
+--uppercase TRUE--
+int(0)
+int(1)
+
+--uppercase FALSE--
+int(0)
+int(0)
+
+--empty string DQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--empty string SQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--string DQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--string SQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--mixed case string--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--heredoc--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--instance of classWithToString--
+Error: 2 - umask() expects parameter 1 to be long, object given, %s(%d)
+bool(false)
+int(63)
+
+--instance of classWithoutToString--
+Error: 2 - umask() expects parameter 1 to be long, object given, %s(%d)
+bool(false)
+int(63)
+
+--undefined var--
+int(0)
+int(0)
+
+--unset var--
+int(0)
+int(0)
+===DONE===
+
diff --git a/ext/standard/tests/file/unlink_variation10.phpt b/ext/standard/tests/file/unlink_variation10.phpt
new file mode 100644 (file)
index 0000000..e0c92ca
--- /dev/null
@@ -0,0 +1,106 @@
+--TEST--
+Test unlink() function : variation: unlinking directories
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not for Windows');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : bool unlink(string filename[, context context])
+ * Description: Delete a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar8.tmp";
+$tmpDir = "subDir.tmp";
+$dirToLinkTo = $workDir.'/'."linkme.tmp";
+
+mkdir($workDir);
+$cwd = getcwd();
+mkdir($dirToLinkTo);
+
+$dirs = array(
+             // relative
+             $workDir.'/'.$tmpDir,
+             './'.$workDir.'/'.$tmpDir,
+             $workDir.'/../'.$workDir.'/'.$tmpDir,
+                         
+             //absolute
+             $cwd.'/'.$workDir.'/'.$tmpDir,
+             $cwd.'/./'.$workDir.'/'.$tmpDir,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$tmpDir,
+           
+             // multiple separators
+             $workDir.'//'.$tmpDir,
+             $cwd.'//'.$workDir.'//'.$tmpDir,
+             
+             );
+             
+
+foreach($dirs as $dirToUnlink) {
+   test_link($workDir.'/'.$tmpDir, $dirToLinkTo, $dirToUnlink, true);  //soft link
+   //cannot test hard links unless you are root.
+}
+
+echo "\n--- try to unlink a directory ---\n";
+unlink($dirToLinkTo);
+rmdir($dirToLinkTo);
+rmdir($workDir);
+
+function test_link($linkedDir, $toLinkTo, $tounlink, $softlink) {
+   if ($softlink == true) {
+         symlink($toLinkTo, $linkedDir);
+         $msg = "soft link";
+   }
+   else {
+         link($toLinkTo, $linkedDir);
+         $msg = "hard link";             
+   }   
+   echo "-- unlinking $msg $tounlink --\n";           
+   $res = unlink($tounlink);
+   if ($res === true) {
+      if (is_link($tounlink) === false) {
+       echo "directory unlinked\n";
+      }
+      else {
+        echo "FAILED: directory not unlinked\n";
+      }
+   }
+   else {
+      unlink($linkedDir);
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- unlinking soft link unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link ./unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link unlinkVar8.tmp/../unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s/unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s/./unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s/unlinkVar8.tmp/../unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link unlinkVar8.tmp//subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s//unlinkVar8.tmp//subDir.tmp --
+directory unlinked
+
+--- try to unlink a directory ---
+
+Warning: unlink(unlinkVar8.tmp/linkme.tmp): %s in %s on line %d
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/unlink_variation6.phpt b/ext/standard/tests/file/unlink_variation6.phpt
new file mode 100644 (file)
index 0000000..ede9ada
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Test unlink() function : variation 
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool unlink(string filename[, context context])
+ * Description: Delete a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing unlink() : variation: contexts and relative files ***\n";
+
+// test relative directories and stream contexts.
+$subdir = 'subdir';
+$testfile = $subdir.'/testfile.txt';
+mkdir($subdir);
+touch($testfile);
+f_exists($testfile);
+$context = stream_context_create();
+var_dump(unlink($testfile, $context));
+f_exists($testfile);
+rmdir($subdir);
+
+function f_exists($file) {
+   if (file_exists($file) == true) {
+      echo "$file exists\n";
+   }
+   else {
+      echo "$file doesn't exist\n";
+   }
+} 
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation: contexts and relative files ***
+subdir/testfile.txt exists
+bool(true)
+subdir/testfile.txt doesn't exist
+===DONE===
diff --git a/ext/standard/tests/file/unlink_variation7.phpt b/ext/standard/tests/file/unlink_variation7.phpt
new file mode 100644 (file)
index 0000000..4c63e11
--- /dev/null
@@ -0,0 +1,246 @@
+--TEST--
+Test unlink() function : usage variation different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype  : bool unlink(string filename[, context context])
+ * Description: Delete a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing unlink() : usage variation different types for context ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+       if (error_reporting() != 0) {
+               // report non-silenced errors
+               echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+       }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__.'tmp';
+$fileRes = fopen(__FILE__, 'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+       public function __toString() {
+               return "Class A object";
+       }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+      // int data
+      'int 0' => 0,
+      'int 1' => 1,
+      'int 12345' => 12345,
+      'int -12345' => -2345,
+
+      // float data
+      'float 10.5' => 10.5,
+      'float -10.5' => -10.5,
+      'float 12.3456789000e10' => 12.3456789000e10,
+      'float -12.3456789000e10' => -12.3456789000e10,
+      'float .5' => .5,
+
+      // array data
+      'empty array' => array(),
+      'int indexed array' => $index_array,
+      'associative array' => $assoc_array,
+      'nested arrays' => array('foo', $index_array, $assoc_array),
+
+      // null data
+      'uppercase NULL' => NULL,
+      'lowercase null' => null,
+
+      // boolean data
+      'lowercase true' => true,
+      'lowercase false' =>false,
+      'uppercase TRUE' =>TRUE,
+      'uppercase FALSE' =>FALSE,
+
+      // empty data
+      'empty string DQ' => "",
+      'empty string SQ' => '',
+
+      // string data
+      'string DQ' => "string",
+      'string SQ' => 'string',
+      'mixed case string' => "sTrInG",
+      'heredoc' => $heredoc,
+
+      // object data
+      'instance of classWithToString' => new classWithToString(),
+      'instance of classWithoutToString' => new classWithoutToString(),
+
+      // undefined data
+      'undefined var' => @$undefined_var,
+
+      // unset data
+      'unset var' => @$unset_var,
+      
+      // file resource
+      'file resource' => $fileRes
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      touch($filename);  // create if it doesn't exist
+      var_dump( unlink($filename, $value) );
+};
+
+if (file_exists($filename)) {
+   unlink($filename);
+}
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : usage variation different types for context ***
+
+--int 0--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - unlink() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - unlink() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--file resource--
+Error: 2 - unlink(): supplied resource is not a valid Stream-Context resource, %s(%d)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/unlink_variation8-win32.phpt b/ext/standard/tests/file/unlink_variation8-win32.phpt
new file mode 100644 (file)
index 0000000..5348676
--- /dev/null
@@ -0,0 +1,112 @@
+--TEST--
+Test unlink() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : bool unlink(string filename[, context context])
+ * Description: Delete a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar8.tmp";
+$tmpFile = "file.tmp";
+mkdir($workDir);
+$cwd = getcwd();
+
+$files = array(
+             // relative
+             $workDir.'/'.$tmpFile,
+             './'.$workDir.'/'.$tmpFile,
+             $workDir.'/../'.$workDir.'/'.$tmpFile,
+             
+             // relative bad path
+             $workDir.'/../BADDIR/'.$tmpFile,
+             'BADDIR/'.$tmpFile,
+             
+             //absolute
+             $cwd.'/'.$workDir.'/'.$tmpFile,
+             $cwd.'/./'.$workDir.'/'.$tmpFile,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$tmpFile,
+
+             //absolute bad path             
+             $cwd.'/BADDIR/'.$tmpFile,
+             
+             //trailing separators
+             $workDir.'/'.$tmpFile.'/',
+             $cwd.'/'.$workDir.'/'.$tmpFile.'/',
+             
+             // multiple separators
+             $workDir.'//'.$tmpFile,
+             $cwd.'//'.$workDir.'//'.$tmpFile,
+             
+             );
+             
+
+foreach($files as $fileToUnlink) {
+   test_realfile($workDir.'/'.$tmpFile, $fileToUnlink);
+}
+
+rmdir($workDir);
+
+function test_realfile($file, $tounlink) {
+   touch($file);
+   echo "-- removing $tounlink --\n";           
+   $res = unlink($tounlink);
+   if ($res === true) {
+      if (file_exists($tounlink) === false) {
+       echo "file removed\n";
+      }
+      else {
+        echo "FAILED: file not removed\n";
+      }
+   }
+   else {
+      unlink($file);
+   }
+}
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- removing unlinkVar8.tmp/file.tmp --
+file removed
+-- removing ./unlinkVar8.tmp/file.tmp --
+file removed
+-- removing unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- removing unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing %s/unlinkVar8.tmp/file.tmp --
+file removed
+-- removing %s/./unlinkVar8.tmp/file.tmp --
+file removed
+-- removing %s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- removing %s/BADDIR/file.tmp --
+
+Warning: unlink(%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Invalid argument in %s on line %d
+-- removing %s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(%s/unlinkVar8.tmp/file.tmp/): Invalid argument in %s on line %d
+-- removing unlinkVar8.tmp//file.tmp --
+file removed
+-- removing %s//unlinkVar8.tmp//file.tmp --
+file removed
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/unlink_variation8.phpt b/ext/standard/tests/file/unlink_variation8.phpt
new file mode 100644 (file)
index 0000000..e87a584
--- /dev/null
@@ -0,0 +1,206 @@
+--TEST--
+Test unlink() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not for Windows');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : bool unlink(string filename[, context context])
+ * Description: Delete a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar8.tmp";
+$tmpFile = "file.tmp";
+$fileToLinkTo = $workDir.'/'."linkme.tmp";
+
+mkdir($workDir);
+$cwd = getcwd();
+touch($fileToLinkTo);
+
+$files = array(
+             // relative
+             $workDir.'/'.$tmpFile,
+             './'.$workDir.'/'.$tmpFile,
+             $workDir.'/../'.$workDir.'/'.$tmpFile,
+             
+             // relative bad path
+             $workDir.'/../BADDIR/'.$tmpFile,
+             'BADDIR/'.$tmpFile,
+             
+             //absolute
+             $cwd.'/'.$workDir.'/'.$tmpFile,
+             $cwd.'/./'.$workDir.'/'.$tmpFile,
+             $cwd.'/'.$workDir.'/../'.$workDir.'/'.$tmpFile,
+
+             //absolute bad path             
+             $cwd.'/BADDIR/'.$tmpFile,
+             
+             //trailing separators
+             $workDir.'/'.$tmpFile.'/',
+             $cwd.'/'.$workDir.'/'.$tmpFile.'/',
+             
+             // multiple separators
+             $workDir.'//'.$tmpFile,
+             $cwd.'//'.$workDir.'//'.$tmpFile,
+             
+             );
+             
+
+foreach($files as $fileToUnlink) {
+   test_realfile($workDir.'/'.$tmpFile, $fileToUnlink);
+   test_link($workDir.'/'.$tmpFile, $fileToLinkTo, $fileToUnlink, true);  //soft link
+   test_link($workDir.'/'.$tmpFile, $fileToLinkTo, $fileToUnlink, false); //hard link   
+}
+
+unlink($fileToLinkTo);
+rmdir($workDir);
+
+function test_realfile($file, $tounlink) {
+   touch($file);
+   echo "-- removing $tounlink --\n";           
+   $res = unlink($tounlink);
+   if ($res === true) {
+      if (file_exists($tounlink) === false) {
+       echo "file removed\n";
+      }
+      else {
+        echo "FAILED: file not removed\n";
+      }
+   }
+   else {
+      unlink($file);
+   }
+}
+
+function test_link($linkedfile, $toLinkTo, $tounlink, $softlink) {
+   if ($softlink == true) {
+         symlink($toLinkTo, $linkedfile);
+         $msg = "soft link";
+   }
+   else {
+         link($toLinkTo, $linkedfile);
+         $msg = "hard link";             
+   }   
+   echo "-- unlinking $msg $tounlink --\n";           
+   $res = unlink($tounlink);
+   if ($res === true) {
+      if (file_exists($tounlink) === false) {
+       echo "file unlinked\n";
+      }
+      else {
+        echo "FAILED: file not unlinked\n";
+      }
+   }
+   else {
+      unlink($linkedfile);
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- removing unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing ./unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link ./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link ./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking soft link unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking hard link unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking soft link BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking hard link BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing /%s/unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link /%s/unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link /%s/unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing /%s/./unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link /%s/./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link /%s/./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing /%s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link /%s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link /%s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing /%s/BADDIR/file.tmp --
+
+Warning: unlink(/%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking soft link /%s/BADDIR/file.tmp --
+
+Warning: unlink(/%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking hard link /%s/BADDIR/file.tmp --
+
+Warning: unlink(/%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- unlinking soft link unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- unlinking hard link unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- removing /%s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(/%s/unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- unlinking soft link /%s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(/%s/unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- unlinking hard link /%s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(/%s/unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- removing unlinkVar8.tmp//file.tmp --
+file removed
+-- unlinking soft link unlinkVar8.tmp//file.tmp --
+file unlinked
+-- unlinking hard link unlinkVar8.tmp//file.tmp --
+file unlinked
+-- removing /%s//unlinkVar8.tmp//file.tmp --
+file removed
+-- unlinking soft link /%s//unlinkVar8.tmp//file.tmp --
+file unlinked
+-- unlinking hard link /%s//unlinkVar8.tmp//file.tmp --
+file unlinked
+===DONE===
\ No newline at end of file
diff --git a/ext/standard/tests/file/unlink_variation9-win32.phpt b/ext/standard/tests/file/unlink_variation9-win32.phpt
new file mode 100644 (file)
index 0000000..4f1a8bb
--- /dev/null
@@ -0,0 +1,120 @@
+--TEST--
+Test unlink() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?> 
+--FILE--
+<?php
+/* Prototype  : bool unlink(string filename[, context context])
+ * Description: Delete a file 
+ * Source code: ext/standard/file.c
+ * Alias to functions: 
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar9.tmp";
+$tmpFile = "file.tmp";
+mkdir($workDir);
+$cwd = getcwd();
+$unixifiedFile = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$tmpFile, 3);
+
+$files = array(
+             // relative
+             $workDir.'\\'.$tmpFile,
+             '.\\'.$workDir.'\\'.$tmpFile,
+             $workDir.'\\..\\'.$workDir.'\\'.$tmpFile,
+             
+             // relative bad path
+             $workDir.'\\..\\BADDIR\\'.$tmpFile,
+             'BADDIR\\'.$tmpFile,
+             
+             //absolute
+             $cwd.'\\'.$workDir.'\\'.$tmpFile,
+             $cwd.'\\.\\'.$workDir.'\\'.$tmpFile,
+             $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$tmpFile,
+
+             //absolute bad path             
+             $cwd.'\\BADDIR\\'.$tmpFile,
+             
+             //trailing separators
+             $workDir.'\\'.$tmpFile.'\\',
+             $cwd.'\\'.$workDir.'\\'.$tmpFile.'\\',
+             
+             // multiple separators
+             $workDir.'\\\\'.$tmpFile,
+             $cwd.'\\\\'.$workDir.'\\\\'.$tmpFile,
+             
+             // Unixified File
+             $unixifiedFile,                                      
+             
+             );
+             
+
+foreach($files as $fileToUnlink) {
+   test_realfile($workDir.'/'.$tmpFile, $fileToUnlink);
+}
+
+rmdir($workDir);
+
+function test_realfile($file, $tounlink) {
+   touch($file);
+   echo "-- removing $tounlink --\n";           
+   $res = unlink($tounlink);
+   if ($res === true) {
+      if (file_exists($tounlink) === false) {
+       echo "file removed\n";
+      }
+      else {
+        echo "FAILED: file not removed\n";
+      }
+   }
+   else {
+      unlink($file);
+   }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- removing unlinkVar9.tmp\file.tmp --
+file removed
+-- removing .\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing unlinkVar9.tmp\..\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing unlinkVar9.tmp\..\BADDIR\file.tmp --
+
+Warning: unlink(unlinkVar9.tmp\..\BADDIR\file.tmp): No such file or directory in %s on line %d
+-- removing BADDIR\file.tmp --
+
+Warning: unlink(BADDIR\file.tmp): No such file or directory in %s on line %d
+-- removing %s\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing %s\.\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing %s\unlinkVar9.tmp\..\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing %s\BADDIR\file.tmp --
+
+Warning: unlink(%s\BADDIR\file.tmp): No such file or directory in %s on line %d
+-- removing unlinkVar9.tmp\file.tmp\ --
+
+Warning: unlink(unlinkVar9.tmp\file.tmp\): Invalid argument in %s on line %d
+-- removing %s\unlinkVar9.tmp\file.tmp\ --
+
+Warning: unlink(%s\unlinkVar9.tmp\file.tmp\): Invalid argument in %s on line %d
+-- removing unlinkVar9.tmp\\file.tmp --
+file removed
+-- removing %s\\unlinkVar9.tmp\\file.tmp --
+file removed
+-- removing /%s/unlinkVar9.tmp/file.tmp --
+file removed
+===DONE===
\ No newline at end of file