1--TEST--
2Phar::convertToPhar() bzipped
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (!extension_loaded("bz2")) die("skip"); ?>
6--INI--
7phar.require_hash=0
8phar.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->stopBuffering();
18var_dump($phar->isFileFormat(Phar::TAR));
19var_dump(strlen($phar->getStub()));
20
21$phar = $phar->convertToExecutable(Phar::TAR);
22var_dump($phar->isFileFormat(Phar::TAR));
23var_dump($phar->getStub());
24
25$phar['a'] = 'hi there';
26
27$phar = $phar->convertToExecutable(Phar::PHAR, Phar::BZ2);
28var_dump($phar->isFileFormat(Phar::PHAR));
29var_dump($phar->isCompressed());
30var_dump(strlen($phar->getStub()));
31
32copy($fname . '.bz2', $fname2);
33
34$phar = new Phar($fname2);
35var_dump($phar->isFileFormat(Phar::PHAR));
36var_dump($phar->isCompressed() == Phar::BZ2);
37var_dump(strlen($phar->getStub()));
38
39?>
40===DONE===
41--CLEAN--
42<?php
43unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.bz2');
44unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
45unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
46unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
47unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.bz2');
48__HALT_COMPILER();
49?>
50--EXPECT--
51bool(false)
52int(6641)
53bool(true)
54string(60) "<?php // tar-based phar archive stub file
55__HALT_COMPILER();"
56bool(true)
57int(8192)
58int(6641)
59bool(true)
60bool(true)
61int(6641)
62===DONE===
63