diff options
Diffstat (limited to 'ext/phar/tests/zip/phar_setalias.phpt')
-rw-r--r-- | ext/phar/tests/zip/phar_setalias.phpt | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ext/phar/tests/zip/phar_setalias.phpt b/ext/phar/tests/zip/phar_setalias.phpt new file mode 100644 index 0000000..1a39633 --- /dev/null +++ b/ext/phar/tests/zip/phar_setalias.phpt @@ -0,0 +1,62 @@ +--TEST-- +Phar::setAlias() zip-based +--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.require_hash=0 +phar.readonly=0 +--FILE-- +<?php + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.zip'; +$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '3.phar.zip'; + +$phar = new Phar($fname); +$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>'); +$phar->setAlias('hio'); + +$files = array(); + +$files['a'] = 'a'; +$files['b'] = 'b'; +$files['c'] = 'c'; + +foreach ($files as $n => $file) { + $phar[$n] = $file; +} +$phar->stopBuffering(); + +echo $phar->getAlias() . "\n"; +$phar->setAlias('test'); +echo $phar->getAlias() . "\n"; + +// test compression + +$phar->compressFiles(Phar::GZ); +copy($fname, $fname2); +$phar->setAlias('unused'); +$p2 = new Phar($fname2); +echo $p2->getAlias(), "\n"; +$p2->compressFiles(Phar::BZ2); +copy($fname2, $fname3); +$p2->setAlias('unused2'); +$p3 = new Phar($fname3); +echo $p3->getAlias(), "\n"; +?> +===DONE=== +--CLEAN-- +<?php +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.zip'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '3.phar.zip'); +__HALT_COMPILER(); +?> +--EXPECT-- +hio +test +test +test +===DONE=== |