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