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 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
13$fname2 = __DIR__ . '/' . 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--CLEAN--
41<?php
42unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.bz2');
43unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '2.phar');
44unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
45unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
46unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.bz2');
47__HALT_COMPILER();
48?>
49--EXPECT--
50bool(false)
51int(6641)
52bool(true)
53string(60) "<?php // tar-based phar archive stub file
54__HALT_COMPILER();"
55bool(true)
56int(8192)
57int(6641)
58bool(true)
59bool(true)
60int(6641)
61