From: Greg Beaver Date: Wed, 9 Jan 2008 08:48:56 +0000 (+0000) Subject: new tests for bz2-compressed tar or phar-based phars (wow, worked on first try, how... X-Git-Tag: RELEASE_2_0_0a1~969 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7def324a80acaafdff1f8ca78625645cb68268ab;p=php new tests for bz2-compressed tar or phar-based phars (wow, worked on first try, how about that) --- diff --git a/ext/phar/tests/phar_bz2.phpt b/ext/phar/tests/phar_bz2.phpt new file mode 100644 index 0000000000..fd7c664734 --- /dev/null +++ b/ext/phar/tests/phar_bz2.phpt @@ -0,0 +1,52 @@ +--TEST-- +Phar: bzipped phar +--SKIPIF-- + + + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +isPhar()); +var_dump($b->isCompressed() == Phar::BZ2); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(9) "it worked" +string(%d) "phar://%sphar_bz2.phar/tar_004.php" +bool(true) +bool(true) +===DONE=== \ No newline at end of file diff --git a/ext/phar/tests/phar_test.inc b/ext/phar/tests/phar_test.inc index 2c3062c457..3ff5103e33 100755 --- a/ext/phar/tests/phar_test.inc +++ b/ext/phar/tests/phar_test.inc @@ -67,4 +67,10 @@ if (@$gzip) { fclose($fp); } +if (@$bz2) { + $fp = bzopen($fname, 'w'); + fwrite($fp, $file); + fclose($fp); +} + ?> \ No newline at end of file diff --git a/ext/phar/tests/tar/tar_bz2.phpt b/ext/phar/tests/tar/tar_bz2.phpt new file mode 100644 index 0000000000..65f062261f --- /dev/null +++ b/ext/phar/tests/tar/tar_bz2.phpt @@ -0,0 +1,50 @@ +--TEST-- +Phar: tar-based phar, bzipped tar +--SKIPIF-- + + + +--INI-- +phar.readonly=0 +--FILE-- +init(); +$a->addFile('tar_004.php', 'addFile('internal/file/here', "hi there!\n"); +$a->mkDir('internal/dir'); +$a->mkDir('dir'); +$a->addFile('.phar/stub.php', 'close(); + +include $fname; + +$a = new Phar($fname); +$a['test'] = 'hi'; +copy($fname, $fname2); +$b = new Phar($fname2); +var_dump($b->isTar()); +var_dump($b->isCompressed() == Phar::BZ2); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(9) "it worked" +string(%d) "phar://%star_bz2.phar/tar_004.php" +bool(true) +bool(true) +===DONE=== \ No newline at end of file diff --git a/ext/phar/tests/tar/tarmaker.php.inc b/ext/phar/tests/tar/tarmaker.php.inc index 566f3bdcc1..902507881a 100644 --- a/ext/phar/tests/tar/tarmaker.php.inc +++ b/ext/phar/tests/tar/tarmaker.php.inc @@ -131,7 +131,7 @@ class tarmaker $this->tmp = gzopen($this->path, 'wb'); break; case 'bz2' : - $this->tmp = bzopen($this->path, 'wb'); + $this->tmp = bzopen($this->path, 'w'); break; case 'none' : $this->tmp = fopen($this->path, 'wb');