Annotation of embedaddon/php/ext/zlib/tests/gzopen_variation4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test gzopen() function : variation: use include path (relative directories in path)
3: --SKIPIF--
4: <?php
5: if (!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:
17: echo "*** Testing gzopen() : usage variation ***\n";
18:
19: require_once('reading_include_path.inc');
20:
21: //define the files to go into these directories, create one in dir2
22: echo "\n--- testing include path ---\n";
23: set_include_path($newIncludePath);
24: $modes = array("r", "r+", "rt");
25: foreach($modes as $mode) {
26: test_gzopen($mode);
27: }
28: restore_include_path();
29:
30: // remove the directory structure
31: chdir($baseDir);
32: rmdir($workingDir);
33: foreach($newdirs as $newdir) {
34: rmdir($newdir);
35: }
36:
37: chdir("..");
38: rmdir($thisTestDir);
39:
40: function 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 **
111: This is a file in dir2
112: This is a file in dir1
113: This is a file in dir1
114: This is a file in working dir
115: This is a file in script dir
116:
117: ** testing with mode=r+ **
118:
119: Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
120:
121: Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
122:
123: Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
124:
125:
126: Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
127:
128: Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
129:
130: Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
131:
132:
133: Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
134:
135: Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
136:
137: Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
138:
139:
140: Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
141:
142: Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
143:
144: Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
145:
146:
147: Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
148:
149: Warning: gzpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
150:
151: Warning: gzclose() expects parameter 1 to be resource, boolean given in %s on line %d
152:
153:
154: ** testing with mode=rt **
155: This is a file in dir2
156: This is a file in dir1
157: This is a file in dir1
158: This is a file in working dir
159: This is a file in script dir
160: ===DONE===
161:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>