xref: /php-src/ext/phar/tests/tar/all.phpt (revision 74859783)
1--TEST--
2Phar: test that creation of tar-based phar generates valid tar with all bells/whistles
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar.php';
11$pname = 'phar://' . $fname;
12$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.phar.tar.php';
13$pname2 = 'phar://' . $fname2;
14
15$phar = new Phar($fname);
16
17$phar->setMetadata('hi there');
18$phar['a'] = 'hi';
19$phar['a']->setMetadata('a meta');
20$phar['b'] = 'hi2';
21$phar['c'] = 'hi3';
22$phar['b']->chmod(0444);
23$phar->setStub("<?php ok __HALT_COMPILER();");
24$phar->setAlias("hime");
25unset($phar);
26copy($fname, $fname2);
27Phar::unlinkArchive($fname);
28var_dump(file_exists($fname), file_exists($pname . '/a'));
29
30$phar = new Phar($fname2);
31var_dump($phar['a']->getContent(), $phar['b']->getContent(), $phar['c']->getContent());
32var_dump((string) decoct(fileperms($pname2 . '/b')));
33var_dump($phar->getStub());
34var_dump($phar->getAlias());
35var_dump($phar->getMetadata());
36var_dump($phar['a']->getMetadata());
37?>
38--CLEAN--
39<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar.tar.php'); ?>
40--EXPECT--
41bool(false)
42bool(false)
43string(2) "hi"
44string(3) "hi2"
45string(3) "hi3"
46string(6) "100444"
47string(32) "<?php ok __HALT_COMPILER(); ?>
48"
49string(4) "hime"
50string(8) "hi there"
51string(6) "a meta"
52