Annotation of embedaddon/php/ext/phar/tests/phar_setsignaturealgo2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Phar::setSupportedSignatures() with hash
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if (!extension_loaded("phar")) die("skip");
        !             6: if (!extension_loaded("hash")) die("skip hash extension required");
        !             7: $arr = Phar::getSupportedSignatures();
        !             8: if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
        !             9: if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
        !            10: ?>
        !            11: --INI--
        !            12: phar.require_hash=0
        !            13: phar.readonly=0
        !            14: --FILE--
        !            15: <?php
        !            16: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
        !            17: $p = new Phar($fname);
        !            18: $p['file1.txt'] = 'hi';
        !            19: var_dump($p->getSignature());
        !            20: $p->setSignatureAlgorithm(Phar::MD5);
        !            21: var_dump($p->getSignature());
        !            22: $p->setSignatureAlgorithm(Phar::SHA1);
        !            23: var_dump($p->getSignature());
        !            24: try {
        !            25: $p->setSignatureAlgorithm(Phar::SHA256);
        !            26: var_dump($p->getSignature());
        !            27: } catch (Exception $e) {
        !            28: echo $e->getMessage();
        !            29: }
        !            30: try {
        !            31: $p->setSignatureAlgorithm(Phar::SHA512);
        !            32: var_dump($p->getSignature());
        !            33: } catch (Exception $e) {
        !            34: echo $e->getMessage();
        !            35: }
        !            36: try {
        !            37: $private = openssl_get_privatekey(file_get_contents(dirname(__FILE__) . '/files/private.pem'));
        !            38: $pkey = '';
        !            39: openssl_pkey_export($private, $pkey);
        !            40: $p->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
        !            41: var_dump($p->getSignature());
        !            42: } catch (Exception $e) {
        !            43: echo $e->getMessage();
        !            44: }
        !            45: ?>
        !            46: ===DONE===
        !            47: --CLEAN--
        !            48: <?php
        !            49: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
        !            50: ?>
        !            51: --EXPECTF--
        !            52: array(2) {
        !            53:   ["hash"]=>
        !            54:   string(%d) "%s"
        !            55:   ["hash_type"]=>
        !            56:   string(5) "SHA-1"
        !            57: }
        !            58: array(2) {
        !            59:   ["hash"]=>
        !            60:   string(%d) "%s"
        !            61:   ["hash_type"]=>
        !            62:   string(3) "MD5"
        !            63: }
        !            64: array(2) {
        !            65:   ["hash"]=>
        !            66:   string(%d) "%s"
        !            67:   ["hash_type"]=>
        !            68:   string(5) "SHA-1"
        !            69: }
        !            70: array(2) {
        !            71:   ["hash"]=>
        !            72:   string(%d) "%s"
        !            73:   ["hash_type"]=>
        !            74:   string(7) "SHA-256"
        !            75: }
        !            76: array(2) {
        !            77:   ["hash"]=>
        !            78:   string(%d) "%s"
        !            79:   ["hash_type"]=>
        !            80:   string(7) "SHA-512"
        !            81: }
        !            82: array(2) {
        !            83:   ["hash"]=>
        !            84:   string(%d) "%s"
        !            85:   ["hash_type"]=>
        !            86:   string(7) "OpenSSL"
        !            87: }
        !            88: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>