]> granicus.if.org Git - php/commitdiff
add new failing test for write support
authorGreg Beaver <cellog@php.net>
Tue, 2 Jan 2007 20:07:54 +0000 (20:07 +0000)
committerGreg Beaver <cellog@php.net>
Tue, 2 Jan 2007 20:07:54 +0000 (20:07 +0000)
ext/phar/tests/open_for_write_existing.phpt [new file with mode: 0644]

diff --git a/ext/phar/tests/open_for_write_existing.phpt b/ext/phar/tests/open_for_write_existing.phpt
new file mode 100644 (file)
index 0000000..769f6e4
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip"; ?>
+--FILE--
+<?php
+$file = "<?php __HALT_COMPILER(); ?>";
+
+$files = array();
+$files['a.php'] = '<?php echo "This is a\n"; ?>';
+$files['b.php'] = '<?php echo "This is b\n"; ?>';
+$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$manifest = '';
+foreach($files as $name => $cont) {
+       $len = strlen($cont);
+       $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
+}
+$alias = '';
+$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
+$file .= pack('V', strlen($manifest)) . $manifest;
+foreach($files as $cont)
+{
+       $file .= $cont;
+}
+
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+
+$fp = fopen('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECT--
+extra
+===DONE===