Annotation of embedaddon/php/ext/phar/tests/016.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Phar::mapPhar invalid file (gzipped file length is too short)
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("phar")) die("skip");?>
                      5: <?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
                      6: --INI--
                      7: phar.require_hash=0
                      8: --FILE--
                      9: <?php
                     10: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
                     11: $pname = 'phar://' . $fname;
                     12: $file = b"<?php __HALT_COMPILER(); ?>";
                     13: // file length is too short
                     14: 
                     15: $files = array();
                     16: // "hi" gzdeflated
                     17: $files['a'] = array('cont'=>b'a','comp'=> (binary)pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
                     18: $files['b'] = $files['a'];
                     19: $files['c'] = array('cont'=>b'*');
                     20: $files['d'] = $files['a'];
                     21: include 'files/phar_test.inc';
                     22: 
                     23: var_dump(file_get_contents($pname . '/a'));
                     24: var_dump(file_get_contents($pname . '/b'));
                     25: var_dump(file_get_contents($pname . '/c'));
                     26: var_dump(file_get_contents($pname . '/d'));
                     27: ?>
                     28: --CLEAN--
                     29: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
                     30: --EXPECTF--
                     31: Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
                     32: bool(false)
                     33: 
                     34: Warning: file_get_contents(phar://%s/b): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "b") in %s on line %d
                     35: bool(false)
                     36: string(1) "*"
                     37: 
                     38: Warning: file_get_contents(phar://%s/d): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "d") in %s on line %d
                     39: bool(false)

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