--- /dev/null
+--TEST--
+Test is_executable() function: usage variations - diff. path notations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+/* test is_executable() with file having different filepath notation */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_executable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_executable_variation1");
+
+// create a new temporary file
+$fp = fopen("$file_path/is_executable_variation1/bar.tmp", "w");
+fclose($fp);
+
+/* array of files checked to see if they are executable files
+ using is_executable() function */
+$files_arr = array(
+ "$file_path/is_executable_variation1/bar.tmp",
+
+ /* Testing a file with trailing slash */
+ "$file_path/is_executable_variation1/bar.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/is_executable_variation1//bar.tmp",
+ "$file_path/is_executable_variation1/*.tmp",
+ "$file_path/is_executable_variation1/b*.tmp",
+
+ /* Testing Binary safe */
+ "$file_path/is_executable_variation1".chr(0)."bar.temp",
+ "$file_path".chr(0)."is_executable_variation1/bar.temp",
+ "$file_path/is_executable_variation1x000/",
+
+ /* Testing directories */
+ ".", // current directory, exp: bool(true)
+ "$file_path/is_executable_variation1" // temp directory, exp: bool(true)
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is an executable file */
+foreach($files_arr as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_executable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/is_executable_variation1/bar.tmp");
+rmdir(dirname(__FILE__)."/is_executable_variation1/");
+?>
+--EXPECTF--
+*** Testing is_executable(): usage variations ***
+-- Iteration 1 --
+bool(false)
+-- Iteration 2 --
+bool(false)
+-- Iteration 3 --
+bool(false)
+-- Iteration 4 --
+bool(false)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(false)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+Done
+--UEXPECTF--
+*** Testing is_executable(): usage variations ***
+-- Iteration 1 --
+bool(false)
+-- Iteration 2 --
+bool(false)
+-- Iteration 3 --
+bool(false)
+-- Iteration 4 --
+bool(false)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(false)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test is_executable() function: usage variations - file/dir with diff. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+/* test is_executable() with file/dir having different permissions */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_executable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_executable_variation2");
+
+echo "\n*** Testing is_executable() on directory without execute permission ***\n";
+chmod("$file_path/is_executable_variation2", 0444);
+var_dump( is_executable("$file_path/is_executable_variation2") ); // exp: bool(false)
+chmod("$file_path/is_executable_variation2", 0777); // chmod to enable deletion of directory
+
+echo "\n*** Testing miscelleneous input for is_executable() function ***\n";
+$name_prefix = "is_executable_variation2";
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
+create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
+create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 4);
+create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
+create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
+create_files(dirname(__FILE__), 1, "text", 0714, 1, "w", $name_prefix, 7);
+create_files(dirname(__FILE__), 1, "numeric", 0744, 1, "w", $name_prefix, 8);
+create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
+create_files(dirname(__FILE__), 1, "text", 0712, 1, "w", $name_prefix, 10);
+
+$files = array (
+ "$file_path/is_executable_variation21.tmp",
+ "$file_path/is_executable_variation22.tmp",
+ "$file_path/is_executable_variation23.tmp",
+ "$file_path/is_executable_variation24.tmp",
+ "$file_path/is_executable_variation25.tmp",
+ "$file_path/is_executable_variation26.tmp",
+ "$file_path/is_executable_variation27.tmp",
+ "$file_path/is_executable_variation28.tmp",
+ "$file_path/is_executable_variation29.tmp",
+ "$file_path/is_executable_variation210.tmp",
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is an executable file */
+foreach($files as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_executable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+// change all file's permissions to 777 before deleting
+change_file_perms($file_path, 10, 0777, $name_prefix);
+delete_files($file_path, 10, $name_prefix);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_executable_variation2/");
+?>
+--EXPECTF--
+*** Testing is_executable(): usage variations ***
+
+*** Testing is_executable() on directory without execute permission ***
+bool(false)
+
+*** Testing miscelleneous input for is_executable() function ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(true)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(false)
+-- Iteration 10 --
+bool(true)
+Done
+--UEXPECTF--
+*** Testing is_executable(): usage variations ***
+
+*** Testing is_executable() on directory without execute permission ***
+bool(false)
+
+*** Testing miscelleneous input for is_executable() function ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(true)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(false)
+-- Iteration 10 --
+bool(true)
+Done
--- /dev/null
+--TEST--
+Test is_executable() function: usage variations - invalid file names
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+/* test is_executable() with invalid arguments */
+
+echo "*** Testing is_executable(): usage variations ***\n";
+
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle);
+
+echo "\n*** Testing is_executable() on invalid files ***\n";
+$invalid_files = array(
+ 0,
+ 1234,
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ @array(),
+ @$file_handle
+);
+/* loop through to test each element in the above array
+ is an executable file */
+foreach( $invalid_files as $invalid_file ) {
+ var_dump( is_executable($invalid_file) );
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_executable(): usage variations ***
+
+*** Testing is_executable() on invalid files ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_executable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+bool(false)
+Done
+--UEXPECTF--
+*** Testing is_executable(): usage variations ***
+
+*** Testing is_executable() on invalid files ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_executable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test is_readable() function: usage variations - diff. file notations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable.
+*/
+
+/* test is_readable() with file having different filepath notation */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_readable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_readable_variation1");
+
+// create a new temporary file
+$fp = fopen("$file_path/is_readable_variation1/bar.tmp", "w");
+fclose($fp);
+
+/* array of files to be tested if they are readable by using
+ is_readable() function */
+$files_arr = array(
+ "$file_path/is_readable_variation1/bar.tmp",
+
+ /* Testing a file trailing slash */
+ "$file_path/is_readable_variation1/bar.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/is_readable_variation1//bar.tmp",
+ "$file_path//is_readable_variation1//bar.tmp",
+ "$file_path/is_readable_variation1/*.tmp",
+ "$file_path/is_readable_variation1/b*.tmp",
+
+ /* Testing Binary safe */
+ "$file_path/is_readable_variation1".chr(0)."bar.tmp",
+ "$file_path".chr(0)."is_readable_variation1/bar.tmp",
+ "$file_path".chr(0)."is_readable_variation1/bar.tmp",
+
+ /* Testing directories */
+ ".", // current directory, exp: bool(true)
+ "$file_path/is_readable_variation1" // temp directory, exp: bool(true)
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is a writable file */
+foreach($files_arr as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_readable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/is_readable_variation1/bar.tmp");
+rmdir(dirname(__FILE__)."/is_readable_variation1/");
+?>
+--EXPECTF--
+*** Testing is_readable(): usage variations ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(%s)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(false)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+-- Iteration 11 --
+bool(true)
+Done
+--UEXPECTF--
+*** Testing is_readable(): usage variations ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(%s)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(false)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+-- Iteration 11 --
+bool(true)
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test is_readable() function: usage variations - file/dir with diff. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable.
+*/
+
+/* test is_executable() with file/dir having different permissions */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_readable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_readable_variation2");
+
+echo "\n*** Testing is_readable() on directory without read permission ***\n";
+chmod("$file_path/is_readable_variation2", 0001);
+var_dump( is_readable("$file_path/is_readable_variation2") ); // exp: bool(false)
+chmod("$file_path/is_readable_variation2", 0777); // chmod to enable deletion of directory
+
+echo "\n*** Testing miscelleneous input for is_readable() function ***\n";
+$name_prefix = "is_readable_variation2";
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
+create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
+create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
+create_files(dirname(__FILE__), 1, "numeric", 0555, 1, "w", $name_prefix, 4);
+create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
+create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
+create_files(dirname(__FILE__), 1, "text", 0411, 1, "w", $name_prefix, 7);
+create_files(dirname(__FILE__), 1, "numeric", 0444, 1, "w", $name_prefix, 8);
+create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
+create_files(dirname(__FILE__), 1, "text", 0422, 1, "w", $name_prefix, 10);
+
+$files = array (
+ "$file_path/is_readable_variation21.tmp",
+ "$file_path/is_readable_variation22.tmp",
+ "$file_path/is_readable_variation23.tmp",
+ "$file_path/is_readable_variation24.tmp",
+ "$file_path/is_readable_variation25.tmp",
+ "$file_path/is_readable_variation26.tmp",
+ "$file_path/is_readable_variation27.tmp",
+ "$file_path/is_readable_variation28.tmp",
+ "$file_path/is_readable_variation29.tmp",
+ "$file_path/is_readable_variation210.tmp"
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is a readable file */
+foreach($files as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_readable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+// change all file's permissions to 777 before deleting
+change_file_perms($file_path, 10, 0777, $name_prefix);
+delete_files($file_path, 10, $name_prefix);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_readable_variation2/");
+?>
+--EXPECTF--
+*** Testing is_readable(): usage variations ***
+
+*** Testing is_readable() on directory without read permission ***
+bool(false)
+
+*** Testing miscelleneous input for is_readable() function ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(true)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+Done
+--UEXPECTF--
+*** Testing is_readable(): usage variations ***
+
+*** Testing is_readable() on directory without read permission ***
+bool(false)
+
+*** Testing miscelleneous input for is_readable() function ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(true)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+Done
\ No newline at end of file
--- /dev/null
+--TEST--
+Test is_readable() function: usage variations - invalid file names
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable.
+*/
+
+/* test is_executable() with invalid arguments */
+
+echo "*** Testing is_readable(): usage variations ***\n";
+
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle);
+
+echo "\n*** Testing is_readable() on miscelleneous filenames ***\n";
+$misc_files = array(
+ 0,
+ 1234,
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ @array(),
+ @$file_handle
+);
+/* loop through to test each element in the above array
+ is a readable file */
+foreach( $misc_files as $misc_file ) {
+ var_dump( is_readable($misc_file) );
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_readable(): usage variations ***
+
+*** Testing is_readable() on miscelleneous filenames ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_readable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+bool(false)
+Done
+--UEXPECTF--
+*** Testing is_readable(): usage variations ***
+
+*** Testing is_readable() on miscelleneous filenames ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_readable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test is_writable() and its alias is_writeable() function: usage variations - diff. path notations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+/* test is_writable() & is_writeable() with file having different filepath notation */
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_writable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_writable_variation1");
+
+// create a new temporary file
+$fp = fopen("$file_path/is_writable_variation1/bar.tmp", "w");
+fclose($fp);
+
+/* array of files to be tested to check if they are writable
+ using is_writable() function */
+$files_arr = array(
+ "$file_path/is_writable_variation1/bar.tmp",
+
+ /* Testing a file trailing slash */
+ "$file_path/is_writable_variation1/bar.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/is_writable_variation1//bar.tmp",
+ "$file_path//is_writable_variation1//bar.tmp",
+ "$file_path/is_writable_variation1/*.tmp",
+ "$file_path/is_writable_variation1/b*.tmp",
+
+ /* Testing Binary safe */
+ "$file_path/is_writable_variation1".chr(0)."bar.tmp",
+ "$file_path".chr(0)."is_writable_variation1/bar.tmp",
+ "$file_path".chr(0)."is_writable_variation1/bar.tmp",
+
+ /* Testing directories */
+ ".", // current directory, exp: bool(true)
+ "$file_path/is_writable_variation1" // temp directory, exp: bool(true)
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is a writable file */
+foreach($files_arr as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_writable($file) );
+ var_dump( is_writeable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/is_writable_variation1/bar.tmp");
+rmdir(dirname(__FILE__)."/is_writable_variation1/");
+?>
+--EXPECTF--
+*** Testing is_writable(): usage variations ***
+-- Iteration 1 --
+bool(true)
+bool(true)
+-- Iteration 2 --
+bool(%s)
+bool(%s)
+-- Iteration 3 --
+bool(true)
+bool(true)
+-- Iteration 4 --
+bool(true)
+bool(true)
+-- Iteration 5 --
+bool(false)
+bool(false)
+-- Iteration 6 --
+bool(false)
+bool(false)
+-- Iteration 7 --
+bool(true)
+bool(true)
+-- Iteration 8 --
+bool(true)
+bool(true)
+-- Iteration 9 --
+bool(true)
+bool(true)
+-- Iteration 10 --
+bool(true)
+bool(true)
+-- Iteration 11 --
+bool(true)
+bool(true)
+Done
+--UEXPECTF--
+*** Testing is_writable(): usage variations ***
+-- Iteration 1 --
+bool(true)
+bool(true)
+-- Iteration 2 --
+bool(%s)
+bool(%s)
+-- Iteration 3 --
+bool(true)
+bool(true)
+-- Iteration 4 --
+bool(true)
+bool(true)
+-- Iteration 5 --
+bool(false)
+bool(false)
+-- Iteration 6 --
+bool(false)
+bool(false)
+-- Iteration 7 --
+bool(true)
+bool(true)
+-- Iteration 8 --
+bool(true)
+bool(true)
+-- Iteration 9 --
+bool(true)
+bool(true)
+-- Iteration 10 --
+bool(true)
+bool(true)
+-- Iteration 11 --
+bool(true)
+bool(true)
+Done
--- /dev/null
+--TEST--
+Test is_writable() and its alias is_writeable() function: usage variations - file/dir with diff. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+
+/* test is_executable() with file/dir having different permissions */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_writable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_writable_variation2");
+
+echo "\n*** Testing is_writable() on directory without write permission ***\n";
+chmod("$file_path/is_writable_variation2", 0004);
+var_dump( is_writable("$file_path/is_writable_variation2") ); // exp: bool(false)
+var_dump( is_writeable("$file_path/is_writable_variation2") ); // exp: bool(false)
+chmod("$file_path/is_writable_variation2", 0777); // chmod to enable deletion of directory
+
+echo "\n*** Testing miscelleneous input for is_writable() function ***\n";
+$name_prefix = "is_writable_variation2";
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
+create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
+create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
+create_files(dirname(__FILE__), 1, "numeric", 0555, 1, "w", $name_prefix, 4);
+create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
+create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
+create_files(dirname(__FILE__), 1, "text", 0114, 1, "w", $name_prefix, 7);
+create_files(dirname(__FILE__), 1, "numeric", 0244, 1, "w", $name_prefix, 8);
+create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
+create_files(dirname(__FILE__), 1, "text", 0422, 1, "w", $name_prefix, 10);
+
+$misc_files = array (
+ "$file_path/is_writable_variation21.tmp",
+ "$file_path/is_writable_variation22.tmp",
+ "$file_path/is_writable_variation23.tmp",
+ "$file_path/is_writable_variation24.tmp",
+ "$file_path/is_writable_variation25.tmp",
+ "$file_path/is_writable_variation26.tmp",
+ "$file_path/is_writable_variation27.tmp",
+ "$file_path/is_writable_variation28.tmp",
+ "$file_path/is_writable_variation29.tmp",
+ "$file_path/is_writable_variation210.tmp"
+);
+
+$counter = 1;
+/* loop through to test each element in the above array
+ is a writable file */
+foreach($misc_files as $misc_file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_writable($misc_file) );
+ var_dump( is_writeable($misc_file) );
+ $counter++;
+ clearstatcache();
+}
+
+// change all file's permissions to 777 before deleting
+change_file_perms($file_path, 10, 0777, $name_prefix);
+delete_files($file_path, 10, $name_prefix);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_writable_variation2/");
+?>
+--EXPECTF--
+*** Testing is_writable(): usage variations ***
+
+*** Testing is_writable() on directory without write permission ***
+bool(false)
+bool(false)
+
+*** Testing miscelleneous input for is_writable() function ***
+-- Iteration 1 --
+bool(true)
+bool(true)
+-- Iteration 2 --
+bool(true)
+bool(true)
+-- Iteration 3 --
+bool(true)
+bool(true)
+-- Iteration 4 --
+bool(false)
+bool(false)
+-- Iteration 5 --
+bool(true)
+bool(true)
+-- Iteration 6 --
+bool(true)
+bool(true)
+-- Iteration 7 --
+bool(false)
+bool(false)
+-- Iteration 8 --
+bool(true)
+bool(true)
+-- Iteration 9 --
+bool(false)
+bool(false)
+-- Iteration 10 --
+bool(false)
+bool(false)
+Done
+--UEXPECTF--
+*** Testing is_writable(): usage variations ***
+
+*** Testing is_writable() on directory without write permission ***
+bool(false)
+bool(false)
+
+*** Testing miscelleneous input for is_writable() function ***
+-- Iteration 1 --
+bool(true)
+bool(true)
+-- Iteration 2 --
+bool(true)
+bool(true)
+-- Iteration 3 --
+bool(true)
+bool(true)
+-- Iteration 4 --
+bool(false)
+bool(false)
+-- Iteration 5 --
+bool(true)
+bool(true)
+-- Iteration 6 --
+bool(true)
+bool(true)
+-- Iteration 7 --
+bool(false)
+bool(false)
+-- Iteration 8 --
+bool(true)
+bool(true)
+-- Iteration 9 --
+bool(false)
+bool(false)
+-- Iteration 10 --
+bool(false)
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test is_writable() and its alias is_writeable() function: usage variations - invalid file names
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on LINUX');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+
+/* test is_writable() & is_writeable() with invalid arguments */
+
+echo "*** Testing is_writable(): usage variations ***\n";
+
+echo "\n*** Testing is_writable() with invalid filenames ***\n";
+$misc_files = array(
+ 0,
+ 1234,
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ @array(),
+ @$file_handle
+);
+/* loop through to test each element in the above array
+ is a writable file */
+foreach( $misc_files as $misc_file ) {
+ var_dump( is_writable($misc_file) );
+ var_dump( is_writeable($misc_file) );
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_writable(): usage variations ***
+
+*** Testing is_writable() with invalid filenames ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_writable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+
+Warning: is_writeable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+bool(false)
+bool(false)
+Done
+--UEXPECTF--
+*** Testing is_writable(): usage variations ***
+
+*** Testing is_writable() with invalid filenames ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_writable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+
+Warning: is_writeable() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
+NULL
+bool(false)
+bool(false)
+Done