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
7require_once('fopen_include_path.inc');
8
9$thisTestDir =  basename(__FILE__, ".php") . ".dir";
10mkdir($thisTestDir);
11chdir($thisTestDir);
12
13$newpath = create_include_path();
14set_include_path($newpath);
15runtest();
16$newpath = generate_next_path();
17set_include_path($newpath);
18runtest();
19
20teardown_include_path();
21chdir("..");
22rmdir($thisTestDir);
23
24function runtest() {
25    global $dir1;
26    $tmpfile =  basename(__FILE__, ".php") . ".tmp";
27    $h = fopen($tmpfile, "w", true);
28    fwrite($h, "This is the test file");
29    fclose($h);
30
31
32    $h = @fopen($tmpfile, "r");
33    if ($h === false) {
34       echo "Not created in working dir\n";
35    }
36    else {
37       echo "created in working dir\n";
38       fclose($h);
39       unlink($tmpfile);
40    }
41
42    $h = @fopen($dir1.'/'.$tmpfile, "r");
43    if ($h === false) {
44       echo "Not created in dir1\n";
45    }
46    else {
47       echo "created in dir1\n";
48       fclose($h);
49       unlink($dir1.'/'.$tmpfile);
50    }
51}
52?>
53--EXPECT--
54created in working dir
55Not created in dir1
56created in working dir
57Not created in dir1
58