Annotation of embedaddon/php/ext/phar/tests/tar/require_hash.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar: tar-based phar, require_hash=1, no signature
3: --SKIPIF--
4: <?php if (!extension_loaded('phar')) die('skip'); ?>
5: <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6: --INI--
7: phar.readonly=1
8: phar.require_hash=0
9: --FILE--
10: <?php
11: ini_set('phar.require_hash', 1);
12: include dirname(__FILE__) . '/files/tarmaker.php.inc';
13: $fname = dirname(__FILE__) . '/tar_004.phar.tar';
14: $alias = 'phar://' . $fname;
15: $fname2 = dirname(__FILE__) . '/tar_004.tar';
16:
17: $tar = new tarmaker($fname, 'none');
18: $tar->init();
19: $tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
20: $tar->addFile('internal/file/here', "hi there!\n");
21: $tar->addFile('.phar/stub.php', "__HALT_COMPILER();");
22: $tar->close();
23:
24: try {
25: $phar = new Phar($fname);
26: var_dump($phar->getStub());
27: } catch (Exception $e) {
28: echo $e->getMessage()."\n";
29: }
30: ini_set('phar.require_hash', 0);
31: try {
32: $phar = new PharData($fname2);
33: $phar['file'] = 'hi';
34: var_dump($phar->getSignature());
35: $phar->setSignatureAlgorithm(Phar::MD5);
36: var_dump($phar->getSignature());
37: } catch (Exception $e) {
38: echo $e->getMessage()."\n";
39: }
40:
41: ?>
42: ===DONE===
43: --CLEAN--
44: <?php
45: @unlink(dirname(__FILE__) . '/tar_004.phar.tar');
46: @unlink(dirname(__FILE__) . '/tar_004.tar');
47: ?>
48: --EXPECTF--
49: tar-based phar "%star_004.phar.tar" does not have a signature
50: bool(false)
51: array(2) {
52: ["hash"]=>
53: string(32) "%s"
54: ["hash_type"]=>
55: string(3) "MD5"
56: }
57: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>