]> granicus.if.org Git - php/commitdiff
Filesystem tests.
authorSteve Seear <stevseea@php.net>
Wed, 11 Jun 2008 12:38:56 +0000 (12:38 +0000)
committerSteve Seear <stevseea@php.net>
Wed, 11 Jun 2008 12:38:56 +0000 (12:38 +0000)
21 files changed:
ext/standard/tests/file/basename_basic-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_variation1-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_variation2-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/basename_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_basic-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_error.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_variation1.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_variation2-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/chmod_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation2.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation3.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation4.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation5-win32.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation5.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation6.phpt [new file with mode: 0644]
ext/standard/tests/file/file_variation7.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/file/basename_basic-win32.phpt b/ext/standard/tests/file/basename_basic-win32.phpt
new file mode 100644 (file)
index 0000000..f575c5a
--- /dev/null
@@ -0,0 +1,101 @@
+--TEST--
+basename() basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+
+$file_paths = array (
+  /* simple paths (forward slashes) */
+  "bar",
+  "/foo/bar",
+  "foo/bar",
+  "/bar",
+
+  /* simple paths with trailing slashes (forward slashes) */
+  "bar/",
+  "/bar/",
+  "/foo/bar/",
+  "foo/bar/",
+  "/bar/",
+
+  /* simple paths (backslashes) */
+  "bar",
+  "\\foo\\bar",
+  "foo\\bar",
+  "\\bar",
+
+  /* simple paths with trailing slashes (backslashes) */
+  "bar\\",
+  "\\bar\\",
+  "\\foo\\bar\\",
+  "foo\\bar\\",
+  "\\bar\\",
+
+  /* paths with numeric strings */
+  "10.5\\10.5",
+  "10.5/10.5",
+  "10.5",
+  "105",
+  "/10.5",
+  "\\10.5",
+  "10.5/",
+  "10.5\\",
+  "10/10.zip",
+  "0",
+  '0',
+
+  /* path with spaces */
+  " ",
+  ' ',
+  
+  /* empty paths */
+  "",
+  '',
+  NULL,
+);
+
+foreach ($file_paths as $file_path) {
+       var_dump(basename($file_path));
+}
+
+?>
+--EXPECT--
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(3) "105"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(6) "10.zip"
+string(1) "0"
+string(1) "0"
+string(1) " "
+string(1) " "
+string(0) ""
+string(0) ""
+string(0) ""
diff --git a/ext/standard/tests/file/basename_basic.phpt b/ext/standard/tests/file/basename_basic.phpt
new file mode 100644 (file)
index 0000000..68aefb2
--- /dev/null
@@ -0,0 +1,101 @@
+--TEST--
+basename() basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$file_paths = array (
+  /* simple paths (forward slashes) */
+  "bar",
+  "/foo/bar",
+  "foo/bar",
+  "/bar",
+
+  /* simple paths with trailing slashes (forward slashes) */
+  "bar/",
+  "/bar/",
+  "/foo/bar/",
+  "foo/bar/",
+  "/bar/",
+
+  /* simple paths (backslashes) */
+  "bar",
+  "\\foo\\bar",
+  "foo\\bar",
+  "\\bar",
+
+  /* simple paths with trailing slashes (backslashes) */
+  "bar\\",
+  "\\bar\\",
+  "\\foo\\bar\\",
+  "foo\\bar\\",
+  "\\bar\\",
+
+  /* paths with numeric strings */
+  "10.5\\10.5",
+  "10.5/10.5",
+  "10.5",
+  "105",
+  "/10.5",
+  "\\10.5",
+  "10.5/",
+  "10.5\\",
+  "10/10.zip",
+  "0",
+  '0',
+
+  /* path with spaces */
+  " ",
+  ' ',
+  
+  /* empty paths */
+  "",
+  '',
+  NULL,
+);
+
+foreach ($file_paths as $file_path) {
+       var_dump(basename($file_path));
+}
+
+?>
+--EXPECT--
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(8) "\foo\bar"
+string(7) "foo\bar"
+string(4) "\bar"
+string(4) "bar\"
+string(5) "\bar\"
+string(9) "\foo\bar\"
+string(8) "foo\bar\"
+string(5) "\bar\"
+string(9) "10.5\10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(3) "105"
+string(4) "10.5"
+string(5) "\10.5"
+string(4) "10.5"
+string(5) "10.5\"
+string(6) "10.zip"
+string(1) "0"
+string(1) "0"
+string(1) " "
+string(1) " "
+string(0) ""
+string(0) ""
+string(0) ""
diff --git a/ext/standard/tests/file/basename_variation1-win32.phpt b/ext/standard/tests/file/basename_variation1-win32.phpt
new file mode 100644 (file)
index 0000000..0f4293e
--- /dev/null
@@ -0,0 +1,238 @@
+--TEST--
+basename() with various inputs
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+
+$prefixes = array (
+       
+    // drive letters
+       "A:/",
+    "Z:/",
+    "A:\\",
+
+    // other prefixes
+    "http://",
+    "blah://",
+       "blah:\\",
+    "hostname:",
+
+       // home directory ~
+       "~/",
+       "~\\",
+);
+
+$paths = array (
+
+       "foo",
+       "foo/",
+    "foo\\",    
+    "foo.bar",
+    "foo.bar/",
+    "foo.bar\\",
+    "dir/foo.bar",
+    "dir\\foo.bar",
+    "dir with spaces/foo.bar",
+    "dir with spaces\\foo.bar",
+
+);
+
+foreach ($prefixes as $prefix) {
+       foreach ($paths as $path) {
+               $input = $prefix . $path;
+               echo "basename for path $input is:\n";
+               var_dump(basename($input));
+       }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path A:/foo is:
+string(3) "foo"
+basename for path A:/foo/ is:
+string(3) "foo"
+basename for path A:/foo\ is:
+string(3) "foo"
+basename for path A:/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path A:/foo.bar\ is:
+string(7) "foo.bar"
+basename for path A:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir\foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/foo is:
+string(3) "foo"
+basename for path Z:/foo/ is:
+string(3) "foo"
+basename for path Z:/foo\ is:
+string(3) "foo"
+basename for path Z:/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar\ is:
+string(7) "foo.bar"
+basename for path Z:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir\foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path A:\foo is:
+string(3) "foo"
+basename for path A:\foo/ is:
+string(3) "foo"
+basename for path A:\foo\ is:
+string(3) "foo"
+basename for path A:\foo.bar is:
+string(7) "foo.bar"
+basename for path A:\foo.bar/ is:
+string(7) "foo.bar"
+basename for path A:\foo.bar\ is:
+string(7) "foo.bar"
+basename for path A:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir\foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path http://foo is:
+string(3) "foo"
+basename for path http://foo/ is:
+string(3) "foo"
+basename for path http://foo\ is:
+string(3) "foo"
+basename for path http://foo.bar is:
+string(7) "foo.bar"
+basename for path http://foo.bar/ is:
+string(7) "foo.bar"
+basename for path http://foo.bar\ is:
+string(7) "foo.bar"
+basename for path http://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir\foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path blah://foo is:
+string(3) "foo"
+basename for path blah://foo/ is:
+string(3) "foo"
+basename for path blah://foo\ is:
+string(3) "foo"
+basename for path blah://foo.bar is:
+string(7) "foo.bar"
+basename for path blah://foo.bar/ is:
+string(7) "foo.bar"
+basename for path blah://foo.bar\ is:
+string(7) "foo.bar"
+basename for path blah://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir\foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\foo is:
+string(3) "foo"
+basename for path blah:\foo/ is:
+string(3) "foo"
+basename for path blah:\foo\ is:
+string(3) "foo"
+basename for path blah:\foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\foo.bar/ is:
+string(7) "foo.bar"
+basename for path blah:\foo.bar\ is:
+string(7) "foo.bar"
+basename for path blah:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir\foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:foo is:
+string(12) "hostname:foo"
+basename for path hostname:foo/ is:
+string(12) "hostname:foo"
+basename for path hostname:foo\ is:
+string(12) "hostname:foo"
+basename for path hostname:foo.bar is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar/ is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar\ is:
+string(16) "hostname:foo.bar"
+basename for path hostname:dir/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir\foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path ~/foo is:
+string(3) "foo"
+basename for path ~/foo/ is:
+string(3) "foo"
+basename for path ~/foo\ is:
+string(3) "foo"
+basename for path ~/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/foo.bar/ is:
+string(7) "foo.bar"
+basename for path ~/foo.bar\ is:
+string(7) "foo.bar"
+basename for path ~/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir\foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path ~\foo is:
+string(3) "foo"
+basename for path ~\foo/ is:
+string(3) "foo"
+basename for path ~\foo\ is:
+string(3) "foo"
+basename for path ~\foo.bar is:
+string(7) "foo.bar"
+basename for path ~\foo.bar/ is:
+string(7) "foo.bar"
+basename for path ~\foo.bar\ is:
+string(7) "foo.bar"
+basename for path ~\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir\foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir with spaces\foo.bar is:
+string(7) "foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation1.phpt b/ext/standard/tests/file/basename_variation1.phpt
new file mode 100644 (file)
index 0000000..9358238
--- /dev/null
@@ -0,0 +1,238 @@
+--TEST--
+basename() with various inputs
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$prefixes = array (
+       
+    // drive letters
+       "A:/",
+    "Z:/",
+    "A:\\",
+
+    // other prefixes
+    "http://",
+    "blah://",
+       "blah:\\",
+    "hostname:",
+
+       // home directory ~
+       "~/",
+       "~\\",
+);
+
+$paths = array (
+
+       "foo",
+       "foo/",
+    "foo\\",    
+    "foo.bar",
+    "foo.bar/",
+    "foo.bar\\",
+    "dir/foo.bar",
+    "dir\\foo.bar",
+    "dir with spaces/foo.bar",
+    "dir with spaces\\foo.bar",
+
+);
+
+foreach ($prefixes as $prefix) {
+       foreach ($paths as $path) {
+               $input = $prefix . $path;
+               echo "basename for path $input is:\n";
+               var_dump(basename($input));
+       }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path A:/foo is:
+string(3) "foo"
+basename for path A:/foo/ is:
+string(3) "foo"
+basename for path A:/foo\ is:
+string(4) "foo\"
+basename for path A:/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path A:/foo.bar\ is:
+string(8) "foo.bar\"
+basename for path A:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path A:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path Z:/foo is:
+string(3) "foo"
+basename for path Z:/foo/ is:
+string(3) "foo"
+basename for path Z:/foo\ is:
+string(4) "foo\"
+basename for path Z:/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar\ is:
+string(8) "foo.bar\"
+basename for path Z:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path Z:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path A:\foo is:
+string(6) "A:\foo"
+basename for path A:\foo/ is:
+string(6) "A:\foo"
+basename for path A:\foo\ is:
+string(7) "A:\foo\"
+basename for path A:\foo.bar is:
+string(10) "A:\foo.bar"
+basename for path A:\foo.bar/ is:
+string(10) "A:\foo.bar"
+basename for path A:\foo.bar\ is:
+string(11) "A:\foo.bar\"
+basename for path A:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir\foo.bar is:
+string(14) "A:\dir\foo.bar"
+basename for path A:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir with spaces\foo.bar is:
+string(26) "A:\dir with spaces\foo.bar"
+basename for path http://foo is:
+string(3) "foo"
+basename for path http://foo/ is:
+string(3) "foo"
+basename for path http://foo\ is:
+string(4) "foo\"
+basename for path http://foo.bar is:
+string(7) "foo.bar"
+basename for path http://foo.bar/ is:
+string(7) "foo.bar"
+basename for path http://foo.bar\ is:
+string(8) "foo.bar\"
+basename for path http://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path http://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path blah://foo is:
+string(3) "foo"
+basename for path blah://foo/ is:
+string(3) "foo"
+basename for path blah://foo\ is:
+string(4) "foo\"
+basename for path blah://foo.bar is:
+string(7) "foo.bar"
+basename for path blah://foo.bar/ is:
+string(7) "foo.bar"
+basename for path blah://foo.bar\ is:
+string(8) "foo.bar\"
+basename for path blah://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path blah://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path blah:\foo is:
+string(9) "blah:\foo"
+basename for path blah:\foo/ is:
+string(9) "blah:\foo"
+basename for path blah:\foo\ is:
+string(10) "blah:\foo\"
+basename for path blah:\foo.bar is:
+string(13) "blah:\foo.bar"
+basename for path blah:\foo.bar/ is:
+string(13) "blah:\foo.bar"
+basename for path blah:\foo.bar\ is:
+string(14) "blah:\foo.bar\"
+basename for path blah:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir\foo.bar is:
+string(17) "blah:\dir\foo.bar"
+basename for path blah:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir with spaces\foo.bar is:
+string(29) "blah:\dir with spaces\foo.bar"
+basename for path hostname:foo is:
+string(12) "hostname:foo"
+basename for path hostname:foo/ is:
+string(12) "hostname:foo"
+basename for path hostname:foo\ is:
+string(13) "hostname:foo\"
+basename for path hostname:foo.bar is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar/ is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar\ is:
+string(17) "hostname:foo.bar\"
+basename for path hostname:dir/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir\foo.bar is:
+string(20) "hostname:dir\foo.bar"
+basename for path hostname:dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir with spaces\foo.bar is:
+string(32) "hostname:dir with spaces\foo.bar"
+basename for path ~/foo is:
+string(3) "foo"
+basename for path ~/foo/ is:
+string(3) "foo"
+basename for path ~/foo\ is:
+string(4) "foo\"
+basename for path ~/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/foo.bar/ is:
+string(7) "foo.bar"
+basename for path ~/foo.bar\ is:
+string(8) "foo.bar\"
+basename for path ~/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path ~/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path ~\foo is:
+string(5) "~\foo"
+basename for path ~\foo/ is:
+string(5) "~\foo"
+basename for path ~\foo\ is:
+string(6) "~\foo\"
+basename for path ~\foo.bar is:
+string(9) "~\foo.bar"
+basename for path ~\foo.bar/ is:
+string(9) "~\foo.bar"
+basename for path ~\foo.bar\ is:
+string(10) "~\foo.bar\"
+basename for path ~\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir\foo.bar is:
+string(13) "~\dir\foo.bar"
+basename for path ~\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir with spaces\foo.bar is:
+string(25) "~\dir with spaces\foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation2-win32.phpt b/ext/standard/tests/file/basename_variation2-win32.phpt
new file mode 100644 (file)
index 0000000..5e9961b
--- /dev/null
@@ -0,0 +1,253 @@
+--TEST--
+Testing basename() with various values for the suffix parameter
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+
+$paths = array (
+
+       "foo",
+       "foo/",
+    "foo\\",    
+    "foo.bar",
+    "foo.bar/",
+    "foo.bar\\",
+    "dir/foo.bar",
+    "dir\\foo.bar",
+    "dir with spaces/foo.bar",
+    "dir with spaces\\foo.bar",
+
+);
+
+$suffixes = array (
+
+       ".bar",
+       ".b",
+    ".",
+    " ",
+    "foo",
+    "foo.bar",
+    "foo/bar",
+    "foo\\bar",
+    "/",
+    "\\",      
+);
+
+foreach ($paths as $path) {
+       foreach ($suffixes as $suffix) {
+               echo "basename for path $path, supplying suffix $suffix is:\n";
+               var_dump(basename($path, $suffix));             
+       }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path foo, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo, supplying suffix .b is:
+string(3) "foo"
+basename for path foo, supplying suffix . is:
+string(3) "foo"
+basename for path foo, supplying suffix   is:
+string(3) "foo"
+basename for path foo, supplying suffix foo is:
+string(3) "foo"
+basename for path foo, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo, supplying suffix / is:
+string(3) "foo"
+basename for path foo, supplying suffix \ is:
+string(3) "foo"
+basename for path foo/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix .b is:
+string(3) "foo"
+basename for path foo/, supplying suffix . is:
+string(3) "foo"
+basename for path foo/, supplying suffix   is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix / is:
+string(3) "foo"
+basename for path foo/, supplying suffix \ is:
+string(3) "foo"
+basename for path foo\, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix .b is:
+string(3) "foo"
+basename for path foo\, supplying suffix . is:
+string(3) "foo"
+basename for path foo\, supplying suffix   is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix / is:
+string(3) "foo"
+basename for path foo\, supplying suffix \ is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar/, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix   is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar\, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix   is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir\foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir with spaces/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir with spaces\foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation2.phpt b/ext/standard/tests/file/basename_variation2.phpt
new file mode 100644 (file)
index 0000000..96cfd65
--- /dev/null
@@ -0,0 +1,253 @@
+--TEST--
+Testing basename() with various values for the suffix parameter
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$paths = array (
+
+       "foo",
+       "foo/",
+    "foo\\",    
+    "foo.bar",
+    "foo.bar/",
+    "foo.bar\\",
+    "dir/foo.bar",
+    "dir\\foo.bar",
+    "dir with spaces/foo.bar",
+    "dir with spaces\\foo.bar",
+
+);
+
+$suffixes = array (
+
+       ".bar",
+       ".b",
+    ".",
+    " ",
+    "foo",
+    "foo.bar",
+    "foo/bar",
+    "foo\\bar",
+    "/",
+    "\\",      
+);
+
+foreach ($paths as $path) {
+       foreach ($suffixes as $suffix) {
+               echo "basename for path $path, supplying suffix $suffix is:\n";
+               var_dump(basename($path, $suffix));             
+       }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path foo, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo, supplying suffix .b is:
+string(3) "foo"
+basename for path foo, supplying suffix . is:
+string(3) "foo"
+basename for path foo, supplying suffix   is:
+string(3) "foo"
+basename for path foo, supplying suffix foo is:
+string(3) "foo"
+basename for path foo, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo, supplying suffix / is:
+string(3) "foo"
+basename for path foo, supplying suffix \ is:
+string(3) "foo"
+basename for path foo/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix .b is:
+string(3) "foo"
+basename for path foo/, supplying suffix . is:
+string(3) "foo"
+basename for path foo/, supplying suffix   is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix / is:
+string(3) "foo"
+basename for path foo/, supplying suffix \ is:
+string(3) "foo"
+basename for path foo\, supplying suffix .bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix .b is:
+string(4) "foo\"
+basename for path foo\, supplying suffix . is:
+string(4) "foo\"
+basename for path foo\, supplying suffix   is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo.bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo/bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo\bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix / is:
+string(4) "foo\"
+basename for path foo\, supplying suffix \ is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar/, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix   is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix .bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix .b is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix . is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix   is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo.bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo/bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo\bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix / is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix .bar is:
+string(7) "dir\foo"
+basename for path dir\foo.bar, supplying suffix .b is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix . is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix   is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix foo is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix foo.bar is:
+string(4) "dir\"
+basename for path dir\foo.bar, supplying suffix foo/bar is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix foo\bar is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix / is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix \ is:
+string(11) "dir\foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir with spaces/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix   is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix .bar is:
+string(19) "dir with spaces\foo"
+basename for path dir with spaces\foo.bar, supplying suffix .b is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix . is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix   is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo.bar is:
+string(16) "dir with spaces\"
+basename for path dir with spaces\foo.bar, supplying suffix foo/bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo\bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix / is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix \ is:
+string(23) "dir with spaces\foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation3.phpt b/ext/standard/tests/file/basename_variation3.phpt
new file mode 100644 (file)
index 0000000..f01f550
--- /dev/null
@@ -0,0 +1,185 @@
+--TEST--
+Test basename() function : first parameter type variations 
+--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() : 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(
+
+      // 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( basename($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basename() : usage variation ***
+
+--int 0--
+string(1) "0"
+
+--int 1--
+string(1) "1"
+
+--int 12345--
+string(5) "12345"
+
+--int -12345--
+string(5) "-2345"
+
+--float 10.5--
+string(4) "10.5"
+
+--float -10.5--
+string(5) "-10.5"
+
+--float 12.3456789000e10--
+string(12) "123456789000"
+
+--float -12.3456789000e10--
+string(13) "-123456789000"
+
+--float .5--
+string(3) "0.5"
+
+--empty array--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(1) "1"
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(1) "1"
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+string(0) ""
+
+--empty string SQ--
+string(0) ""
+
+--instance of classWithToString--
+string(14) "Class A object"
+
+--instance of classWithoutToString--
+Error: 2 - basename() 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/basename_variation4.phpt b/ext/standard/tests/file/basename_variation4.phpt
new file mode 100644 (file)
index 0000000..88ce61a
--- /dev/null
@@ -0,0 +1,188 @@
+--TEST--
+Test basename() function : second parameter type variation
+--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() : 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
+$path = 'path';
+
+//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 suffix
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( basename($path, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basename() : usage variation ***
+
+--int 0--
+string(4) "path"
+
+--int 1--
+string(4) "path"
+
+--int 12345--
+string(4) "path"
+
+--int -12345--
+string(4) "path"
+
+--float 10.5--
+string(4) "path"
+
+--float -10.5--
+string(4) "path"
+
+--float 12.3456789000e10--
+string(4) "path"
+
+--float -12.3456789000e10--
+string(4) "path"
+
+--float .5--
+string(4) "path"
+
+--empty array--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(4) "path"
+
+--lowercase null--
+string(4) "path"
+
+--lowercase true--
+string(4) "path"
+
+--lowercase false--
+string(4) "path"
+
+--uppercase TRUE--
+string(4) "path"
+
+--uppercase FALSE--
+string(4) "path"
+
+--empty string DQ--
+string(4) "path"
+
+--empty string SQ--
+string(4) "path"
+
+--instance of classWithToString--
+string(4) "path"
+
+--instance of classWithoutToString--
+Error: 2 - basename() expects parameter 2 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(4) "path"
+
+--unset var--
+string(4) "path"
+===DONE===
diff --git a/ext/standard/tests/file/chmod_basic-win32.phpt b/ext/standard/tests/file/chmod_basic-win32.phpt
new file mode 100644 (file)
index 0000000..ca224f7
--- /dev/null
@@ -0,0 +1,545 @@
+--TEST--
+chmod() basic fuctionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip Windows only chmod test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$filename = __FILE__ . ".tmp";
+
+$fd = fopen($filename, "w+");
+fclose($fd);
+
+for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) {
+       chmod($filename, $perms_to_set);
+       $set_perms = (fileperms($filename) & PERMISSIONS_MASK);
+       clearstatcache();
+       printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms);
+}
+var_dump(chmod($filename, 0777));
+
+unlink($filename);
+echo "done";
+
+?>
+--EXPECT--
+Setting mode 777 gives mode 666
+Setting mode 776 gives mode 666
+Setting mode 775 gives mode 666
+Setting mode 774 gives mode 666
+Setting mode 773 gives mode 666
+Setting mode 772 gives mode 666
+Setting mode 771 gives mode 666
+Setting mode 770 gives mode 666
+Setting mode 767 gives mode 666
+Setting mode 766 gives mode 666
+Setting mode 765 gives mode 666
+Setting mode 764 gives mode 666
+Setting mode 763 gives mode 666
+Setting mode 762 gives mode 666
+Setting mode 761 gives mode 666
+Setting mode 760 gives mode 666
+Setting mode 757 gives mode 666
+Setting mode 756 gives mode 666
+Setting mode 755 gives mode 666
+Setting mode 754 gives mode 666
+Setting mode 753 gives mode 666
+Setting mode 752 gives mode 666
+Setting mode 751 gives mode 666
+Setting mode 750 gives mode 666
+Setting mode 747 gives mode 666
+Setting mode 746 gives mode 666
+Setting mode 745 gives mode 666
+Setting mode 744 gives mode 666
+Setting mode 743 gives mode 666
+Setting mode 742 gives mode 666
+Setting mode 741 gives mode 666
+Setting mode 740 gives mode 666
+Setting mode 737 gives mode 666
+Setting mode 736 gives mode 666
+Setting mode 735 gives mode 666
+Setting mode 734 gives mode 666
+Setting mode 733 gives mode 666
+Setting mode 732 gives mode 666
+Setting mode 731 gives mode 666
+Setting mode 730 gives mode 666
+Setting mode 727 gives mode 666
+Setting mode 726 gives mode 666
+Setting mode 725 gives mode 666
+Setting mode 724 gives mode 666
+Setting mode 723 gives mode 666
+Setting mode 722 gives mode 666
+Setting mode 721 gives mode 666
+Setting mode 720 gives mode 666
+Setting mode 717 gives mode 666
+Setting mode 716 gives mode 666
+Setting mode 715 gives mode 666
+Setting mode 714 gives mode 666
+Setting mode 713 gives mode 666
+Setting mode 712 gives mode 666
+Setting mode 711 gives mode 666
+Setting mode 710 gives mode 666
+Setting mode 707 gives mode 666
+Setting mode 706 gives mode 666
+Setting mode 705 gives mode 666
+Setting mode 704 gives mode 666
+Setting mode 703 gives mode 666
+Setting mode 702 gives mode 666
+Setting mode 701 gives mode 666
+Setting mode 700 gives mode 666
+Setting mode 677 gives mode 666
+Setting mode 676 gives mode 666
+Setting mode 675 gives mode 666
+Setting mode 674 gives mode 666
+Setting mode 673 gives mode 666
+Setting mode 672 gives mode 666
+Setting mode 671 gives mode 666
+Setting mode 670 gives mode 666
+Setting mode 667 gives mode 666
+Setting mode 666 gives mode 666
+Setting mode 665 gives mode 666
+Setting mode 664 gives mode 666
+Setting mode 663 gives mode 666
+Setting mode 662 gives mode 666
+Setting mode 661 gives mode 666
+Setting mode 660 gives mode 666
+Setting mode 657 gives mode 666
+Setting mode 656 gives mode 666
+Setting mode 655 gives mode 666
+Setting mode 654 gives mode 666
+Setting mode 653 gives mode 666
+Setting mode 652 gives mode 666
+Setting mode 651 gives mode 666
+Setting mode 650 gives mode 666
+Setting mode 647 gives mode 666
+Setting mode 646 gives mode 666
+Setting mode 645 gives mode 666
+Setting mode 644 gives mode 666
+Setting mode 643 gives mode 666
+Setting mode 642 gives mode 666
+Setting mode 641 gives mode 666
+Setting mode 640 gives mode 666
+Setting mode 637 gives mode 666
+Setting mode 636 gives mode 666
+Setting mode 635 gives mode 666
+Setting mode 634 gives mode 666
+Setting mode 633 gives mode 666
+Setting mode 632 gives mode 666
+Setting mode 631 gives mode 666
+Setting mode 630 gives mode 666
+Setting mode 627 gives mode 666
+Setting mode 626 gives mode 666
+Setting mode 625 gives mode 666
+Setting mode 624 gives mode 666
+Setting mode 623 gives mode 666
+Setting mode 622 gives mode 666
+Setting mode 621 gives mode 666
+Setting mode 620 gives mode 666
+Setting mode 617 gives mode 666
+Setting mode 616 gives mode 666
+Setting mode 615 gives mode 666
+Setting mode 614 gives mode 666
+Setting mode 613 gives mode 666
+Setting mode 612 gives mode 666
+Setting mode 611 gives mode 666
+Setting mode 610 gives mode 666
+Setting mode 607 gives mode 666
+Setting mode 606 gives mode 666
+Setting mode 605 gives mode 666
+Setting mode 604 gives mode 666
+Setting mode 603 gives mode 666
+Setting mode 602 gives mode 666
+Setting mode 601 gives mode 666
+Setting mode 600 gives mode 666
+Setting mode 577 gives mode 444
+Setting mode 576 gives mode 444
+Setting mode 575 gives mode 444
+Setting mode 574 gives mode 444
+Setting mode 573 gives mode 444
+Setting mode 572 gives mode 444
+Setting mode 571 gives mode 444
+Setting mode 570 gives mode 444
+Setting mode 567 gives mode 444
+Setting mode 566 gives mode 444
+Setting mode 565 gives mode 444
+Setting mode 564 gives mode 444
+Setting mode 563 gives mode 444
+Setting mode 562 gives mode 444
+Setting mode 561 gives mode 444
+Setting mode 560 gives mode 444
+Setting mode 557 gives mode 444
+Setting mode 556 gives mode 444
+Setting mode 555 gives mode 444
+Setting mode 554 gives mode 444
+Setting mode 553 gives mode 444
+Setting mode 552 gives mode 444
+Setting mode 551 gives mode 444
+Setting mode 550 gives mode 444
+Setting mode 547 gives mode 444
+Setting mode 546 gives mode 444
+Setting mode 545 gives mode 444
+Setting mode 544 gives mode 444
+Setting mode 543 gives mode 444
+Setting mode 542 gives mode 444
+Setting mode 541 gives mode 444
+Setting mode 540 gives mode 444
+Setting mode 537 gives mode 444
+Setting mode 536 gives mode 444
+Setting mode 535 gives mode 444
+Setting mode 534 gives mode 444
+Setting mode 533 gives mode 444
+Setting mode 532 gives mode 444
+Setting mode 531 gives mode 444
+Setting mode 530 gives mode 444
+Setting mode 527 gives mode 444
+Setting mode 526 gives mode 444
+Setting mode 525 gives mode 444
+Setting mode 524 gives mode 444
+Setting mode 523 gives mode 444
+Setting mode 522 gives mode 444
+Setting mode 521 gives mode 444
+Setting mode 520 gives mode 444
+Setting mode 517 gives mode 444
+Setting mode 516 gives mode 444
+Setting mode 515 gives mode 444
+Setting mode 514 gives mode 444
+Setting mode 513 gives mode 444
+Setting mode 512 gives mode 444
+Setting mode 511 gives mode 444
+Setting mode 510 gives mode 444
+Setting mode 507 gives mode 444
+Setting mode 506 gives mode 444
+Setting mode 505 gives mode 444
+Setting mode 504 gives mode 444
+Setting mode 503 gives mode 444
+Setting mode 502 gives mode 444
+Setting mode 501 gives mode 444
+Setting mode 500 gives mode 444
+Setting mode 477 gives mode 444
+Setting mode 476 gives mode 444
+Setting mode 475 gives mode 444
+Setting mode 474 gives mode 444
+Setting mode 473 gives mode 444
+Setting mode 472 gives mode 444
+Setting mode 471 gives mode 444
+Setting mode 470 gives mode 444
+Setting mode 467 gives mode 444
+Setting mode 466 gives mode 444
+Setting mode 465 gives mode 444
+Setting mode 464 gives mode 444
+Setting mode 463 gives mode 444
+Setting mode 462 gives mode 444
+Setting mode 461 gives mode 444
+Setting mode 460 gives mode 444
+Setting mode 457 gives mode 444
+Setting mode 456 gives mode 444
+Setting mode 455 gives mode 444
+Setting mode 454 gives mode 444
+Setting mode 453 gives mode 444
+Setting mode 452 gives mode 444
+Setting mode 451 gives mode 444
+Setting mode 450 gives mode 444
+Setting mode 447 gives mode 444
+Setting mode 446 gives mode 444
+Setting mode 445 gives mode 444
+Setting mode 444 gives mode 444
+Setting mode 443 gives mode 444
+Setting mode 442 gives mode 444
+Setting mode 441 gives mode 444
+Setting mode 440 gives mode 444
+Setting mode 437 gives mode 444
+Setting mode 436 gives mode 444
+Setting mode 435 gives mode 444
+Setting mode 434 gives mode 444
+Setting mode 433 gives mode 444
+Setting mode 432 gives mode 444
+Setting mode 431 gives mode 444
+Setting mode 430 gives mode 444
+Setting mode 427 gives mode 444
+Setting mode 426 gives mode 444
+Setting mode 425 gives mode 444
+Setting mode 424 gives mode 444
+Setting mode 423 gives mode 444
+Setting mode 422 gives mode 444
+Setting mode 421 gives mode 444
+Setting mode 420 gives mode 444
+Setting mode 417 gives mode 444
+Setting mode 416 gives mode 444
+Setting mode 415 gives mode 444
+Setting mode 414 gives mode 444
+Setting mode 413 gives mode 444
+Setting mode 412 gives mode 444
+Setting mode 411 gives mode 444
+Setting mode 410 gives mode 444
+Setting mode 407 gives mode 444
+Setting mode 406 gives mode 444
+Setting mode 405 gives mode 444
+Setting mode 404 gives mode 444
+Setting mode 403 gives mode 444
+Setting mode 402 gives mode 444
+Setting mode 401 gives mode 444
+Setting mode 400 gives mode 444
+Setting mode 377 gives mode 666
+Setting mode 376 gives mode 666
+Setting mode 375 gives mode 666
+Setting mode 374 gives mode 666
+Setting mode 373 gives mode 666
+Setting mode 372 gives mode 666
+Setting mode 371 gives mode 666
+Setting mode 370 gives mode 666
+Setting mode 367 gives mode 666
+Setting mode 366 gives mode 666
+Setting mode 365 gives mode 666
+Setting mode 364 gives mode 666
+Setting mode 363 gives mode 666
+Setting mode 362 gives mode 666
+Setting mode 361 gives mode 666
+Setting mode 360 gives mode 666
+Setting mode 357 gives mode 666
+Setting mode 356 gives mode 666
+Setting mode 355 gives mode 666
+Setting mode 354 gives mode 666
+Setting mode 353 gives mode 666
+Setting mode 352 gives mode 666
+Setting mode 351 gives mode 666
+Setting mode 350 gives mode 666
+Setting mode 347 gives mode 666
+Setting mode 346 gives mode 666
+Setting mode 345 gives mode 666
+Setting mode 344 gives mode 666
+Setting mode 343 gives mode 666
+Setting mode 342 gives mode 666
+Setting mode 341 gives mode 666
+Setting mode 340 gives mode 666
+Setting mode 337 gives mode 666
+Setting mode 336 gives mode 666
+Setting mode 335 gives mode 666
+Setting mode 334 gives mode 666
+Setting mode 333 gives mode 666
+Setting mode 332 gives mode 666
+Setting mode 331 gives mode 666
+Setting mode 330 gives mode 666
+Setting mode 327 gives mode 666
+Setting mode 326 gives mode 666
+Setting mode 325 gives mode 666
+Setting mode 324 gives mode 666
+Setting mode 323 gives mode 666
+Setting mode 322 gives mode 666
+Setting mode 321 gives mode 666
+Setting mode 320 gives mode 666
+Setting mode 317 gives mode 666
+Setting mode 316 gives mode 666
+Setting mode 315 gives mode 666
+Setting mode 314 gives mode 666
+Setting mode 313 gives mode 666
+Setting mode 312 gives mode 666
+Setting mode 311 gives mode 666
+Setting mode 310 gives mode 666
+Setting mode 307 gives mode 666
+Setting mode 306 gives mode 666
+Setting mode 305 gives mode 666
+Setting mode 304 gives mode 666
+Setting mode 303 gives mode 666
+Setting mode 302 gives mode 666
+Setting mode 301 gives mode 666
+Setting mode 300 gives mode 666
+Setting mode 277 gives mode 666
+Setting mode 276 gives mode 666
+Setting mode 275 gives mode 666
+Setting mode 274 gives mode 666
+Setting mode 273 gives mode 666
+Setting mode 272 gives mode 666
+Setting mode 271 gives mode 666
+Setting mode 270 gives mode 666
+Setting mode 267 gives mode 666
+Setting mode 266 gives mode 666
+Setting mode 265 gives mode 666
+Setting mode 264 gives mode 666
+Setting mode 263 gives mode 666
+Setting mode 262 gives mode 666
+Setting mode 261 gives mode 666
+Setting mode 260 gives mode 666
+Setting mode 257 gives mode 666
+Setting mode 256 gives mode 666
+Setting mode 255 gives mode 666
+Setting mode 254 gives mode 666
+Setting mode 253 gives mode 666
+Setting mode 252 gives mode 666
+Setting mode 251 gives mode 666
+Setting mode 250 gives mode 666
+Setting mode 247 gives mode 666
+Setting mode 246 gives mode 666
+Setting mode 245 gives mode 666
+Setting mode 244 gives mode 666
+Setting mode 243 gives mode 666
+Setting mode 242 gives mode 666
+Setting mode 241 gives mode 666
+Setting mode 240 gives mode 666
+Setting mode 237 gives mode 666
+Setting mode 236 gives mode 666
+Setting mode 235 gives mode 666
+Setting mode 234 gives mode 666
+Setting mode 233 gives mode 666
+Setting mode 232 gives mode 666
+Setting mode 231 gives mode 666
+Setting mode 230 gives mode 666
+Setting mode 227 gives mode 666
+Setting mode 226 gives mode 666
+Setting mode 225 gives mode 666
+Setting mode 224 gives mode 666
+Setting mode 223 gives mode 666
+Setting mode 222 gives mode 666
+Setting mode 221 gives mode 666
+Setting mode 220 gives mode 666
+Setting mode 217 gives mode 666
+Setting mode 216 gives mode 666
+Setting mode 215 gives mode 666
+Setting mode 214 gives mode 666
+Setting mode 213 gives mode 666
+Setting mode 212 gives mode 666
+Setting mode 211 gives mode 666
+Setting mode 210 gives mode 666
+Setting mode 207 gives mode 666
+Setting mode 206 gives mode 666
+Setting mode 205 gives mode 666
+Setting mode 204 gives mode 666
+Setting mode 203 gives mode 666
+Setting mode 202 gives mode 666
+Setting mode 201 gives mode 666
+Setting mode 200 gives mode 666
+Setting mode 177 gives mode 444
+Setting mode 176 gives mode 444
+Setting mode 175 gives mode 444
+Setting mode 174 gives mode 444
+Setting mode 173 gives mode 444
+Setting mode 172 gives mode 444
+Setting mode 171 gives mode 444
+Setting mode 170 gives mode 444
+Setting mode 167 gives mode 444
+Setting mode 166 gives mode 444
+Setting mode 165 gives mode 444
+Setting mode 164 gives mode 444
+Setting mode 163 gives mode 444
+Setting mode 162 gives mode 444
+Setting mode 161 gives mode 444
+Setting mode 160 gives mode 444
+Setting mode 157 gives mode 444
+Setting mode 156 gives mode 444
+Setting mode 155 gives mode 444
+Setting mode 154 gives mode 444
+Setting mode 153 gives mode 444
+Setting mode 152 gives mode 444
+Setting mode 151 gives mode 444
+Setting mode 150 gives mode 444
+Setting mode 147 gives mode 444
+Setting mode 146 gives mode 444
+Setting mode 145 gives mode 444
+Setting mode 144 gives mode 444
+Setting mode 143 gives mode 444
+Setting mode 142 gives mode 444
+Setting mode 141 gives mode 444
+Setting mode 140 gives mode 444
+Setting mode 137 gives mode 444
+Setting mode 136 gives mode 444
+Setting mode 135 gives mode 444
+Setting mode 134 gives mode 444
+Setting mode 133 gives mode 444
+Setting mode 132 gives mode 444
+Setting mode 131 gives mode 444
+Setting mode 130 gives mode 444
+Setting mode 127 gives mode 444
+Setting mode 126 gives mode 444
+Setting mode 125 gives mode 444
+Setting mode 124 gives mode 444
+Setting mode 123 gives mode 444
+Setting mode 122 gives mode 444
+Setting mode 121 gives mode 444
+Setting mode 120 gives mode 444
+Setting mode 117 gives mode 444
+Setting mode 116 gives mode 444
+Setting mode 115 gives mode 444
+Setting mode 114 gives mode 444
+Setting mode 113 gives mode 444
+Setting mode 112 gives mode 444
+Setting mode 111 gives mode 444
+Setting mode 110 gives mode 444
+Setting mode 107 gives mode 444
+Setting mode 106 gives mode 444
+Setting mode 105 gives mode 444
+Setting mode 104 gives mode 444
+Setting mode 103 gives mode 444
+Setting mode 102 gives mode 444
+Setting mode 101 gives mode 444
+Setting mode 100 gives mode 444
+Setting mode 77 gives mode 444
+Setting mode 76 gives mode 444
+Setting mode 75 gives mode 444
+Setting mode 74 gives mode 444
+Setting mode 73 gives mode 444
+Setting mode 72 gives mode 444
+Setting mode 71 gives mode 444
+Setting mode 70 gives mode 444
+Setting mode 67 gives mode 444
+Setting mode 66 gives mode 444
+Setting mode 65 gives mode 444
+Setting mode 64 gives mode 444
+Setting mode 63 gives mode 444
+Setting mode 62 gives mode 444
+Setting mode 61 gives mode 444
+Setting mode 60 gives mode 444
+Setting mode 57 gives mode 444
+Setting mode 56 gives mode 444
+Setting mode 55 gives mode 444
+Setting mode 54 gives mode 444
+Setting mode 53 gives mode 444
+Setting mode 52 gives mode 444
+Setting mode 51 gives mode 444
+Setting mode 50 gives mode 444
+Setting mode 47 gives mode 444
+Setting mode 46 gives mode 444
+Setting mode 45 gives mode 444
+Setting mode 44 gives mode 444
+Setting mode 43 gives mode 444
+Setting mode 42 gives mode 444
+Setting mode 41 gives mode 444
+Setting mode 40 gives mode 444
+Setting mode 37 gives mode 444
+Setting mode 36 gives mode 444
+Setting mode 35 gives mode 444
+Setting mode 34 gives mode 444
+Setting mode 33 gives mode 444
+Setting mode 32 gives mode 444
+Setting mode 31 gives mode 444
+Setting mode 30 gives mode 444
+Setting mode 27 gives mode 444
+Setting mode 26 gives mode 444
+Setting mode 25 gives mode 444
+Setting mode 24 gives mode 444
+Setting mode 23 gives mode 444
+Setting mode 22 gives mode 444
+Setting mode 21 gives mode 444
+Setting mode 20 gives mode 444
+Setting mode 17 gives mode 444
+Setting mode 16 gives mode 444
+Setting mode 15 gives mode 444
+Setting mode 14 gives mode 444
+Setting mode 13 gives mode 444
+Setting mode 12 gives mode 444
+Setting mode 11 gives mode 444
+Setting mode 10 gives mode 444
+Setting mode 7 gives mode 444
+Setting mode 6 gives mode 444
+Setting mode 5 gives mode 444
+Setting mode 4 gives mode 444
+Setting mode 3 gives mode 444
+Setting mode 2 gives mode 444
+Setting mode 1 gives mode 444
+Setting mode 0 gives mode 444
+bool(true)
+done
diff --git a/ext/standard/tests/file/chmod_basic.phpt b/ext/standard/tests/file/chmod_basic.phpt
new file mode 100644 (file)
index 0000000..582f273
--- /dev/null
@@ -0,0 +1,35 @@
+--TEST--
+chmod() basic fuctionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+define("MODE_MASK", 07777);
+
+$filename = __FILE__ . ".tmp";
+
+$fd = fopen($filename, "w+");
+fclose($fd);
+
+for ($perms_to_set = 07777; $perms_to_set >= 0; $perms_to_set--) {
+       chmod($filename, $perms_to_set);
+       $set_perms = (fileperms($filename) & MODE_MASK);
+       clearstatcache();
+       if ($set_perms != $perms_to_set) {
+               printf("Error: %o does not match %o\n", $set_perms, $perms_to_set);
+       }
+}
+var_dump(chmod($filename, 0777));
+
+unlink($filename);
+echo "done";
+
+?>
+--EXPECT--
+bool(true)
+done
diff --git a/ext/standard/tests/file/chmod_error.phpt b/ext/standard/tests/file/chmod_error.phpt
new file mode 100644 (file)
index 0000000..f4cae3b
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Test chmod() function : error conditions 
+--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() : error conditions ***\n";
+
+
+//Test chmod with one more than the expected number of arguments
+echo "\n-- Testing chmod() function with more than expected no. of arguments --\n";
+$filename = 'string_val';
+$mode = 10;
+$extra_arg = 10;
+var_dump( chmod($filename, $mode, $extra_arg) );
+
+// Testing chmod with one less than the expected number of arguments
+echo "\n-- Testing chmod() function with less than expected no. of arguments --\n";
+$filename = 'string_val';
+var_dump( chmod($filename) );
+
+// testing chmod with a non-existing file
+$filename = "___nonExisitingFile___";
+var_dump(chmod($filename, 0777));
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing chmod() : error conditions ***
+
+-- Testing chmod() function with more than expected no. of arguments --
+
+Warning: chmod() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing chmod() function with less than expected no. of arguments --
+
+Warning: chmod() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: chmod(): No such file or directory in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/chmod_variation1.phpt b/ext/standard/tests/file/chmod_variation1.phpt
new file mode 100644 (file)
index 0000000..f35e54e
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+chmod() on a directory
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$dirname = dirname(__FILE__) . "/" . basename(__FILE__, ".php") . "testdir";
+mkdir($dirname);
+
+for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) {
+       chmod($dirname, $perms_to_set);
+       $set_perms = (fileperms($dirname) & PERMISSIONS_MASK);
+       clearstatcache();
+       if ($set_perms != $perms_to_set) {
+               printf("Error: %o does not match %o\n", $set_perms, $perms_to_set);
+       }
+}
+
+var_dump(chmod($dirname, 0777));
+rmdir($dirname);
+
+echo "done";
+
+?>
+--EXPECT--
+bool(true)
+done
diff --git a/ext/standard/tests/file/chmod_variation2-win32.phpt b/ext/standard/tests/file/chmod_variation2-win32.phpt
new file mode 100644 (file)
index 0000000..bc379ff
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+chmod() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip Windows only chmod test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fclose($fd);
+
+echo "chmod() on a path containing .. and .\n";
+var_dump(chmod("./$test_dirname/../$filename", 0777));
+var_dump(chmod("./$test_dirname/../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+echo "\nchmod() on a path containing .. with invalid directories\n";
+var_dump(chmod($filepath, 0777));
+var_dump(chmod("./$test_dirname/bad_dir/../../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+echo "\nchmod() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(chmod("../$filename", 0777));
+var_dump(chmod("../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+chdir($script_directory);
+
+echo "\nchmod() on a directory with a trailing /\n";
+var_dump(chmod($test_dirname, 0777));
+var_dump(chmod("$test_dirname/", 0775));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECTF--
+chmod() on a path containing .. and .
+bool(true)
+bool(true)
+666
+
+chmod() on a path containing .. with invalid directories
+bool(true)
+bool(true)
+666
+
+chmod() on a relative path from a different working directory
+bool(true)
+bool(true)
+666
+
+chmod() on a directory with a trailing /
+bool(true)
+bool(true)
+666
diff --git a/ext/standard/tests/file/chmod_variation2.phpt b/ext/standard/tests/file/chmod_variation2.phpt
new file mode 100644 (file)
index 0000000..b193acf
--- /dev/null
@@ -0,0 +1,92 @@
+--TEST--
+chmod() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fclose($fd);
+
+echo "chmod() on a path containing .. and .\n";
+var_dump(chmod("./$test_dirname/../$filename", 0777));
+var_dump(chmod("./$test_dirname/../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+echo "\nchmod() on a path containing .. with invalid directories\n";
+var_dump(chmod($filepath, 0777));
+var_dump(chmod("./$test_dirname/bad_dir/../../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+echo "\nchmod() on a linked file\n";
+$linkname = "somelink";
+var_dump(symlink($filepath, $linkname));
+var_dump(chmod($filepath, 0777));
+var_dump(chmod($linkname, 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+var_dump(unlink($linkname));
+
+echo "\nchmod() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(chmod("../$filename", 0777));
+var_dump(chmod("../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+chdir($script_directory);
+
+echo "\nchmod() on a directory with a trailing /\n";
+var_dump(chmod($test_dirname, 0777));
+var_dump(chmod("$test_dirname/", 0775));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECTF--
+chmod() on a path containing .. and .
+bool(true)
+bool(true)
+755
+
+chmod() on a path containing .. with invalid directories
+bool(true)
+
+Warning: chmod(): No such file or directory in %s on line %d
+bool(false)
+777
+
+chmod() on a linked file
+bool(true)
+bool(true)
+bool(true)
+755
+bool(true)
+
+chmod() on a relative path from a different working directory
+bool(true)
+bool(true)
+755
+
+chmod() on a directory with a trailing /
+bool(true)
+bool(true)
+755
diff --git a/ext/standard/tests/file/file_variation2.phpt b/ext/standard/tests/file/file_variation2.phpt
new file mode 100644 (file)
index 0000000..1bb9e9d
--- /dev/null
@@ -0,0 +1,202 @@
+--TEST--
+Test file() function : first parameter variation 
+--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() : 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
+$flags = 0;
+$context = 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' => '',
+
+      // 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( file($value, $flags, $context) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file() : usage variation ***
+
+--int 0--
+Error: 2 - file(0): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - file(12345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - file(-2345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - file(10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - file(-10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - file(123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - file(-123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - file(0.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - file() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(false)
+
+--lowercase null--
+bool(false)
+
+--lowercase true--
+Error: 2 - file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+bool(false)
+
+--empty string DQ--
+bool(false)
+
+--empty string SQ--
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - file(Class A object): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - file() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(false)
+
+--unset var--
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/file_variation3.phpt b/ext/standard/tests/file/file_variation3.phpt
new file mode 100644 (file)
index 0000000..1dd8520
--- /dev/null
@@ -0,0 +1,294 @@
+--TEST--
+Test file() function : second parameter variation 
+--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() : 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+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+$context = 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(
+
+      // 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 flags
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file($filename, $value, $context) );
+};
+
+unlink(__FILE__ . ".tmp");
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file() : usage variation ***
+
+--float 10.5--
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--float -10.5--
+Error: 2 - file(): '-10' flag is not supported, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - file(): '%i' flag is not supported, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - file(): '%i' flag is not supported, %s(%d)
+bool(false)
+
+--float .5--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--empty array--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--lowercase null--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--lowercase true--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--lowercase false--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--uppercase TRUE--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--uppercase FALSE--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--empty string DQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--unset var--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+===DONE===
diff --git a/ext/standard/tests/file/file_variation4.phpt b/ext/standard/tests/file/file_variation4.phpt
new file mode 100644 (file)
index 0000000..5010368
--- /dev/null
@@ -0,0 +1,291 @@
+--TEST--
+Test file() function : third parameter variation 
+--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() : 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+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+$flags = 0;
+
+//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);
+
+// create a file stream resource
+$tmp_filename = __FILE__ . ".tmp2";
+$file_stream_resource = fopen($tmp_filename, "w+");
+
+//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 stream resource
+      'file stream resource' => $file_stream_resource,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+      echo "\n--$key--\n";
+      var_dump( file($filename, $flags, $value) );
+};
+
+fclose($file_stream_resource);
+unlink($tmp_filename);
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file() : usage variation ***
+
+--int 0--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 1--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 12345--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int -12345--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--float 10.5--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -10.5--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float 12.3456789000e10--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -12.3456789000e10--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float .5--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--empty array--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--lowercase null--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--lowercase true--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--lowercase false--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase TRUE--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase FALSE--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--empty string DQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--undefined var--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--unset var--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+--file stream resource--
+Error: 2 - file(): supplied resource is not a valid Stream-Context resource, %s(%d)
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+===DONE===
diff --git a/ext/standard/tests/file/file_variation5-win32.phpt b/ext/standard/tests/file/file_variation5-win32.phpt
new file mode 100644 (file)
index 0000000..d6390db
--- /dev/null
@@ -0,0 +1,74 @@
+--TEST--
+file() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+echo "file() on a path containing .. and .\n";
+var_dump(file("./$test_dirname/../$filename"));
+
+echo "\nfile() on a path containing .. with invalid directories\n";
+var_dump(file("./$test_dirname/bad_dir/../../$filename"));
+
+echo "\nfile() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(file("../$filename"));
+chdir($script_directory);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECT--
+file() on a path containing .. and .
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+file() on a path containing .. with invalid directories
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+file() on a relative path from a different working directory
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
diff --git a/ext/standard/tests/file/file_variation5.phpt b/ext/standard/tests/file/file_variation5.phpt
new file mode 100644 (file)
index 0000000..1f15491
--- /dev/null
@@ -0,0 +1,94 @@
+--TEST--
+file() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+echo "file() on a path containing .. and .\n";
+var_dump(file("./$test_dirname/../$filename"));
+
+echo "\nfile() on a path containing .. with invalid directories\n";
+var_dump(file("./$test_dirname/bad_dir/../../$filename"));
+echo "\nfile() on a linked file\n";
+$linkname = "somelink";
+var_dump(symlink($filepath, $linkname));
+var_dump(file($linkname));
+var_dump(unlink($linkname));
+
+echo "\nfile() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(file("../$filename"));
+chdir($script_directory);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECT--
+file() on a path containing .. and .
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+file() on a path containing .. with invalid directories
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+
+file() on a linked file
+bool(true)
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+bool(true)
+
+file() on a relative path from a different working directory
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
diff --git a/ext/standard/tests/file/file_variation6.phpt b/ext/standard/tests/file/file_variation6.phpt
new file mode 100644 (file)
index 0000000..7e34f28
--- /dev/null
@@ -0,0 +1,261 @@
+--TEST--
+file() with a range of integer flag values
+--FILE--
+<?php
+
+$filepath = __FILE__ . ".tmp";
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+for ($flags = 0; $flags <= 32; $flags++) {
+       var_dump(file($filepath, $flags));
+}
+
+unlink($filepath);
+
+?>
+--EXPECTF--
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(7) "Line 2
+"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+array(3) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(6) "Line 2"
+  [2]=>
+  string(6) "Line 3"
+}
+
+Warning: file(): '24' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '25' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '26' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '27' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '28' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '29' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '30' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '31' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '32' flag is not supported in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/file/file_variation7.phpt b/ext/standard/tests/file/file_variation7.phpt
new file mode 100644 (file)
index 0000000..3cd9d7f
--- /dev/null
@@ -0,0 +1,87 @@
+--TEST--
+file() on a file with blank lines
+--FILE--
+<?php
+
+$filepath = __FILE__ . ".tmp";
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\n\n \n  \n\Line 3");
+fclose($fd);
+
+echo "file():\n";
+var_dump(file($filepath));
+
+echo "\nfile() with FILE_IGNORE_NEW_LINES:\n";
+var_dump(file($filepath, FILE_IGNORE_NEW_LINES));
+
+echo "\nfile() with FILE_SKIP_EMPTY_LINES:\n";
+var_dump(file($filepath, FILE_SKIP_EMPTY_LINES));
+
+echo "\nfile() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:\n";
+var_dump(file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
+
+unlink($filepath);
+
+?>
+--EXPECT--
+file():
+array(5) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(1) "
+"
+  [2]=>
+  string(2) " 
+"
+  [3]=>
+  string(3) "  
+"
+  [4]=>
+  string(7) "\Line 3"
+}
+
+file() with FILE_IGNORE_NEW_LINES:
+array(5) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) " "
+  [3]=>
+  string(2) "  "
+  [4]=>
+  string(7) "\Line 3"
+}
+
+file() with FILE_SKIP_EMPTY_LINES:
+array(5) {
+  [0]=>
+  string(7) "Line 1
+"
+  [1]=>
+  string(1) "
+"
+  [2]=>
+  string(2) " 
+"
+  [3]=>
+  string(3) "  
+"
+  [4]=>
+  string(7) "\Line 3"
+}
+
+file() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:
+array(4) {
+  [0]=>
+  string(6) "Line 1"
+  [1]=>
+  string(1) " "
+  [2]=>
+  string(2) "  "
+  [3]=>
+  string(7) "\Line 3"
+}