1--TEST-- 2Test gzopen() function : variation: use include path (relative directories in path) 3--SKIPIF-- 4<?php 5if (!extension_loaded("zlib")) { 6 print "skip - ZLIB extension not loaded"; 7} 8?> 9--FILE-- 10<?php 11echo "*** Testing gzopen() : usage variation ***\n"; 12 13$testName = 'gzopen_variation4'; 14require_once('reading_include_path.inc'); 15 16//define the files to go into these directories, create one in dir2 17echo "\n--- testing include path ---\n"; 18set_include_path($newIncludePath); 19$modes = array("r", "r+", "rt"); 20foreach($modes as $mode) { 21 test_gzopen($mode); 22} 23 24// remove the directory structure 25chdir($baseDir); 26rmdir($workingDir); 27foreach($newdirs as $newdir) { 28 rmdir($newdir); 29} 30 31chdir(".."); 32rmdir($thisTestDir); 33 34function test_gzopen($mode) { 35 global $scriptFile, $secondFile, $firstFile, $filename; 36 37 // create a file in the middle directory 38 $h = gzopen($secondFile, "w"); 39 gzwrite($h, "This is a file in dir2"); 40 gzclose($h); 41 42 echo "\n** testing with mode=$mode **\n"; 43 // should read dir2 file 44 $h = gzopen($filename, $mode, true); 45 if ($h) { 46 gzpassthru($h); 47 gzclose($h); 48 echo "\n"; 49 } 50 51 //create a file in dir1 52 $h = gzopen($firstFile, "w"); 53 gzwrite($h, "This is a file in dir1"); 54 gzclose($h); 55 56 //should now read dir1 file 57 $h = gzopen($filename, $mode, true); 58 if ($h) { 59 gzpassthru($h); 60 gzclose($h); 61 echo "\n"; 62 } 63 64 // create a file in working directory 65 $h = gzopen($filename, "w"); 66 gzwrite($h, "This is a file in working dir"); 67 gzclose($h); 68 69 //should still read dir1 file 70 $h = gzopen($filename, $mode, true); 71 if ($h) { 72 gzpassthru($h); 73 gzclose($h); 74 echo "\n"; 75 } 76 77 unlink($firstFile); 78 unlink($secondFile); 79 80 //should read the file in working dir 81 $h = gzopen($filename, $mode, true); 82 if ($h) { 83 gzpassthru($h); 84 gzclose($h); 85 echo "\n"; 86 } 87 88 // create a file in the script directory 89 $h = gzopen($scriptFile, "w"); 90 gzwrite($h, "This is a file in script dir"); 91 gzclose($h); 92 93 //should read the file in script dir 94 $h = gzopen($filename, $mode, true); 95 if ($h) { 96 gzpassthru($h); 97 gzclose($h); 98 echo "\n"; 99 } 100 101 //cleanup 102 unlink($filename); 103 unlink($scriptFile); 104} 105 106?> 107--EXPECTF-- 108*** Testing gzopen() : usage variation *** 109 110--- testing include path --- 111 112** testing with mode=r ** 113This is a file in dir2 114This is a file in dir1 115This is a file in dir1 116This is a file in working dir 117This is a file in script dir 118 119** testing with mode=r+ ** 120 121Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d 122 123Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d 124 125Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d 126 127Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d 128 129Warning: gzopen(): Cannot open a zlib stream for reading and writing at the same time! in %s on line %d 130 131** testing with mode=rt ** 132This is a file in dir2 133This is a file in dir1 134This is a file in dir1 135This is a file in working dir 136This is a file in script dir 137