import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / realpath_basic3.php
blobf549e3633858ccdcb6049428e70b5ca9067a7d2f
1 <?php
2 /* Prototype: string realpath ( string $path );
3 Description: Returns canonicalized absolute pathname
4 */
6 echo "\n*** Testing basic functions of realpath() with files ***\n";
8 /* creating directories and files */
9 $file_path = dirname(__FILE__);
10 mkdir("$file_path/realpath_basic/home/test/", 0777, true);
12 $file_handle1 = fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w");
13 $file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", "w");
14 $file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w");
15 fclose($file_handle1);
16 fclose($file_handle2);
17 fclose($file_handle3);
19 echo "\n*** Testing realpath() on filenames ***\n";
20 $filenames = array (
21 /* filenames resulting in valid paths */
22 "./realpath_basic/home/realpath_basic.tmp",
23 "./realpath_basic/realpath_basic.tmp",
24 "./realpath_basic//home/test//../test/./realpath_basic.tmp",
25 "./realpath_basic/home//../././realpath_basic.tmp",
27 /* filenames with invalid path */
28 // checking for binary safe
29 "./realpath_basicx000/home/realpath_basic.tmp",
31 ".///realpath_basic/home//..//././test//realpath_basic.tmp",
32 "./realpath_basic/home/../home/../test/..realpath_basic.tmp"
35 chdir("$file_path/..");
36 chdir($file_path);
38 $counter = 1;
39 /* loop through $files to read the filepath of $file in the above array */
40 foreach($filenames as $file) {
41 echo "\n-- Iteration $counter --\n";
42 var_dump( realpath($file) );
43 $counter++;
46 echo "Done\n";
47 ?><?php
48 $name_prefix = dirname(__FILE__)."/realpath_basic";
49 unlink("$name_prefix/home/test/realpath_basic.tmp");
50 unlink("$name_prefix/home/realpath_basic.tmp");
51 unlink("$name_prefix/realpath_basic.tmp");
52 rmdir("$name_prefix/home/test/");
53 rmdir("$name_prefix/home/");
54 rmdir("$name_prefix/");