File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
phar /
tests /
pharfileinfo_compression.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:00 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
Phar: PharFileInfo compression-related methods
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
--INI--
phar.readonly=0
--FILE--
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$pname = 'phar://' . $fname;
$phar = new Phar($fname);
$phar['a/b'] = 'hi there';
$b = $phar['a/b'];
$b->isCompressed(array());
try {
$b->isCompressed(25);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$b->compress(25);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
$tar = $phar->convertToData(Phar::TAR);
$c = $tar['a/b'];
try {
$c->compress(Phar::GZ);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$phar['a']->compress(Phar::GZ);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 1);
try {
$b->compress(Phar::GZ);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 0);
var_dump($b->compress(Phar::GZ));
var_dump($b->compress(Phar::GZ));
var_dump($b->compress(Phar::BZ2));
var_dump($b->compress(Phar::BZ2));
echo "decompress\n";
ini_set('phar.readonly', 1);
try {
$phar['a/b']->decompress();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 0);
try {
$phar['a']->decompress();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
var_dump($b->decompress());
var_dump($b->decompress());
?>
===DONE===
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar'); ?>
--EXPECTF--
Warning: PharFileInfo::isCompressed() expects parameter 1 to be long, array given in %spharfileinfo_compression.php on line 11
Unknown compression type specified
Unknown compression type specified
Cannot compress with Gzip compression, not possible with tar-based phar archives
Phar entry is a directory, cannot set compression
Phar is readonly, cannot change compression
bool(true)
bool(true)
bool(true)
bool(true)
decompress
Phar is readonly, cannot decompress
Phar entry is a directory, cannot set compression
bool(true)
bool(true)
===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>