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