Annotation of embedaddon/php/ext/standard/tests/file/fopen_variation17.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fopen() function : variation: use include path create and read a file (relative)
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --FILE--
6: <?php
7: /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
8: * Description: Open a file or a URL and return a file pointer
9: * Source code: ext/standard/file.c
10: * Alias to functions:
11: */
12:
13: require_once('fopen_include_path.inc');
14:
15: $thisTestDir = basename(__FILE__, ".php") . ".dir";
16: mkdir($thisTestDir);
17: chdir($thisTestDir);
18:
19: $newpath = create_include_path();
20: set_include_path($newpath);
21: runtest();
22:
23: $newpath = generate_next_path();
24: set_include_path($newpath);
25: runtest();
26:
27: teardown_include_path();
28: restore_include_path();
29: chdir("..");
30: rmdir($thisTestDir);
31:
32: function runtest() {
33: global $dir1;
34:
35: $extraDir = "extraDir";
36:
37: mkdir($dir1.'/'.$extraDir);
38: mkdir($extraDir);
39:
40: $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp";
41: $h = fopen($tmpfile, "w+", true);
42: fwrite($h, (binary) "This is the test file");
43: fclose($h);
44:
45: $h = @fopen($dir1.'/'.$tmpfile, "r");
46: if ($h === false) {
47: echo "Not created in dir1\n";
48: }
49: else {
50: echo "created in dir1\n";
51: fclose($h);
52: }
53:
54: $h = fopen($tmpfile, "r", true);
55: if ($h === false) {
56: echo "could not find file for reading\n";
57: }
58: else {
59: echo "found file for reading\n";
60: fclose($h);
61: }
62:
63: unlink($tmpfile);
64: rmdir($dir1.'/'.$extraDir);
65: rmdir($extraDir);
66: }
67: ?>
68: ===DONE===
69: --EXPECT--
70: Not created in dir1
71: found file for reading
72: Not created in dir1
73: found file for reading
74: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>