import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / tempnam_variation4.php
bloba7819fdd133224923ea5974772b3c282c294b1e9
1 <?php
2 /* Prototype: string tempnam ( string $dir, string $prefix );
3 Description: Create file with unique file name.
4 */
6 /* Trying to create the file in a dir with permissions from 0000 to 0777,
7 Allowable permissions: files are expected to be created in the input dir
8 Non-allowable permissions: files are expected to be created in '/tmp' dir
9 */
11 echo "*** Testing tempnam() with dir of permissions from 0000 to 0777 ***\n";
12 $file_path = dirname(__FILE__);
13 $dir_name = $file_path."/tempnam_variation4";
14 $prefix = "tempnamVar4.";
16 mkdir($dir_name);
18 for($mode = 0000; $mode <= 0777; $mode++) {
19 echo "-- dir perms ";
20 printf("%o", $mode);
21 echo " --\n";
22 chmod($dir_name, $mode);
23 $file_name = tempnam($dir_name, $prefix);
25 if(file_exists($file_name) ) {
26 if (realpath(dirname($file_name)) == realpath(sys_get_temp_dir())) {
27 $msg = " created in temp dir ";
29 else if (dirname($file_name) == $dir_name) {
30 $msg = " created in requested dir";
32 else {
33 $msg = " created in unexpected dir";
36 echo $msg."\n";
37 unlink($file_name);
39 else {
40 print("FAILED: File is not created\n");
44 rmdir($dir_name);
46 echo "*** Done ***\n";