1--TEST--
2Phar: test edge cases of fopen() function interception #2
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9Phar::interceptFileFuncs();
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
11$pname = 'phar://' . $fname;
12
13fopen(array(), 'r');
14chdir(dirname(__FILE__));
15file_put_contents($fname, "blah\n");
16file_put_contents("foob", "test\n");
17$a = fopen($fname, 'rb');
18echo fread($a, 1000);
19fclose($a);
20unlink($fname);
21mkdir($pname . '/oops');
22file_put_contents($pname . '/foo/hi', '<?php
23$context = stream_context_create();
24$a = fopen("foob", "rb", false, $context);
25echo fread($a, 1000);
26fclose($a);
27fopen("../oops", "r");
28?>
29');
30include $pname . '/foo/hi';
31?>
32===DONE===
33--CLEAN--
34<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
35<?php rmdir(dirname(__FILE__) . '/poo'); ?>
36<?php unlink(dirname(__FILE__) . '/foob'); ?>
37--EXPECTF--
38Warning: fopen() expects parameter 1 to be a valid path, array given in %sfopen_edgecases2.php on line %d
39blah
40test
41
42Warning: fopen(phar://%sfopen_edgecases2.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfopen_edgecases2.phar.php/foo/hi on line %d
43===DONE===
44