Annotation of embedaddon/php/ext/phar/tests/phar_setsignaturealgo1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Phar::setSignatureAlgorithm()
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("phar")) die("skip"); ?>
! 5: <?php if ( extension_loaded("hash")) die("skip extension hash conflicts"); ?>
! 6: <?php if (!defined("Phar::PGP")) die("skip PGP Signature algorithm not available"); ?>
! 7: --INI--
! 8: phar.require_hash=0
! 9: phar.readonly=0
! 10: --FILE--
! 11: <?php
! 12: $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
! 13: $p['file1.txt'] = 'hi';
! 14: var_dump($p->getSignature());
! 15: $p->setSignatureAlgorithm(Phar::MD5);
! 16: var_dump($p->getSignature());
! 17: $p->setSignatureAlgorithm(Phar::SHA1);
! 18: var_dump($p->getSignature());
! 19: try {
! 20: $p->setSignatureAlgorithm(Phar::SHA256);
! 21: var_dump($p->getSignature());
! 22: } catch (Exception $e) {
! 23: echo $e->getMessage();
! 24: }
! 25: try {
! 26: $p->setSignatureAlgorithm(Phar::SHA512);
! 27: var_dump($p->getSignature());
! 28: } catch (Exception $e) {
! 29: echo $e->getMessage();
! 30: }
! 31: try {
! 32: $p->setSignatureAlgorithm(Phar::PGP);
! 33: var_dump($p->getSignature());
! 34: } catch (Exception $e) {
! 35: echo $e->getMessage();
! 36: }
! 37: ?>
! 38: ===DONE===
! 39: --CLEAN--
! 40: <?php
! 41: unlink(dirname(__FILE__) . '/brandnewphar.phar');
! 42: ?>
! 43: --EXPECTF--
! 44: array(2) {
! 45: ["hash"]=>
! 46: string(%d) "%s"
! 47: ["hash_type"]=>
! 48: string(5) "SHA-1"
! 49: }
! 50: array(2) {
! 51: ["hash"]=>
! 52: string(%d) "%s"
! 53: ["hash_type"]=>
! 54: string(3) "MD5"
! 55: }
! 56: array(2) {
! 57: ["hash"]=>
! 58: string(%d) "%s"
! 59: ["hash_type"]=>
! 60: string(5) "SHA-1"
! 61: }
! 62: string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled"
! 63: string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled"
! 64: array(2) {
! 65: ["hash"]=>
! 66: string(%d) "%s"
! 67: ["hash_type"]=>
! 68: string(5) "SHA-1"
! 69: }
! 70: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>