From: Greg Beaver Date: Mon, 22 Jan 2007 00:57:34 +0000 (+0000) Subject: new test for stream context setting of compression X-Git-Tag: RELEASE_1_0_0RC1~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=038de43fd6dfada30c86484f379924a687037d08;p=php new test for stream context setting of compression --- diff --git a/ext/phar/tests/phar_ctx_001.phpt b/ext/phar/tests/phar_ctx_001.phpt new file mode 100644 index 0000000000..07137aa6b8 --- /dev/null +++ b/ext/phar/tests/phar_ctx_001.phpt @@ -0,0 +1,68 @@ +--TEST-- +Phar context +--SKIPIF-- + + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +'; + +$files = array(); +$files['a'] = 'a'; +$files['b'] = 'b'; +$files['c'] = 'c'; + +include 'phar_test.inc'; + +$phar = new Phar($fname); + +var_dump(file_get_contents($pname . '/a')); +var_dump($phar['a']->isCompressed()); +var_dump(file_get_contents($pname . '/b')); +var_dump($phar['b']->isCompressed()); +var_dump(file_get_contents($pname . '/c')); +var_dump($phar['c']->isCompressed()); + +$context = stream_context_create(array('phar'=>array('compress'=>Phar::GZ))); + +file_put_contents($pname . '/a', 'new a', 0); // no compression +file_put_contents($pname . '/b', 'new b', 0, $context); +file_put_contents($pname . '/d', 'new d');//, 0, $context); + +$phar = new Phar($fname); +var_dump(file_get_contents($pname . '/a')); +var_dump($phar['a']->isCompressed()); +var_dump(file_get_contents($pname . '/b')); +var_dump($phar['b']->isCompressed()); +var_dump(file_get_contents($pname . '/c')); +var_dump($phar['c']->isCompressed()); +var_dump(file_get_contents($pname . '/d')); +var_dump($phar['d']->isCompressed()); + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(1) "a" +bool(false) +string(1) "b" +bool(false) +string(1) "c" +bool(false) +string(4) "new a" +bool(false) +string(4) "new b" +bool(true) +string(1) "c" +bool(false) +string(4) "new d" +bool(true) +===DONE===