xref: /PHP-8.2/ext/phar/tests/tar/rmdir.phpt (revision 74859783)
1--TEST--
2Phar: rmdir test tar-based
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10include __DIR__ . '/files/tarmaker.php.inc';
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar';
12$alias = 'phar://' . $fname;
13
14$tar = new tarmaker($fname, 'none');
15$tar->init();
16$tar->addFile('.phar/stub.php', "<?php
17Phar::mapPhar('hio');
18__HALT_COMPILER(); ?>");
19
20$files = array();
21$files['a/x'] = 'a';
22
23foreach ($files as $n => $file) {
24    $tar->addFile($n, $file);
25}
26$tar->mkdir('a');
27
28$tar->close();
29
30include $fname;
31
32echo file_get_contents($alias . '/a/x') . "\n";
33var_dump(rmdir($alias . '/a'));
34echo file_get_contents($alias . '/a/x') . "\n";
35unlink($alias . '/a/x');
36var_dump(rmdir($alias . '/a'));
37?>
38--CLEAN--
39<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
40--EXPECTF--
41a
42
43Warning: rmdir(): phar error: Directory not empty in %srmdir.php on line %d
44bool(false)
45a
46bool(true)
47