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