xref: /php-src/ext/phar/tests/phar_gobyebye.phpt (revision 98d004c9)
1--TEST--
2Phar: test edge cases of intercepted functions when the underlying phar archive has been unlinkArchive()d
3--EXTENSIONS--
4phar
5--SKIPIF--
6<?php
7if (defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip");
8?>
9--INI--
10phar.readonly=0
11--FILE--
12<?php
13Phar::interceptFileFuncs();
14$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
15$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.php';
16$pname = 'phar://' . $fname;
17file_put_contents($fname2, '<?php Phar::unlinkArchive("' . addslashes($fname) . '");');
18file_put_contents($pname . '/foo/hi', '<?php
19include "' . addslashes($fname2) . '";
20readfile("foo/hi");
21fopen("foo/hi", "r");
22echo file_get_contents("foo/hi");
23var_dump(is_file("foo/hi"),is_link("foo/hi"),is_dir("foo/hi"),file_exists("foo/hi"),stat("foo/hi"));
24opendir("foo/hi");
25?>
26');
27include $pname . '/foo/hi';
28?>
29--CLEAN--
30<?php
31@unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
32unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.php');
33?>
34--EXPECTF--
35Warning: readfile(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
36
37Warning: fopen(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
38
39Warning: file_get_contents(foo/hi): Failed to open stream: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
40
41Warning: stat(): stat failed for foo/hi in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
42bool(false)
43bool(false)
44bool(false)
45bool(false)
46bool(false)
47
48Warning: opendir(foo/hi): Failed to open directory: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
49