1--TEST--
2Test fopen() function : variation: use include path create a file (relative)
3--CREDITS--
4Dave 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
13require_once('fopen_include_path.inc');
14
15$thisTestDir =  basename(__FILE__, ".php") . ".dir";
16mkdir($thisTestDir);
17chdir($thisTestDir);
18
19$newpath = create_include_path();
20set_include_path($newpath);
21runtest();
22$newpath = generate_next_path();
23set_include_path($newpath);
24runtest();
25
26teardown_include_path();
27restore_include_path();
28chdir("..");
29rmdir($thisTestDir);
30
31function runtest() {
32    global $dir1;
33	$tmpfile =  basename(__FILE__, ".php") . ".tmp";
34	$h = fopen($tmpfile, "w", true);
35	fwrite($h, (binary)"This is the test file");
36	fclose($h);
37
38
39	$h = @fopen($tmpfile, "r");
40	if ($h === false) {
41	   echo "Not created in working dir\n";
42	}
43	else {
44	   echo "created in working dir\n";
45	   fclose($h);
46	   unlink($tmpfile);
47	}
48
49	$h = @fopen($dir1.'/'.$tmpfile, "r");
50	if ($h === false) {
51	   echo "Not created in dir1\n";
52	}
53	else {
54	   echo "created in dir1\n";
55	   fclose($h);
56	   unlink($dir1.'/'.$tmpfile);
57	}
58}
59?>
60===DONE===
61--EXPECT--
62created in working dir
63Not created in dir1
64created in working dir
65Not created in dir1
66===DONE===
67