]> granicus.if.org Git - php/commitdiff
- Add new test
authorMarcus Boerger <helly@php.net>
Tue, 3 Jan 2006 21:34:11 +0000 (21:34 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 3 Jan 2006 21:34:11 +0000 (21:34 +0000)
ext/phar/tests/019b.phpt [new file with mode: 0755]

diff --git a/ext/phar/tests/019b.phpt b/ext/phar/tests/019b.phpt
new file mode 100755 (executable)
index 0000000..218e519
--- /dev/null
@@ -0,0 +1,66 @@
+--TEST--
+Phar: opendir test, recurse into
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip"; ?>
+--FILE--
+<?php
+function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
+register_shutdown_function('cleanup');
+$file = "<?php
+Phar::mapPhar('hio', true);
+__HALT_COMPILER(); ?>";
+$manifest = '';
+$manifest .= pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 9);
+$manifest .= pack('V', 3) . 'b/a' . pack('VVVV', 1, time(), 0, 9);
+$manifest .= pack('V', 5) . 'b/c/d' . pack('VVVV', 1, time(), 0, 9);
+$manifest .= pack('V', 5) . 'bad/c' . pack('VVVV', 1, time(), 0, 9);
+$file .= pack('VV', strlen($manifest) + 4, 4) .
+        $manifest .
+        pack('VV', crc32('a'), 1) . 'a' .
+        pack('VV', crc32('b'), 1) . 'b';
+        pack('VV', crc32('c'), 1) . 'c';
+        pack('VV', crc32('d'), 1) . 'd';
+file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
+include dirname(__FILE__) . '/008_phar.php';
+
+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('phar://hio', '/');
+
+?>
+--EXPECT--
+string(11) "phar://hio/"
+string(2) "/a"
+bool(false)
+string(2) "/b"
+bool(true)
+string(12) "phar://hio/b"
+string(4) "/b/a"
+bool(false)
+string(4) "/b/c"
+bool(true)
+string(14) "phar://hio/b/c"
+string(6) "/b/c/d"
+bool(false)
+string(4) "/bad"
+bool(true)
+string(14) "phar://hio/bad"
+string(6) "/bad/c"
+bool(false)