xref: /PHP-8.0/ext/phar/tests/tar/delete_in_phar.phpt (revision 0374cf08)
1--TEST--
2Phar: delete a file within a tar-based .phar
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7phar.require_hash=0
8opcache.validate_timestamps=1
9--FILE--
10<?php
11
12$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar';
13$alias = 'phar://' . $fname;
14
15$phar = new Phar($fname);
16$phar['a.php'] = '<?php echo "This is a\n"; ?>';
17$phar['b.php'] = '<?php echo "This is b\n"; ?>';
18$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
19$phar->setStub('<?php __HALT_COMPILER(); ?>');
20$phar->stopBuffering();
21
22include $alias . '/a.php';
23include $alias . '/b.php';
24include $alias . '/b/c.php';
25unlink($alias . '/b/c.php');
26
27?>
28===AFTER===
29<?php
30include $alias . '/a.php';
31include $alias . '/b.php';
32include $alias . '/b/c.php';
33?>
34
35--CLEAN--
36<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
37--EXPECTF--
38This is a
39This is b
40This is b/c
41===AFTER===
42This is a
43This is b
44
45Warning: include(%sdelete_in_phar.phar.tar/b/c.php): Failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.tar" in %sdelete_in_phar.php on line %d
46
47Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.tar/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
48
49