xref: /PHP-5.4/ext/phar/tests/tar/require_hash.phpt (revision 475cf4d2)
1--TEST--
2Phar: 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--
7phar.readonly=1
8phar.require_hash=0
9--FILE--
10<?php
11ini_set('phar.require_hash', 1);
12include 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
24try {
25	$phar = new Phar($fname);
26	var_dump($phar->getStub());
27} catch (Exception $e) {
28	echo $e->getMessage()."\n";
29}
30ini_set('phar.require_hash', 0);
31try {
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--
49tar-based phar "%star_004.phar.tar" does not have a signature
50bool(false)
51array(2) {
52  ["hash"]=>
53  string(32) "%s"
54  ["hash_type"]=>
55  string(3) "MD5"
56}
57===DONE===
58