]> granicus.if.org Git - php/commitdiff
Duplicate tests to accommodate parameter parsing fixes in 5_3 core
authorSteph Fox <sfox@php.net>
Mon, 7 Jul 2008 01:09:21 +0000 (01:09 +0000)
committerSteph Fox <sfox@php.net>
Mon, 7 Jul 2008 01:09:21 +0000 (01:09 +0000)
(NB the 5_2 tests will fail currently due to name changes, will fix tomorrow)

26 files changed:
ext/phar/tests/files/notbogus.zip [new file with mode: 0644]
ext/phar/tests/open_for_write_existing_b.phpt
ext/phar/tests/open_for_write_existing_b_5_2.phpt [new file with mode: 0644]
ext/phar/tests/open_for_write_existing_c.phpt
ext/phar/tests/open_for_write_existing_c_5_2.phpt [new file with mode: 0644]
ext/phar/tests/open_for_write_newfile_b.phpt
ext/phar/tests/open_for_write_newfile_b_5_2.phpt [new file with mode: 0644]
ext/phar/tests/open_for_write_newfile_c.phpt
ext/phar/tests/open_for_write_newfile_c_5_2.phpt [new file with mode: 0644]
ext/phar/tests/phar_extract3.phpt [new file with mode: 0644]
ext/phar/tests/tar/open_for_write_existing_b.phpt
ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt [new file with mode: 0644]
ext/phar/tests/tar/open_for_write_existing_c.phpt
ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt [new file with mode: 0644]
ext/phar/tests/tar/open_for_write_newfile_b.phpt
ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt [new file with mode: 0644]
ext/phar/tests/tar/open_for_write_newfile_c.phpt
ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt [new file with mode: 0644]
ext/phar/tests/zip/open_for_write_existing_b.phpt
ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt [new file with mode: 0644]
ext/phar/tests/zip/open_for_write_existing_c.phpt
ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt [new file with mode: 0644]
ext/phar/tests/zip/open_for_write_newfile_b.phpt
ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt [new file with mode: 0644]
ext/phar/tests/zip/open_for_write_newfile_c.phpt
ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt [new file with mode: 0644]

diff --git a/ext/phar/tests/files/notbogus.zip b/ext/phar/tests/files/notbogus.zip
new file mode 100644 (file)
index 0000000..19ea96f
Binary files /dev/null and b/ext/phar/tests/files/notbogus.zip differ
index 6c3cd3e986828fbb6b714700fb50e229bdd0883f..f0474372ae4f5ae09e201be02ead9069bb6ebee2 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (existing file)
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=1
 phar.require_hash=0
@@ -35,8 +38,8 @@ include $pname . '/b/c.php';
 
 Warning: fopen(phar://%sopen_for_write_existing_b.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
 This is b/c
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_b_5_2.phpt b/ext/phar/tests/open_for_write_existing_b_5_2.phpt
new file mode 100644 (file)
index 0000000..0c694be
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$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"; ?>';
+include 'files/phar_test.inc';
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+  echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+This is b/c
+===DONE===
\ No newline at end of file
index 9bbaaae92a003aaf5b54947e1670be3552dd2416..3f1d76bacdb031e4077a9a3116fdf23bf8c09cba 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (existing file)
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=1
 phar.require_hash=0
@@ -29,8 +32,8 @@ include $pname . '/b/c.php';
 
 Warning: fopen(phar://%sopen_for_write_existing_c.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
 This is b/c
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_c_5_2.phpt b/ext/phar/tests/open_for_write_existing_c_5_2.phpt
new file mode 100644 (file)
index 0000000..de5855e
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+This is b/c
+===DONE===
\ No newline at end of file
index 1c136ff1d52da41dc6dca7744238aa929a0ffe0a..9cfeeccec50baf24b0cba44db4c3caa607d53955 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (new file)
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=1
 phar.require_hash=0
@@ -37,9 +40,9 @@ include $pname . '/b/new.php';
 
 Warning: fopen(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line 20
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
 This is b/c
 
 Warning: include(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.php" in %sopen_for_write_newfile_b.php on line 22
diff --git a/ext/phar/tests/open_for_write_newfile_b_5_2.phpt b/ext/phar/tests/open_for_write_newfile_b_5_2.phpt
new file mode 100644 (file)
index 0000000..c0f92ec
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$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"; ?>';
+include 'files/phar_test.inc';
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+  echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.php" in %sopen_for_write_newfile_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+
+===DONE===
index 59b4339eb95dd817b5b1a1d88eccaa6f0a05936b..fc509a5a5c15ad6c7bf75038359f0cb893c593c0 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (new file)
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=1
 phar.require_hash=0
@@ -31,9 +34,9 @@ include $pname . '/b/new.php';
 
 Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 This is b/c
 
 Warning: include(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.php" in %sopen_for_write_newfile_c.php on line %d
diff --git a/ext/phar/tests/open_for_write_newfile_c_5_2.phpt b/ext/phar/tests/open_for_write_newfile_c_5_2.phpt
new file mode 100644 (file)
index 0000000..6602397
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+Phar: fopen a .phar for writing (new file)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=1
+phar.require_hash=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
+$pname = 'phar://' . $fname;
+$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"; ?>';
+include 'files/phar_test.inc';
+
+$fp = fopen($pname . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $pname . '/b/c.php';
+include $pname . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.php" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+
+===DONE===
\ No newline at end of file
diff --git a/ext/phar/tests/phar_extract3.phpt b/ext/phar/tests/phar_extract3.phpt
new file mode 100644 (file)
index 0000000..df85211
--- /dev/null
@@ -0,0 +1,46 @@
+--TEST--
+Phar: Phar::extractTo() - check that phar exists
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+
+$fname   = dirname(__FILE__) . '/files/bogus.zip';
+$fname2  = dirname(__FILE__) . '/files/notbogus.zip';
+$extract = dirname(__FILE__) . '/test';
+
+$phar = new PharData($fname);
+
+try {
+       $phar->extractTo($extract);
+} catch (Exception $e) {
+       echo $e->getMessage(), "\n";
+}
+
+$phar = new PharData($fname2);
+foreach ($phar as $filename) {
+       echo "$filename\n";
+}
+
+try {
+       $phar->extractTo($extract);
+} catch (Exception $e) {
+       echo $e->getMessage(), "\n";
+}
+
+?>
+===DONE===
+--CLEAN--
+<?php
+$dir = dirname(__FILE__) . '/test/';
+@unlink($dir . 'stuff.txt');
+@unlink($dir . 'nonsense.txt');
+@rmdir($dir);
+?>
+--EXPECTF--
+Invalid argument, %sfiles/bogus.zip cannot be found
+phar://%sfiles/notbogus.zip%cnonsense.txt
+phar://%sfiles/notbogus.zip%cstuff.txt
+===DONE===
index 54ec5855fb2649c1d97ffc4103c4ec8ce60c404b..c8bba1e350b293594ea0ab75df21b2f3de0fd956 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (existing file) tar-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -48,9 +51,9 @@ include $alias . '/b/c.php';
 
 Warning: fopen(phar://%sopen_for_write_existing_b.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_b.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_existing_b.php on line %d
 This is b/c
 
 ===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt b/ext/phar/tests/tar/open_for_write_existing_b_5_2.phpt
new file mode 100644 (file)
index 0000000..5b70192
--- /dev/null
@@ -0,0 +1,57 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+       echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_b.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+This is b/c
+
+===DONE===
index 0e5a181e65577a079f2a3042fda59edc1088cf97..92955808859f2b3dd4c5cfc49357b28754732a5b 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (existing file) tar-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -42,9 +45,9 @@ include $alias . '/b/c.php';
 
 Warning: fopen(phar://%sopen_for_write_existing_c.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
 This is b/c
 
 ===DONE===
diff --git a/ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt b/ext/phar/tests/tar/open_for_write_existing_c_5_2.phpt
new file mode 100644 (file)
index 0000000..f56e77b
--- /dev/null
@@ -0,0 +1,51 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+This is b/c
+
+===DONE===
index d3a21b4caf74aafa0c5602ece8a547e0d6395f48..f322ac27ad7fba115d692dc38a87360fb9dbf747 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (new file) tar-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -49,9 +52,9 @@ include $alias . '/b/new.php';
 
 Warning: fopen(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
 This is b/c
 
 Warning: include(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.tar" in %sopen_for_write_newfile_b.php on line %d
diff --git a/ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt b/ext/phar/tests/tar/open_for_write_newfile_b_5_2.phpt
new file mode 100644 (file)
index 0000000..831c2fa
--- /dev/null
@@ -0,0 +1,62 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+       echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.tar" in %sopen_for_write_newfile_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+
+===DONE===
index 231241c8adec33153a3565be452d28068e8271e8..1925162015948cfaa2adf51ea5cbb7ed64ae35b5 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (new file) tar-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -42,9 +45,9 @@ include $alias . '/b/new.php';
 
 Warning: fopen(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 This is b/c
 
 Warning: include(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.tar" in %sopen_for_write_newfile_c.php on line %d
diff --git a/ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt b/ext/phar/tests/tar/open_for_write_newfile_c_5_2.phpt
new file mode 100644 (file)
index 0000000..eb77ea7
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) tar-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.tar" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+
+===DONE===
\ No newline at end of file
index 347a1ce719554af633a940bf3738ead6591bd94f..b3391136501c7c1c5b5f25edac33bc33277ab5f8 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (existing file) zip-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -45,8 +48,8 @@ include $alias . '/b/c.php';
 
 Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_b.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_b.php on line %d
 This is b/c
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt b/ext/phar/tests/zip/open_for_write_existing_b_5_2.phpt
new file mode 100644 (file)
index 0000000..b6842ea
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+  echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
+This is b/c
+===DONE===
\ No newline at end of file
index b66a77b2128922bc1421b1efa7eb75ebb58556cc..d39a7dd818aa2047dc9b8597950afda7d117b5bb 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (existing file) zip-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -39,8 +42,8 @@ include $alias . '/b/c.php';
 
 Warning: fopen(phar://%sopen_for_write_existing_c.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %spen_for_write_existing_c.php on line %d
 This is b/c
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt b/ext/phar/tests/zip/open_for_write_existing_c_5_2.phpt
new file mode 100644 (file)
index 0000000..de89ca0
--- /dev/null
@@ -0,0 +1,47 @@
+--TEST--
+Phar: fopen a .phar for writing (existing file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/c.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+include $alias . '/b/c.php';
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
+This is b/c
+===DONE===
\ No newline at end of file
index 44ad7487fa0fbb6998f11b39e77ae81e90a83a4b..59b00ce6bbf180113485ebe27dd3da52138f5b9c 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (new file) zip-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -48,9 +51,9 @@ include $alias . '/b/new.php';
 
 Warning: fopen(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_b.php on line %d
 This is b/c
 
 Warning: include(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.zip" in %sopen_for_write_newfile_b.php on line %d
diff --git a/ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt b/ext/phar/tests/zip/open_for_write_newfile_b_5_2.phpt
new file mode 100644 (file)
index 0000000..585496c
--- /dev/null
@@ -0,0 +1,61 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+function err_handler($errno, $errstr, $errfile, $errline) {
+  echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+}
+
+set_error_handler("err_handler", E_RECOVERABLE_ERROR);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.zip" in %sopen_for_write_newfile_b.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+
+===DONE===
index b664397a99aef66d50ac918b2a392d8dda7f8414..7d16142e687e33abce745b109e853f96fd409084 100755 (executable)
@@ -1,7 +1,10 @@
 --TEST--
 Phar: fopen a .phar for writing (new file) zip-based
 --SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php
+if (!extension_loaded("phar")) die("skip");
+if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or later");
+?>
 --INI--
 phar.readonly=0
 phar.require_hash=0
@@ -42,9 +45,9 @@ include $alias . '/b/new.php';
 
 Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
 
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+Warning: fclose() expects parameter 1 to be resource, boolean given in %sopen_for_write_newfile_c.php on line %d
 This is b/c
 
 Warning: include(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.zip" in %sopen_for_write_newfile_c.php on line %d
diff --git a/ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt b/ext/phar/tests/zip/open_for_write_newfile_c_5_2.phpt
new file mode 100644 (file)
index 0000000..c79df7c
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+Phar: fopen a .phar for writing (new file) zip-based
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
+--INI--
+phar.readonly=0
+phar.require_hash=0
+--FILE--
+<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?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"; ?>';
+
+foreach ($files as $n => $file) {
+       $phar[$n] = $file;
+}
+$phar->stopBuffering();
+
+ini_set('phar.readonly', 1);
+
+$fp = fopen($alias . '/b/new.php', 'wb');
+fwrite($fp, 'extra');
+fclose($fp);
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
+?>
+
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
+--EXPECTF--
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
+This is b/c
+
+Warning: include(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.zip" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+
+===DONE===
\ No newline at end of file