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===