Annotation of embedaddon/php/ext/phar/tests/tar/phar_convert_phar4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar::convertToPhar() with global metadata
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip"); ?>
5: <?php if (!extension_loaded("zlib")) die("skip"); ?>
6: --INI--
7: phar.require_hash=0
8: phar.readonly=0
9: --FILE--
10: <?php
11:
12: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
13: $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
14:
15: $phar = new Phar($fname);
16: $phar['a.txt'] = 'some text';
17: $phar->setMetadata(b'hi');
18: $phar->stopBuffering();
19: var_dump($phar->isFileFormat(Phar::TAR));
20: var_dump(strlen($phar->getStub()));
21: var_dump($phar->getMetadata());
22:
23: $phar = $phar->convertToExecutable(Phar::TAR);
24: var_dump($phar->isFileFormat(Phar::TAR));
25: var_dump($phar->getStub());
26: var_dump($phar->getMetadata());
27:
28: $phar['a'] = 'hi there';
29:
30: $phar = $phar->convertToExecutable(Phar::PHAR, Phar::GZ);
31: var_dump($phar->isFileFormat(Phar::PHAR));
32: var_dump($phar->isCompressed());
33: var_dump(strlen($phar->getStub()));
34: var_dump($phar->getMetadata());
35:
36: copy($fname . '.gz', $fname2);
37:
38: $phar = new Phar($fname2);
39: var_dump($phar->isFileFormat(Phar::PHAR));
40: var_dump($phar->isCompressed() == Phar::GZ);
41: var_dump(strlen($phar->getStub()));
42: var_dump($phar->getMetadata());
43:
44: ?>
45: ===DONE===
46: --CLEAN--
47: <?php
48: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.gz');
49: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
50: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
51: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
52: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz');
53: __HALT_COMPILER();
54: ?>
55: --EXPECT--
56: bool(false)
57: int(6683)
58: string(2) "hi"
59: bool(true)
60: string(60) "<?php // tar-based phar archive stub file
61: __HALT_COMPILER();"
62: string(2) "hi"
63: bool(true)
64: int(4096)
65: int(6683)
66: string(2) "hi"
67: bool(true)
68: bool(true)
69: int(6683)
70: string(2) "hi"
71: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>