From: Dmitry Stogov Date: Thu, 10 Jul 2008 14:27:21 +0000 (+0000) Subject: Added tests that demonstrate serious PHAR errors X-Git-Tag: php-5.3.0alpha1~411 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d82b5d59b4d06fd3e19025db45fbd39e4cb33bd4;p=php Added tests that demonstrate serious PHAR errors They cannot be easly fixed without algorithms modification --- diff --git a/ext/phar/tests/rename_dir.phpt b/ext/phar/tests/rename_dir.phpt new file mode 100644 index 0000000000..308d2e3058 --- /dev/null +++ b/ext/phar/tests/rename_dir.phpt @@ -0,0 +1,32 @@ +--TEST-- +Phar: rename_dir test +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +"; + +$files = array(); +$files['a/x'] = 'a'; +include 'files/phar_test.inc'; +include $fname; + +echo file_get_contents($pname . '/a/x') . "\n"; +rename($pname . '/a', $pname . '/b'); +echo file_get_contents($pname . '/b/x') . "\n"; +echo file_get_contents($pname . '/a/x') . "\n"; +?> +--CLEAN-- + +--EXPECTF-- +a +a + +Warning: file_get_contents(phar://%srename.phar.php/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d \ No newline at end of file diff --git a/ext/phar/tests/rmdir.phpt b/ext/phar/tests/rmdir.phpt new file mode 100644 index 0000000000..f3d07362d6 --- /dev/null +++ b/ext/phar/tests/rmdir.phpt @@ -0,0 +1,30 @@ +--TEST-- +Phar: rmdir test +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +"; + +$files = array(); +$files['a/x'] = 'a'; +include 'files/phar_test.inc'; +include $fname; + +echo file_get_contents($pname . '/a/x') . "\n"; +rmdir($pname . '/a'); +echo file_get_contents($pname . '/a/x') . "\n"; +?> +--CLEAN-- + +--EXPECTF-- +a + +Warning: file_get_contents(phar://%srename.phar.php/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d \ No newline at end of file diff --git a/ext/phar/tests/tar/rename_dir.phpt b/ext/phar/tests/tar/rename_dir.phpt new file mode 100644 index 0000000000..4f94ef43b4 --- /dev/null +++ b/ext/phar/tests/tar/rename_dir.phpt @@ -0,0 +1,42 @@ +--TEST-- +Phar: rename_dir test tar-based +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +init(); +$tar->addFile('.phar/stub.php', ""); + +$files = array(); +$files['a/x'] = 'a'; + +foreach ($files as $n => $file) { + $tar->addFile($n, $file); +} + +$tar->close(); + +include $fname; + +echo file_get_contents($alias . '/a/x') . "\n"; +rename($alias . '/a', $alias . '/b'); +echo file_get_contents($alias . '/b/x') . "\n"; +echo file_get_contents($alias . '/a/x') . "\n"; +?> +--CLEAN-- + +--EXPECTF-- +a +a + +Warning: file_get_contents(phar://%srename.phar.tar/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d diff --git a/ext/phar/tests/tar/rmdir.phpt b/ext/phar/tests/tar/rmdir.phpt new file mode 100644 index 0000000000..972dea8c32 --- /dev/null +++ b/ext/phar/tests/tar/rmdir.phpt @@ -0,0 +1,40 @@ +--TEST-- +Phar: rmdir test tar-based +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +init(); +$tar->addFile('.phar/stub.php', ""); + +$files = array(); +$files['a/x'] = 'a'; + +foreach ($files as $n => $file) { + $tar->addFile($n, $file); +} + +$tar->close(); + +include $fname; + +echo file_get_contents($alias . '/a/x') . "\n"; +rmdir($alias . '/a'); +echo file_get_contents($alias . '/a/x') . "\n"; +?> +--CLEAN-- + +--EXPECTF-- +a + +Warning: file_get_contents(phar://%srename.phar.tar/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d diff --git a/ext/phar/tests/zip/rename_dir.phpt b/ext/phar/tests/zip/rename_dir.phpt new file mode 100644 index 0000000000..d88eb9b0ef --- /dev/null +++ b/ext/phar/tests/zip/rename_dir.phpt @@ -0,0 +1,34 @@ +--TEST-- +Phar: rename_dir test zip-based +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +setStub(""); +$phar['a/x'] = 'a'; +$phar->stopBuffering(); + +include $fname; + +echo file_get_contents($alias . '/a/x') . "\n"; +rename($alias . '/a', $alias . '/b'); +echo file_get_contents($alias . '/b/x') . "\n"; +echo file_get_contents($alias . '/a/x') . "\n"; +?> +--CLEAN-- + +--EXPECTF-- +a +a + +Warning: file_get_contents(phar://%srename.phar.zip/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.zip" in %srename.php on line %d \ No newline at end of file diff --git a/ext/phar/tests/zip/rmdir.phpt b/ext/phar/tests/zip/rmdir.phpt new file mode 100644 index 0000000000..c0c2cbffe5 --- /dev/null +++ b/ext/phar/tests/zip/rmdir.phpt @@ -0,0 +1,32 @@ +--TEST-- +Phar: rmdir test zip-based +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--FILE-- +setStub(""); +$phar['a/x'] = 'a'; +$phar->stopBuffering(); + +include $fname; + +echo file_get_contents($alias . '/a/x') . "\n"; +rmdir($alias . '/a'); +echo file_get_contents($alias . '/a/x') . "\n"; +?> +--CLEAN-- + +--EXPECTF-- +a + +Warning: file_get_contents(phar://%srename.phar.zip/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.zip" in %srename.php on line %d \ No newline at end of file