Annotation of embedaddon/php/ext/standard/tests/file/realpath_variation-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test realpath() function: usage variation
                      3: --SKIPIF--
                      4: <?php
                      5: if (substr(PHP_OS, 0, 3) != 'WIN') {
                      6:     die('skip only on Windows');
                      7: }
                      8: ?>
                      9: --FILE--
                     10: <?php
                     11: /* Prototype: string realpath ( string $path );
                     12:    Description: Returns canonicalized absolute pathname
                     13: */
                     14: 
                     15: require dirname(__FILE__).'/file.inc';
                     16: 
                     17: echo "*** Testing realpath(): usage variations ***\n";
                     18: $name_prefix = dirname(__FILE__);
                     19: $filename = "$name_prefix/realpath_variation/home/tests/realpath_variation.tmp";
                     20: mkdir("$name_prefix/realpath_variation/home/tests/", 0777, true);
                     21: 
                     22: echo "\n*** Testing realpath() with filename stored inside a object ***\n";
                     23: // create a temp file
                     24: $file_handle = fopen($filename, "w");
                     25: fclose($file_handle);
                     26: 
                     27: // creating object with members as filename
                     28: class object_temp {
                     29:   public $filename;
                     30:   function object_temp($file) {
                     31:     $this->filename = $file;
                     32:   }
                     33: }
                     34: $obj1 = new object_temp("$name_prefix/realpath_variation/../././realpath_variation/home/tests/realpath_variation.tmp");
                     35: $obj2 = new object_temp("$name_prefix/realpath_variation/home/..///realpath_variation.tmp");
                     36: 
                     37: var_dump( realpath($obj1->filename) );
                     38: var_dump( realpath($obj2->filename) );
                     39: 
                     40: echo "\n*** Testing realpath() with filename stored in an array ***\n";
                     41: $file_arr = array (
                     42:   "$name_prefix////realpath_variation/home/tests/realpath_variation.tmp",
                     43:   "$name_prefix/./realpath_variation/home/../home//tests//..//..//..//home//realpath_variation.tmp/"
                     44: );
                     45: 
                     46: var_dump( realpath($file_arr[0]) ); 
                     47: var_dump( realpath($file_arr[1]) );
                     48: 
                     49: echo "\n*** Testing realpath() with filename as empty string, NULL and single space ***\n";
                     50: $file_string = array (
                     51:   /* filename as spaces */
                     52:   " ",
                     53:   ' ',
                     54: 
                     55:   /* empty filename */
                     56:   "",
                     57:   '',
                     58:   NULL,
                     59:   null
                     60:  );
                     61: for($loop_counter = 0; $loop_counter < count($file_string); $loop_counter++) {
                     62:   echo "-- Iteration";
                     63:   echo $loop_counter + 1;
                     64:   echo " --\n";
                     65:   var_dump( realpath($file_string[$loop_counter]) ); 
                     66: }
                     67: 
                     68: echo "Done\n";
                     69: ?>
                     70: --CLEAN--
                     71: <?php
                     72: $name_prefix = dirname(__FILE__)."/realpath_variation";
                     73: unlink("$name_prefix/home/tests/realpath_variation.tmp");
                     74: rmdir("$name_prefix/home/tests/");
                     75: rmdir("$name_prefix/home/");
                     76: rmdir("$name_prefix/");
                     77: ?>
                     78: --EXPECTF--
                     79: *** Testing realpath(): usage variations ***
                     80: 
                     81: *** Testing realpath() with filename stored inside a object ***
                     82: string(%d) "%s\realpath_variation\home\tests\realpath_variation.tmp"
                     83: bool(false)
                     84: 
                     85: *** Testing realpath() with filename stored in an array ***
                     86: string(%d) "%s\realpath_variation\home\tests\realpath_variation.tmp"
                     87: bool(false)
                     88: 
                     89: *** Testing realpath() with filename as empty string, NULL and single space ***
                     90: -- Iteration1 --
                     91: bool(false)
                     92: -- Iteration2 --
                     93: bool(false)
                     94: -- Iteration3 --
                     95: string(%d) "%s"
                     96: -- Iteration4 --
                     97: string(%d) "%s"
                     98: -- Iteration5 --
                     99: string(%d) "%s"
                    100: -- Iteration6 --
                    101: string(%d) "%s"
                    102: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>