From e267d2c2d04153946e1b79b6baace51d734bee94 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Fri, 6 Jan 2006 16:27:15 +0000 Subject: [PATCH] - And another test --- ext/phar/tests/026.phpt | 46 +++++++++++++++++++++++++ ext/phar/tests/027.phpt | 74 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100755 ext/phar/tests/026.phpt create mode 100755 ext/phar/tests/027.phpt diff --git a/ext/phar/tests/026.phpt b/ext/phar/tests/026.phpt new file mode 100755 index 0000000000..96e20af908 --- /dev/null +++ b/ext/phar/tests/026.phpt @@ -0,0 +1,46 @@ +--TEST-- +Phar: phar:// require from within +--INI-- +magic_quotes_runtime=0 +--SKIPIF-- + +--FILE-- +"; +$a = ''; +$b = ''; +$c = ''; +$d = ''; +$e = ''; + +$manifest = ''; +$manifest .= pack('V', 5) . 'a.php' . pack('VVVV', strlen($a), time(), 0, strlen($a) + 8); +$manifest .= pack('V', 5) . 'b.php' . pack('VVVV', strlen($b), time(), strlen($a) + 8, strlen($b) + 8); +$manifest .= pack('V', 7) . 'b/c.php' . pack('VVVV', strlen($c), time(), strlen($a.$b) + 16, strlen($c) + 8); +$manifest .= pack('V', 7) . 'b/d.php' . pack('VVVV', strlen($d), time(), strlen($a.$b.$c) + 24, strlen($d) + 8); +$manifest .= pack('V', 5) . 'e.php' . pack('VVVV', strlen($e), time(), strlen($a.$b.$c.$d) + 32, strlen($e) + 8); +$file .= pack('VV', strlen($manifest) + 4, 5) . + $manifest . + pack('VV', crc32($a), strlen($a)) . $a . + pack('VV', crc32($b), strlen($b)) . $b . + pack('VV', crc32($c), strlen($c)) . $c . + pack('VV', crc32($d), strlen($d)) . $d . + pack('VV', crc32($e), strlen($e)) . $e; + +file_put_contents($fname, $file); + +require $pname . '/a.php'; + +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +This is a +This is b +This is b/c +This is b/d +This is e +===DONE=== diff --git a/ext/phar/tests/027.phpt b/ext/phar/tests/027.phpt new file mode 100755 index 0000000000..7ac842c03d --- /dev/null +++ b/ext/phar/tests/027.phpt @@ -0,0 +1,74 @@ +--TEST-- +Phar: phar:// opendir +--INI-- +magic_quotes_runtime=0 +--SKIPIF-- + +--FILE-- +"; +$a = ''; +$b = ''; +$c = ''; +$d = ''; +$e = ''; + +$manifest = ''; +$manifest .= pack('V', 5) . 'a.php' . pack('VVVV', strlen($a), time(), 0, strlen($a) + 8); +$manifest .= pack('V', 5) . 'b.php' . pack('VVVV', strlen($b), time(), strlen($a) + 8, strlen($b) + 8); +$manifest .= pack('V', 7) . 'b/c.php' . pack('VVVV', strlen($c), time(), strlen($a.$b) + 16, strlen($c) + 8); +$manifest .= pack('V', 7) . 'b/d.php' . pack('VVVV', strlen($d), time(), strlen($a.$b.$c) + 24, strlen($d) + 8); +$manifest .= pack('V', 5) . 'e.php' . pack('VVVV', strlen($e), time(), strlen($a.$b.$c.$d) + 32, strlen($e) + 8); +$file .= pack('VV', strlen($manifest) + 4, 5) . + $manifest . + pack('VV', crc32($a), strlen($a)) . $a . + pack('VV', crc32($b), strlen($b)) . $b . + pack('VV', crc32($c), strlen($c)) . $c . + pack('VV', crc32($d), strlen($d)) . $d . + pack('VV', crc32($e), strlen($e)) . $e; + +file_put_contents($fname, $file); + +function dump($phar, $base) +{ + var_dump($phar . $base); + $dir = opendir($phar . $base); + if ($base == '/') + { + $base = ''; + } + while (false !== ($entry = readdir($dir))) { + $entry = $base . '/' . $entry; + var_dump($entry); + var_dump(is_dir($phar . $entry)); + if (is_dir($phar . $entry)) + { + dump($phar, $entry); + } + } +} + +dump($pname, '/'); + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(52) "phar://%s027.phar.php/" +string(6) "/a.php" +bool(false) +string(2) "/b" +bool(true) +string(53) "phar://%s027.phar.php/b" +string(8) "/b/c.php" +bool(false) +string(8) "/b/d.php" +bool(false) +string(6) "/b.php" +bool(false) +string(6) "/e.php" +bool(false) +===DONE=== -- 2.40.0