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 11/* Prototype : resource gzopen(string filename, string mode [, int use_include_path]) 12 * Description: Open a .gz-file and return a .gz-file pointer 13 * Source code: ext/zlib/zlib.c 14 * Alias to functions: 15 */ 16 17echo "*** Testing gzopen() : usage variation ***\n"; 18 19$testName = 'gzopen_variation4'; 20require_once('reading_include_path.inc'); 21 22//define the files to go into these directories, create one in dir2 23echo "\n--- testing include path ---\n"; 24set_include_path($newIncludePath); 25$modes = array("r", "r+", "rt"); 26foreach($modes as $mode) { 27 test_gzopen($mode); 28} 29 30// remove the directory structure 31chdir($baseDir); 32rmdir($workingDir); 33foreach($newdirs as $newdir) { 34 rmdir($newdir); 35} 36 37chdir(".."); 38rmdir($thisTestDir); 39 40function test_gzopen($mode) { 41 global $scriptFile, $secondFile, $firstFile, $filename; 42 43 // create a file in the middle directory 44 $h = gzopen($secondFile, "w"); 45 gzwrite($h, "This is a file in dir2"); 46 gzclose($h); 47 48 echo "\n** testing with mode=$mode **\n"; 49 // should read dir2 file 50 $h = gzopen($filename, $mode, true); 51 gzpassthru($h); 52 gzclose($h); 53 echo "\n"; 54 55 //create a file in dir1 56 $h = gzopen($firstFile, "w"); 57 gzwrite($h, "This is a file in dir1"); 58 gzclose($h); 59 60 //should now read dir1 file 61 $h = gzopen($filename, $mode, true); 62 gzpassthru($h); 63 gzclose($h); 64 echo "\n"; 65 66 // create a file in working directory 67 $h = gzopen($filename, "w"); 68 gzwrite($h, "This is a file in working dir"); 69 gzclose($h); 70 71 //should still read dir1 file 72 $h = gzopen($filename, $mode, true); 73 gzpassthru($h); 74 gzclose($h); 75 echo "\n"; 76 77 unlink($firstFile); 78 unlink($secondFile); 79 80 //should read the file in working dir 81 $h = gzopen($filename, $mode, true); 82 gzpassthru($h); 83 gzclose($h); 84 echo "\n"; 85 86 // create a file in the script directory 87 $h = gzopen($scriptFile, "w"); 88 gzwrite($h, "This is a file in script dir"); 89 gzclose($h); 90 91 //should read the file in script dir 92 $h = gzopen($filename, $mode, true); 93 gzpassthru($h); 94 gzclose($h); 95 echo "\n"; 96 97 //cleanup 98 unlink($filename); 99 unlink($scriptFile); 100 101} 102 103?> 104===DONE=== 105--EXPECTF-- 106*** Testing gzopen() : usage variation *** 107 108--- testing include path --- 109 110** testing with mode=r ** 111This is a file in dir2 112This is a file in dir1 113This is a file in dir1 114This is a file in working dir 115This is a file in script dir 116 117** testing with mode=r+ ** 118 119Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d 120 121Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d 122 123Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d 124 125 126Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d 127 128Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d 129 130Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d 131 132 133Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d 134 135Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d 136 137Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d 138 139 140Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d 141 142Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d 143 144Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d 145 146 147Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d 148 149Warning: gzpassthru() expects parameter 1 to be resource, bool given in %s on line %d 150 151Warning: gzclose() expects parameter 1 to be resource, bool given in %s on line %d 152 153 154** testing with mode=rt ** 155This is a file in dir2 156This is a file in dir1 157This is a file in dir1 158This is a file in working dir 159This is a file in script dir 160===DONE=== 161