xref: /PHP-8.2/ext/phar/tests/mkdir.phpt (revision 74859783)
1--TEST--
2phar: mkdir/rmdir edge cases
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
10$pname = 'phar://' . $fname;
11Phar::interceptFileFuncs();
12mkdir('phar://');
13mkdir('phar://foo.phar');
14$a = new Phar($fname);
15$a['a'] = 'hi';
16mkdir($pname . '/a');
17rmdir('phar://');
18rmdir('phar://foo.phar');
19rmdir($pname . '/a');
20$a->addEmptyDir('bb');
21$a->addEmptyDir('bb');
22try {
23$a->addEmptyDir('.phar');
24} catch (Exception $e) {
25echo $e->getMessage(),"\n";
26}
27?>
28--CLEAN--
29<?php
30unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
31__HALT_COMPILER();
32?>
33--EXPECTF--
34Warning: mkdir(): phar error: cannot create directory "phar://", no phar archive specified in %smkdir.php on line %d
35
36Warning: mkdir(): phar error: cannot create directory "" in phar "foo.phar", phar error: invalid path "" must not be empty in %smkdir.php on line %d
37
38Warning: mkdir(): phar error: cannot create directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d
39
40Warning: rmdir(): phar error: cannot remove directory "phar://", no phar archive specified, or phar archive does not exist in %smkdir.php on line %d
41
42Warning: rmdir(): phar error: cannot remove directory "" in phar "foo.phar", directory does not exist in %smkdir.php on line %d
43
44Warning: rmdir(): phar error: cannot remove directory "a" in phar "%smkdir.phar.php", phar error: path "a" exists and is a not a directory in %smkdir.php on line %d
45Cannot create a directory in magic ".phar" directory
46