From 0d67c19edb6afa5e78662b6b3dd4361db7f82781 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Mon, 26 Mar 2007 00:01:34 +0000 Subject: [PATCH] add tests for signature algo --- ext/phar/tests/phar_setsignaturealgo1.phpt | 58 ++++++++++++++++++++ ext/phar/tests/phar_setsignaturealgo2.phpt | 64 ++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 ext/phar/tests/phar_setsignaturealgo1.phpt create mode 100644 ext/phar/tests/phar_setsignaturealgo2.phpt diff --git a/ext/phar/tests/phar_setsignaturealgo1.phpt b/ext/phar/tests/phar_setsignaturealgo1.phpt new file mode 100644 index 00000000000..1b206f2668a --- /dev/null +++ b/ext/phar/tests/phar_setsignaturealgo1.phpt @@ -0,0 +1,58 @@ +--TEST-- +Phar::setSignatureAlgorithm() +--SKIPIF-- + + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +getSignature()); +$p->setSignatureAlgorithm(Phar::MD5); +var_dump($p->getSignature()); +$p->setSignatureAlgorithm(Phar::SHA1); +var_dump($p->getSignature()); +try { +$p->setSignatureAlgorithm(Phar::SHA256); +var_dump($p->getSignature()); +} catch (Exception $e) { +echo $e->getMessage(); +} +try { +$p->setSignatureAlgorithm(Phar::SHA512); +var_dump($p->getSignature()); +} catch (Exception $e) { +echo $e->getMessage(); +} +try { +$p->setSignatureAlgorithm(Phar::PGP); +var_dump($p->getSignature()); +} catch (Exception $e) { +echo $e->getMessage(); +} +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(false) +array(1) { + [hash_type]=> + string(3) "MD5" +} +array(1) { + [hash_type]=> + string(5) "SHA-1" +} +string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled" +string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled" +array(1) { + [hash_type]=> + string(5) "SHA-1" +} +===DONE=== diff --git a/ext/phar/tests/phar_setsignaturealgo2.phpt b/ext/phar/tests/phar_setsignaturealgo2.phpt new file mode 100644 index 00000000000..83168430e77 --- /dev/null +++ b/ext/phar/tests/phar_setsignaturealgo2.phpt @@ -0,0 +1,64 @@ +--TEST-- +Phar::setSupportedSignatures() with hash +--SKIPIF-- + + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +getSignature()); +$p->setSignatureAlgorithm(Phar::MD5); +var_dump($p->getSignature()); +$p->setSignatureAlgorithm(Phar::SHA1); +var_dump($p->getSignature()); +try { +$p->setSignatureAlgorithm(Phar::SHA256); +var_dump($p->getSignature()); +} catch (Exception $e) { +echo $e->getMessage(); +} +try { +$p->setSignatureAlgorithm(Phar::SHA512); +var_dump($p->getSignature()); +} catch (Exception $e) { +echo $e->getMessage(); +} +try { +$p->setSignatureAlgorithm(Phar::PGP); +var_dump($p->getSignature()); +} catch (Exception $e) { +echo $e->getMessage(); +} +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(false) +array(1) { + [hash_type]=> + string(3) "MD5" +} +array(1) { + [hash_type]=> + string(5) "SHA-1" +} +array(1) { + [hash_type]=> + string(5) "SHA-256" +} +array(1) { + [hash_type]=> + string(5) "SHA-512" +} +array(1) { + [hash_type]=> + string(5) "SHA-1" +} +===DONE===