diff options
author | Marcus Boerger <helly@php.net> | 2007-01-21 16:58:23 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2007-01-21 16:58:23 +0000 |
commit | fc80ed5913a85268418d17d5acb77fcac2f4a9ec (patch) | |
tree | 3c666e3a9ae9ebe7e8e78a61864dd9492e7833f2 /ext/phar | |
parent | a02afe32c10dea0cf4c48a2171730cba6cf971d0 (diff) | |
download | php-git-fc80ed5913a85268418d17d5acb77fcac2f4a9ec.tar.gz |
- Update tests
Diffstat (limited to 'ext/phar')
-rw-r--r-- | ext/phar/tests/011.phpt | 20 | ||||
-rw-r--r-- | ext/phar/tests/013.phpt | 25 | ||||
-rw-r--r-- | ext/phar/tests/014.phpt | 27 | ||||
-rw-r--r-- | ext/phar/tests/015.phpt | 31 | ||||
-rwxr-xr-x | ext/phar/tests/015b.phpt | 28 | ||||
-rw-r--r-- | ext/phar/tests/016.phpt | 49 | ||||
-rwxr-xr-x | ext/phar/tests/016b.phpt | 31 | ||||
-rw-r--r-- | ext/phar/tests/017.phpt | 21 | ||||
-rw-r--r-- | ext/phar/tests/018.phpt | 3 | ||||
-rw-r--r-- | ext/phar/tests/metadata_read.phpt | 1 | ||||
-rwxr-xr-x | ext/phar/tests/phar_test.inc | 34 |
11 files changed, 95 insertions, 175 deletions
diff --git a/ext/phar/tests/011.phpt b/ext/phar/tests/011.phpt index 009d51d4e7..3b0cde1d19 100644 --- a/ext/phar/tests/011.phpt +++ b/ext/phar/tests/011.phpt @@ -6,6 +6,8 @@ Phar::mapPhar filesize too small in manifest phar.require_hash=0 --FILE-- <?php +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; $file = "<?php Phar::mapPhar('hio'); __HALT_COMPILER(); ?>"; @@ -13,22 +15,10 @@ __HALT_COMPILER(); ?>"; // compressed file length does not match incompressed lentgh for an uncompressed file $files = array(); -$files['a'] = 'a'; -$manifest = ''; -foreach($files as $name => $cont) { - $len = strlen($cont); - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', $len, time(), $len+1, crc32($cont), 0x00000000, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= $cont; -} +$files['a'] = array('cont'=>'a','ulen'=>1,'clen'=>2);; +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +include $fname; echo file_get_contents('phar://hio/a'); ?> --CLEAN-- diff --git a/ext/phar/tests/013.phpt b/ext/phar/tests/013.phpt index 808d37462a..2d00a93f30 100644 --- a/ext/phar/tests/013.phpt +++ b/ext/phar/tests/013.phpt @@ -8,31 +8,16 @@ phar.require_hash=0 <?php $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; $pname = 'phar://' . $fname; -$file = "<?php -Phar::mapPhar('hio'); -__HALT_COMPILER(); ?>"; +$file = "<?php __HALT_COMPILER(); ?>"; // filesize should be 1, and is 2 $files = array(); -$files['a'] = 'a'; -$manifest = ''; -foreach($files as $name => $cont) { - $len = strlen($cont)+1; - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', $len, time(), $len, crc32($cont), 0x00000000, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= $cont; -} +$files['a'] = array('cont'=>'a', 'ulen'=>2, 'clen'=>2); +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; -echo file_get_contents('phar://hio/a'); +echo file_get_contents($pname.'/a'); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECTF-- -Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d +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 diff --git a/ext/phar/tests/014.phpt b/ext/phar/tests/014.phpt index 2117eaaff9..70a5b53c35 100644 --- a/ext/phar/tests/014.phpt +++ b/ext/phar/tests/014.phpt @@ -6,31 +6,18 @@ Phar::mapPhar filesize mismatch phar.require_hash=0 --FILE-- <?php -$file = "<?php -Phar::mapPhar('hio'); -__HALT_COMPILER(); ?>"; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; +$file = "<?php __HALT_COMPILER(); ?>"; // wrong crc32 $files = array(); -$files['a'] = 'a'; -$manifest = ''; -foreach($files as $name => $cont) { - $len = strlen($cont); - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', $len, time(), $len, crc32($cont.'X'), 0x00000000, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= $cont; -} +$files['a'] = array('cont'=>'a', 'crc32'=>crc32('aX')); +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; -echo file_get_contents('phar://hio/a'); +echo file_get_contents($pname.'/a'); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECTF-- -Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line %d
\ No newline at end of file +Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line %d diff --git a/ext/phar/tests/015.phpt b/ext/phar/tests/015.phpt index 4d5477c557..b7c4241433 100644 --- a/ext/phar/tests/015.phpt +++ b/ext/phar/tests/015.phpt @@ -1,36 +1,23 @@ --TEST-- Phar::mapPhar valid file (gzipped) --SKIPIF-- -<?php if (!extension_loaded("phar")) print "skip"; -if (!extension_loaded("zlib")) print "skip zlib not present"; ?> +<?php if (!extension_loaded("phar")) print "skip"; ?> +<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?> --INI-- phar.require_hash=0 --FILE-- <?php -$file = "<?php -Phar::mapPhar('hio'); -__HALT_COMPILER(); ?>"; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; +$file = "<?php __HALT_COMPILER(); ?>"; $files = array(); -$files['a'] = 'a'; -$manifest = ''; -foreach($files as $name => $cont) { - $len = strlen($cont); - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', $len, time(), 3, crc32($cont), 0x00001000, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00001000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= chr(75) . chr(4) . chr(0); // 'a' gzdeflated -} +$files['a'] = array('cont'=>'a','comp'=>chr(75) . chr(4) . chr(0) /* 'a' gzdeflated */, 'flags'=>0x00001000); +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; -echo file_get_contents('phar://hio/a'); +echo file_get_contents($pname .'/a'); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECT-- -a
\ No newline at end of file +a diff --git a/ext/phar/tests/015b.phpt b/ext/phar/tests/015b.phpt index 1909da6a82..973c5d28c8 100755 --- a/ext/phar/tests/015b.phpt +++ b/ext/phar/tests/015b.phpt @@ -1,33 +1,21 @@ --TEST-- Phar::mapPhar valid file (bzip2) --SKIPIF-- -<?php if (!extension_loaded("phar")) print "skip"; -if (!extension_loaded("bz2")) print "skip bz2 not present"; ?> +<?php if (!extension_loaded("phar")) print "skip";?> +<?php if (!extension_loaded("bz2")) print "skip bz2 not present"; ?> --INI-- phar.require_hash=0 --FILE-- <?php -$file = "<?php -Phar::mapPhar('hio'); -__HALT_COMPILER(); ?>"; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; +$file = "<?php __HALT_COMPILER(); ?>"; $files = array(); -$files['a'] = array('Hello World', pack('H*', '425a6839314159265359d872012f00000157800010400000400080060490002000220686d420c988c769e8281f8bb9229c28486c39009780')); -$manifest = ''; -foreach($files as $name => $cont) { - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', strlen($cont[0]), time(), strlen($cont[1]), crc32($cont[0]), 0x00002000, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00002000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= $cont[1]; -} +$files['a'] = array('cont'=>'Hello World', 'comp'=>pack('H*', '425a6839314159265359d872012f00000157800010400000400080060490002000220686d420c988c769e8281f8bb9229c28486c39009780'),'flags'=>0x00002000); +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; -var_dump(file_get_contents('phar://hio/a')); +var_dump(file_get_contents($pname . '/a')); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> diff --git a/ext/phar/tests/016.phpt b/ext/phar/tests/016.phpt index 929e21a1f3..1bb9e1e8c0 100644 --- a/ext/phar/tests/016.phpt +++ b/ext/phar/tests/016.phpt @@ -1,53 +1,38 @@ --TEST-- Phar::mapPhar invalid file (gzipped file length is too short) --SKIPIF-- -<?php if (!extension_loaded("phar")) print "skip"; -if (!extension_loaded("zlib")) print "skip zlib not present"; ?> +<?php if (!extension_loaded("phar")) print "skip";?> +<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?> --INI-- phar.require_hash=0 --FILE-- <?php -$file = "<?php -Phar::mapPhar('hio'); -__HALT_COMPILER(); ?>"; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; +$file = "<?php __HALT_COMPILER(); ?>"; // file length is too short $files = array(); -$files['a'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x00001000); -$files['b'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x00001000); -$files['c'] = array('*', '*', 0x00000000); -$files['d'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x00001000); -$manifest = ''; -foreach($files as $name => $cont) { - $ulen = strlen($cont[0]); - $clen = strlen($cont[1]); - $manifest .= pack('V', strlen($name)) . $name - . pack('VVVVVV', $ulen, time(), $clen, crc32($cont[0]), $cont[2], 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00001000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= $cont[1]; -} +$files['a'] = array('cont'=>'a','comp'=>chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */,'flags'=>0x00001000); +$files['b'] = $files['a']; +$files['c'] = array('cont'=>'*'); +$files['d'] = $files['a']; +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; -var_dump(file_get_contents('phar://hio/a')); -var_dump(file_get_contents('phar://hio/b')); -var_dump(file_get_contents('phar://hio/c')); -var_dump(file_get_contents('phar://hio/d')); +var_dump(file_get_contents($pname . '/a')); +var_dump(file_get_contents($pname . '/b')); +var_dump(file_get_contents($pname . '/c')); +var_dump(file_get_contents($pname . '/d')); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECTF-- -Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d +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 bool(false) -Warning: file_get_contents(phar://hio/b): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "b") in %s on line %d +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 bool(false) string(1) "*" -Warning: file_get_contents(phar://hio/d): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "d") in %s on line %d +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 bool(false) diff --git a/ext/phar/tests/016b.phpt b/ext/phar/tests/016b.phpt index ae5ec5fded..027657f281 100755 --- a/ext/phar/tests/016b.phpt +++ b/ext/phar/tests/016b.phpt @@ -1,37 +1,24 @@ --TEST-- Phar::mapPhar invalid file (gzipped file length is too short) --SKIPIF-- -<?php if (!extension_loaded("phar")) print "skip"; -if (!extension_loaded("zlib")) print "skip zlib not present"; ?> +<?php if (!extension_loaded("phar")) print "skip";?> +<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?> --INI-- phar.require_hash=0 --FILE-- <?php -$file = "<?php -Phar::mapPhar('hio'); -__HALT_COMPILER(); ?>"; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; +$file = "<?php __HALT_COMPILER(); ?>"; // file length is too short $files = array(); -$files['a'] = 'a'; -$manifest = ''; -foreach($files as $name => $cont) { - $len = strlen($cont); - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', $len, time(), 1, crc32($cont), 0x00001000, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00001000, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= chr(0) . chr(4) . chr(0); // 'a' gzdeflated -} +$files['a'] = array('cont'=>'a','flags'=>0x00001000); +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; -echo file_get_contents('phar://hio/a'); +echo file_get_contents($pname . '/a'); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECTF-- -Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
\ No newline at end of file +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 diff --git a/ext/phar/tests/017.phpt b/ext/phar/tests/017.phpt index b3332bb6dc..9be69708c4 100644 --- a/ext/phar/tests/017.phpt +++ b/ext/phar/tests/017.phpt @@ -6,31 +6,20 @@ Phar: opendir test - no dir specified at all phar.require_hash=0 --FILE-- <?php +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://' . $fname; $file = "<?php Phar::mapPhar('hio'); __HALT_COMPILER(); ?>"; -// file length is too short $files = array(); $files['a'] = 'abc'; -$manifest = ''; -foreach($files as $name => $cont) { - $len = strlen($cont); - $manifest .= pack('V', strlen($name)) . $name . pack('VVVVVV', $len, time(), $len, crc32($cont), 0x00000001, 0); -} -$alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00000001, strlen($alias)) . $alias . $manifest; -$file .= pack('V', strlen($manifest)) . $manifest; -foreach($files as $cont) -{ - $file .= $cont; -} +include 'phar_test.inc'; -file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +include $fname; $dir = opendir('phar://hio'); ?> --CLEAN-- <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> --EXPECTF-- -Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory in %s on line %d
\ No newline at end of file +Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory in %s on line %d diff --git a/ext/phar/tests/018.phpt b/ext/phar/tests/018.phpt index e30b429171..84b8e088b7 100644 --- a/ext/phar/tests/018.phpt +++ b/ext/phar/tests/018.phpt @@ -16,7 +16,8 @@ $files = array(); $files['a'] = 'a'; $files['b/a'] = 'b'; include 'phar_test.inc'; -include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; + +include $fname; $dir = opendir('phar://hio/'); while (false !== ($a = readdir($dir))) { var_dump($a); diff --git a/ext/phar/tests/metadata_read.phpt b/ext/phar/tests/metadata_read.phpt index c9dbc7eb21..195ec28c95 100644 --- a/ext/phar/tests/metadata_read.phpt +++ b/ext/phar/tests/metadata_read.phpt @@ -13,7 +13,6 @@ $file = "<?php __HALT_COMPILER(); ?>"; $files = array(); $files['c'] = array('cont' => '*', 'meta' => array(1, 'hi there')); - include 'phar_test.inc'; var_dump(file_get_contents($pname.'/c')); diff --git a/ext/phar/tests/phar_test.inc b/ext/phar/tests/phar_test.inc index 13b9c8b5a5..82987cb19d 100755 --- a/ext/phar/tests/phar_test.inc +++ b/ext/phar/tests/phar_test.inc @@ -1,15 +1,25 @@ <?php $manifest = ''; +$glags = 0; foreach($files as $name => $cont) { + global $gflags, $files; + + $comp = NULL; + $crc32= NULL; + $clen = NULL; + $ulen = NULL; $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006); + $flags= 0; $perm = 0x000001B6; $meta = array(); + + // overwrite if array if (is_array($cont)) { - foreach(array('time','perm','meta','cont') as $what) + foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what) { if (isset($cont[$what])) { @@ -17,22 +27,34 @@ foreach($files as $name => $cont) } } } - $ulen = strlen($cont); - $clen = $ulen; + + // create if not yet done + if (empty($comp)) $comp = $cont; + if (empty($ulen)) $ulen = strlen($cont); + if (empty($clen)) $clen = strlen($comp); + if (empty($crc32))$crc32= crc32($cont); + + // write manifest entry $manifest .= pack('V', strlen($name)) . $name; - $manifest .= pack('VVVVV', $ulen, $time, $clen, crc32($cont), $perm); + $manifest .= pack('VVVVV', $ulen, $time, $clen, $crc32, $flags|$perm); foreach($meta as $type => $data) { $manifest .= pack('Vv', $type, strlen($data)) . $data; } $manifest .= pack('V', 0); + + // globals + $gflags |= $flags; + $files[$name] = $comp; } + $alias = 'hio'; -$manifest = pack('VnVV', count($files), 0x0900, 0x00000000, strlen($alias)) . $alias . $manifest; +$manifest = pack('VnVV', count($files), 0x0900, $glags, strlen($alias)) . $alias . $manifest; $file .= pack('V', strlen($manifest)) . $manifest; + foreach($files as $cont) { - $file .= is_array($cont) ? $cont['cont'] : $cont; + $file .= $cont; } file_put_contents($fname, $file); |