*** testing touch ***
-Warning: touch(): Unable to create file because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
bool(false)
-Warning: touch(): Unable to create file because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
bool(false)
-Warning: touch(): Unable to create file because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
bool(false)
-Warning: touch(): Unable to create file because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
bool(false)
-Warning: touch(): Unable to create file | because %s in %s on line %d
+Warning: touch(): %s in %s on line %d
bool(false)
Done
if(PHP_WINDOWS_VERSION_MAJOR < 6) {
die('skip windows version 6.0+ only test');
}
+
+$ret = exec('mklink rename_variation13tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+ die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
?>
--FILE--
<?php
NULL
--uppercase NULL--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--lowercase null--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--lowercase true--
bool(false)
--lowercase false--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--uppercase TRUE--
bool(false)
--uppercase FALSE--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--empty string DQ--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--empty string SQ--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--instance of classWithToString--
NULL
--undefined var--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
--unset var--
-Error: 2 - chmod(): No such file or directory, %s(%d)
+Error: 2 - chmod(): %s, %s(%d)
bool(false)
===DONE===
if($file_handle == false)
exit("Error:failed to open file $filename");
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $data = str_replace("\r",'', $data);
+}
+
// writing data to the file
var_dump( fwrite($file_handle, $data) );
var_dump( fflush($file_handle) );
<html> html </html> <?php echo "php"; ?>
EOT;
-
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
/* try reading the file opened in different modes of reading */
$file_modes = array("r","rb", "rt","r+", "r+b", "r+t");
echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing fgetss() : Basic operations ***
-- Testing fgetss() with file opened using r mode --
is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
<html> html </html> <?php echo "php"; ?>
EOT;
-
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
$filename = dirname(__FILE__)."/fgetss_basic2.tmp";
/* try reading the file opened in different modes of reading */
this is the line with \n character.
EOT;
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
$filename = dirname(__FILE__)."/fgetss_variation1.tmp";
/* try reading the file opened in different modes of reading */
echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing fgetss() : usage variations ***
-- Testing fgetss() with file opened using w mode --
this is the line with \n character.
EOT;
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
$filename = dirname(__FILE__)."/fgetss_variation3.tmp";
/* try reading the file opened in different modes of reading */
echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing fgetss() : usage variations ***
-- Testing fgetss() with file opened using w+ mode --
--TEST--
Test fgetss() function : usage variations - read modes, file pointer at EOF
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip not for Windows");
+?>
--FILE--
<?php
/*
this text contains some html tags <body> body </body> <br> br </br>
this is the line with \n character.
EOT;
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
$filename = dirname(__FILE__)."/fgetss_variation5.tmp";
echo "Done\n";
?>
---EXPECTF--
+--EXPECT--
*** Testing fgetss() : usage variations ***
-- Testing fgetss() with file opened using w+ mode --
filled => total files filled, always returned as 1
perms_changed => total files permission changed
*/
-function create_links( $file_path,
- $filename,
- $link_count = 1,
- $link_type = "soft",
- $link_size = 1024,
- $link_name_prefix = "link",
- $link_name_suffix = 1,
- $link_file_content = "text",
- $link_perms = 0755,
- $link_file_extension = ".tmp"
+function create_links($file_path,
+ $filename,
+ $link_count = 1,
+ $link_type = "soft",
+ $link_size = 1024,
+ $link_name_prefix = "link",
+ $link_name_suffix = 1,
+ $link_file_content = "text",
+ $link_perms = 0755,
+ $link_file_extension = ".tmp"
)
{
$return_value = array('created' => 0, 'filled' => 0, 'perms_changed' => 0);
<?php
if(substr(PHP_OS, 0, 3) != "WIN")
die("skip Run only on Windows");
+
+if (!is_writable('c:\\fopen_variation10.tmp')) {
+ die('skip. C:\\ not writable.');
+}
+
?>
--FILE--
<?php
<?php
if(substr(PHP_OS, 0, 3) != "WIN")
die("skip Run only on Windows");
+if (!is_writable('c:\\fopen_variation10.tmp')) {
+ die('skip. C:\\ not writable.');
+}
+
?>
--FILE--
<?php
mkdir($dir1.'/'.$extraDir);
mkdir($extraDir);
- $tmpfile = $extraDir.'/ basename(__FILE__, ".php") . ".tmp"';
+ $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp";
$h = fopen($tmpfile, "w+", true);
fwrite($h, (binary) "This is the test file");
fclose($h);
$string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^
Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
-
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string = str_replace("\r",'', $string);
+}
fwrite($write_handle, $string);
fclose($write_handle);
*** Testing mkdir() : usage variation ***
--uppercase NULL--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--lowercase null--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--lowercase false--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--uppercase FALSE--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--empty string DQ--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--empty string SQ--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--undefined var--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--unset var--
-Error: 2 - mkdir(): No such file or directory, %s(%d)
+Error: 2 - mkdir(): %s, %s(%d)
--single space--
Error: 2 - mkdir(): %s, %s(%d)
bool(true)
-- Iteration 2 --
-Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): No such file or directory in %s on line %d
+Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): The filename, directory name, or volume label syntax is incorrect. (code: 123) in %s on line %d
bool(false)
bool(false)
bool(false)
-- Iteration 5 --
-Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
bool(false)
-- Iteration 6 --
-Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
bool(false)
-- Iteration 7 --
-- Iteration 11 --
-Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
bool(false)
-- Iteration 12 --
--- /dev/null
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
+?>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ touch($absSubDir."/".$fromFile);
+ $res = rename($dir."/".$fromFile, $dir."/".$toFile);
+ var_dump($res);
+ if ($res == true) {
+ $res = rename($dir."/".$toFile, $dir."/".$fromFile);
+ var_dump($res);
+ }
+ unlink($absSubDir."/".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+*** Done ***
\ No newline at end of file
Test rename() function : variation - various relative, absolute paths
--CREDITS--
Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip.. not for Windows');
+?>
--FILE--
<?php
/* Prototype : bool rename(string old_name, string new_name[, resource context])
-- Iteration 5 --
-Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): %s in %s on line %d
bool(false)
-- Iteration 6 --
-Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): %s in %s on line %d
bool(false)
-- Iteration 7 --
-- Iteration 11 --
-Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): No such file or directory in %s on line %d
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): %s in %s on line %d
bool(false)
-*** Done ***
\ No newline at end of file
+*** Done ***
--SKIPIF--
<?php
if(substr(PHP_OS, 0, 3) == "WIN")
- die("skip Not for Windows");
+ die("skip. Not for Windows");
?>
--FILE--
<?php
* Alias to functions:
*/
-
echo "*** Testing rename() with obscure files ***\n";
$file_path = dirname(__FILE__)."/renameVar13";
$aFile = $file_path.'/afile.tmp';
bool(false)
-- testing '' --
-Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
bool(false)
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
bool(false)
-- testing '' --
-Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
bool(false)
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
bool(false)
-- testing '' --
-Warning: rename(%s/renameVar13/afile.tmp,): No such file or directory in %s on line %d
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
bool(false)
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
bool(false)
-- testing ' ' --
bool(true)
Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
bool(false)
-Warning: rename(,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
bool(false)
-- testing 'Array' --
Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
bool(false)
-*** Done ***
\ No newline at end of file
+*** Done ***
$filename = "$file_path/rename_variation3.tmp";
$fp = fopen($filename, "w");
+if (!$fp) {
+ die("Cannot create $filename\n");
+}
fclose($fp);
echo "\n-- Renaming file to same file name --\n";
-- Renaming existing file to existing directory name --
-Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): No such file or directory in %s on line %d
+Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): Access is denied. (code: 5) in %s on line %d
bool(false)
bool(true)
bool(true)
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
if (!function_exists("symlink")) die("skip symlinks are not supported");
+$ret = exec('mklink rename_variation13tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+ die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
?>
--FILE--
<?php
--- /dev/null
+--TEST--\r
+Test rename() function: variation\r
+--SKIPIF--\r
+<?php\r
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');\r
+?>\r
+--FILE--\r
+<?php\r
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );\r
+ Description: Renames a file or directory\r
+*/\r
+\r
+echo "\n*** Testing rename() on non-existing file ***\n";\r
+$file_path = dirname(__FILE__);\r
+\r
+// try renaming a non existing file\r
+$src_name = $file_path."/non_existent_file.tmp";\r
+$dest_name = $file_path."/rename_variation8_new.tmp";\r
+var_dump( rename($src_name, $dest_name) );\r
+\r
+// ensure that $dest_name didn't get created\r
+var_dump( file_exists($src_name) ); // expecting false\r
+var_dump( file_exists($dest_name) ); // expecting false\r
+\r
+// rename a existing dir to new name\r
+echo "\n*** Testing rename() on existing directory ***\n";\r
+$dir_name = $file_path."/rename_basic_dir";\r
+mkdir($dir_name);\r
+$new_dir_name = $file_path."/rename_basic_dir1";\r
+var_dump( rename($dir_name, $new_dir_name) );\r
+//ensure that $new_dir_name got created\r
+var_dump( file_exists($dir_name) ); // expecting false\r
+var_dump( file_exists($new_dir_name) ); // expecting true\r
+\r
+// try to rename an non_existing dir \r
+echo "\n*** Testing rename() on non-existing directory ***\n";\r
+$non_existent_dir_name = $file_path."/non_existent_dir";\r
+$new_dir_name = "$file_path/rename_basic_dir2";\r
+var_dump( rename($non_existent_dir_name, $new_dir_name) );\r
+// ensure that $new_dir_name didn't get created\r
+var_dump( file_exists($non_existent_dir_name) ); // expecting flase\r
+var_dump( file_exists($new_dir_name) ); // expecting false\r
+\r
+echo "Done\n";\r
+?>\r
+--CLEAN--\r
+<?php\r
+rmdir(dirname(__FILE__)."/rename_basic_dir1");\r
+?>\r
+--EXPECTF--\r
+*** Testing rename() on non-existing file ***\r
+\r
+Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): The system cannot find the file specified. (code: 2) in %s on line %d\r
+bool(false)\r
+bool(false)\r
+bool(false)\r
+\r
+*** Testing rename() on existing directory ***\r
+bool(true)\r
+bool(false)\r
+bool(true)\r
+\r
+*** Testing rename() on non-existing directory ***\r
+\r
+Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): The system cannot find the file specified. (code: 2) in %s on line %d\r
+bool(false)\r
+bool(false)\r
+bool(false)\r
+Done\r
+\r
--TEST--
Test rename() function: variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip.. not for Windows');
+?>
--FILE--
<?php
/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
?>
--CLEAN--
<?php
+unlink(dirname(__FILE__)."/rename_basic_new2.tmp");
rmdir(dirname(__FILE__)."/rename_basic_dir1");
?>
--EXPECTF--
unlink(dirname(__FILE__)."/rename_variation9_new.tmp");
rmdir(dirname(__FILE__)."/rename_variation_dir9_new");
?>
---EXPECTF--
+--EXPECT--
*** Testing rename() by giving stream context as third argument ***
bool(true)
bool(false)
*** Testing rmdir() : usage variation ***
--uppercase NULL--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--lowercase null--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--lowercase false--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--uppercase FALSE--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--empty string DQ--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--empty string SQ--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--undefined var--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--unset var--
-Error: 2 - rmdir(): No such file or directory, %s(%d)
+Error: 2 - rmdir(): %s, %s(%d)
bool(false)
--single space--
foreach($inputs as $key =>$value) {
echo "\n--$key--\n";
- var_dump( rmdir($value) );
+ var_dump(rmdir($value));
};
?>
--SKIPIF--
<?php
if(substr(PHP_OS, 0, 3) != "WIN")
- die("skip run only on Windows");
+ die("skip run only on Windows");
?>
--FILE--
<?php
echo "*** Testing tempnam() with obscure prefixes ***\n";
$file_path = dirname(__FILE__)."/tempnamVar3";
-mkdir($file_path);
+if (!mkdir($file_path)) {
+ echo "Failed, cannot create temp dir $filepath\n";
+ exit(1);
+}
+
+$file_path = realpath($file_path);
/* An array of prefixes */
$names_arr = array(
- /* Invalid args */
- -1,
- TRUE,
- FALSE,
- NULL,
- "",
- " ",
- "\0",
- array(),
+ /* Valid args (casting)*/
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ /* Invalid args */
+ array(),
- /* prefix with path separator of a non existing directory*/
- "/no/such/file/dir",
- "php/php"
+ /* Valid args*/
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir",
+ "php/php"
+);
+$res_arr = array(
+ /* Invalid args */
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ false,
+
+ /* prefix with path separator of a non existing directory*/
+ true,
+ true
);
for( $i=0; $i<count($names_arr); $i++ ) {
- echo "-- Iteration $i --\n";
- $file_name = tempnam("$file_path", $names_arr[$i]);
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam($file_path, $names_arr[$i]);
/* creating the files in existing dir */
if (file_exists($file_name) && !$res_arr[$i]) {
if (!is_writable($file_name)) {
printf("%o\n", fileperms($file_name) );
- echo "File permissions are => ";
- printf("%o", fileperms($file_name) );
- echo "\n";
-
- echo "File created in => ";
- $file_dir = dirname($file_name);
- if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
- echo "temp dir\n";
- }
- else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {
- echo "directory specified\n";
- }
- else {
- echo "unknown location\n";
- }
- }
- else {
- echo "-- File is not created --\n";
- }
-
- unlink($file_name);
+ }
+ } else {
+ echo "OK\n";
+ }
+ @unlink($file_name);
}
rmdir($file_path);
-echo "\n*** Done ***\n";
+echo "\n*** Done. ***\n";
?>
--EXPECTF--
*** Testing tempnam() with obscure prefixes ***
-- Iteration 0 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 1 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 2 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 3 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 4 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 5 --
Failed, not created in the correct directory %s vs %s
0
-- Iteration 6 --
-File name is => %s\%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 7 --
-Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
--- File is not created --
-
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
+OK
-- Iteration 8 --
-File name is => %s\di%s
-File permissions are => 100666
-File created in => directory specified
+OK
-- Iteration 9 --
-File name is => %s\ph%s
-File permissions are => 100666
-File created in => directory specified
-
-*** Done ***
+OK
+*** Done. ***
Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
-- File is not created --
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
-- Iteration 8 --
File name is => %s/dir%s
File permissions are => 100600
echo "*** Testing tempnam() with invalid/non-existing directory names ***\n";
/* An array of names, which will be passed as a dir name */
$names_arr = array(
- /* Invalid args */
- -1,
- TRUE,
- FALSE,
- NULL,
- "",
- " ",
- "\0",
- array(),
-
- /* Non-existing dirs */
- "/no/such/file/dir",
- "php"
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+ /* Non-existing dirs */
+ "/no/such/file/dir",
+ "php"
);
for( $i=0; $i<count($names_arr); $i++ ) {
- echo "-- Iteration $i --\n";
- $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
+
+ if( file_exists($file_name) ){
+
+ echo "File name is => ";
+ print($file_name);
+ echo "\n";
- if( file_exists($file_name) ){
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
- echo "File name is => ";
- print($file_name);
- echo "\n";
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+ if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ } else {
+ echo "unknown location\n";
+ }
+ } else {
+ echo "-- File is not created --\n";
+ }
- echo "File permissions are => ";
- printf("%o", fileperms($file_name) );
- echo "\n";
-
- echo "File created in => ";
- $file_dir = dirname($file_name);
- if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
- echo "temp dir\n";
- }
- else {
- echo "unknown location\n";
- }
- }
- else {
- echo "-- File is not created --\n";
- }
-
- unlink($file_name);
+ unlink($file_name);
}
echo "\n*** Done ***\n";
Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
-- File is not created --
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
-- Iteration 8 --
File name is => %s%et%s
File permissions are => 100666
Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
-- File is not created --
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
-- Iteration 8 --
File name is => %s%etempnam_variation3.tmp%s
File permissions are => 100600
-- Testing unlink() on invalid arguments --
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
bool(false)
bool(false)
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
bool(false)
bool(false)
-Warning: unlink(): No such file or directory in %s on line %d
+Warning: unlink(): %s in %s on line %d
bool(false)
bool(false)
value:
int(0)
ptrparam:
-int(8192)
+int(%d)
$option === 3 === 3:
bool(true)
$value === 0 === 0:
function create_file($name, $perms) {
if (empty($name)) {
- echo "create_dir: Empty name is not allowed\n";
+ echo "create_file: Empty name is not allowed\n";
return;
}
<?php\r
$old_dir = __DIR__;\r
$dirname = __DIR__ . "\\mnt\\test\\directory";\r
-exec("mkdir " . $dirname, $output, $ret_val);\r
+mkdir($dirname, 0700, true);\r
chdir(__DIR__ . "\\mnt\\test");\r
$drive = substr(__DIR__, 0, 2);\r
$pathwithoutdrive = substr(__DIR__, 2);\r
var_dump(is_readable("mklink_junction"));\r
var_dump(is_writeable("$fullpath"));\r
chdir($old_dir);\r
+\r
rmdir(__DIR__ . "\\mnt\\test\\directory");\r
rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");\r
rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");\r
bool(true)\r
bool(true)\r
bool(true)\r
-bool(true)
+bool(true)\r
if(substr(PHP_OS, 0, 3) != 'WIN' ) {\r
die('skip windows only test');\r
}\r
-$cmd = "mklink.exe /?";\r
-$ret = @exec($cmd, $output, $return_val);\r
-if (count($output) == 0) {\r
- die("mklink.exe not found in PATH");\r
+$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);\r
+if (strpos($ret, 'privilege')) {\r
+ die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');\r
}\r
+unlink('mklink bug48746_tmp.lnk');\r
?>\r
--FILE--\r
<?php\r
--SKIPIF--\r
<?php\r
if(substr(PHP_OS, 0, 3) != 'WIN' ) {\r
- die('skip windows only test');\r
+ die('skip windows only test');\r
}\r
-$cmd = "junction.exe /?";\r
-$ret = @exec($cmd, $output, $return_val);\r
-if (count($output) == 0) {\r
- die("junction.exe not found in PATH");\r
+$ret = exec('junction /? 2>&1', $out);\r
+if (strpos($out[0], 'recognized')) {\r
+ die('skip. junction.exe not found in PATH.');\r
}\r
+\r
?>\r
--FILE--\r
<?php\r