sync the repo
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / file / fopen_variation16.php
blob5fef796f411827663e3da93c143f7170abaa06f4
1 <?hh
2 /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
3 * Description: Open a file or a URL and return a file pointer
4 * Source code: ext/standard/file.c
5 * Alias to functions:
6 */
8 function runtest() :mixed{
11 $extraDir = "extraDir16";
13 mkdir(ZendGoodExtStandardTestsFileFopenIncludePathInc::dir1().'/'.$extraDir);
14 mkdir($extraDir);
16 $tmpfile = $extraDir.'/fopen_variation16.tmp';
18 $h = fopen($tmpfile, "w+", true);
19 fwrite($h, (string)"This is the test file");
20 fclose($h);
22 $h = @fopen(ZendGoodExtStandardTestsFileFopenIncludePathInc::dir1().'/'.$tmpfile, "r");
23 if ($h === false) {
24 echo "Not created in dir1\n";
26 else {
27 echo "created in dir1\n";
28 fclose($h);
31 $h = fopen($tmpfile, "r", true);
32 if ($h === false) {
33 echo "could not find file for reading\n";
35 else {
36 echo "found file - not in dir1\n";
37 fclose($h);
40 unlink($tmpfile);
41 rmdir(ZendGoodExtStandardTestsFileFopenIncludePathInc::dir1().'/'.$extraDir);
42 rmdir($extraDir);
44 <<__EntryPoint>> function main(): void {
45 require_once('fopen_include_path.inc');
46 $thisTestDir = sys_get_temp_dir().'/'.'fopenVariation16.dir';
48 mkdir($thisTestDir);
49 $oldDirPath = getcwd();
50 chdir($thisTestDir);
52 $newpath = create_include_path();
53 set_include_path($newpath);
54 runtest();
56 $newpath = generate_next_path();
57 set_include_path($newpath);
58 runtest();
60 teardown_include_path();
61 restore_include_path();
62 chdir($oldDirPath);
63 rmdir($thisTestDir);
65 echo "===DONE===\n";