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