summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSteph Fox <sfox@php.net>2008-02-11 20:55:44 +0000
committerSteph Fox <sfox@php.net>2008-02-11 20:55:44 +0000
commitef46f3e3a2a7d267e31be072be3e5843901ea278 (patch)
tree0ed8a5108359c0516ff904f91f47f42231983648 /ext
parent914c94d497ac1bc2433fa431dc0cee881c3ec06c (diff)
downloadphp-git-ef46f3e3a2a7d267e31be072be3e5843901ea278.tar.gz
Funnily enough those frontcontroller tests still pass here! Investigating...
Diffstat (limited to 'ext')
-rw-r--r--ext/phar/tests/zip/033.phpt42
-rw-r--r--ext/phar/tests/zip/033a.phpt42
-rw-r--r--ext/phar/tests/zip/delete.phpt23
-rw-r--r--ext/phar/tests/zip/delete_in_phar.phpt39
-rw-r--r--ext/phar/tests/zip/delete_in_phar_b.phpt35
-rw-r--r--ext/phar/tests/zip/delete_in_phar_confirm.phpt43
-rw-r--r--ext/phar/tests/zip/files/frontcontroller.phar.inc (renamed from ext/phar/tests/zip/frontcontroller.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller.phar.zip (renamed from ext/phar/tests/zip/frontcontroller.phar.zip)bin625 -> 625 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller10.phar.inc (renamed from ext/phar/tests/zip/frontcontroller10.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller10.phar.zip (renamed from ext/phar/tests/zip/frontcontroller10.phar.zip)bin471 -> 471 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller11.phar.inc (renamed from ext/phar/tests/zip/frontcontroller11.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller11.phar.zip (renamed from ext/phar/tests/zip/frontcontroller11.phar.zip)bin461 -> 461 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.inc (renamed from ext/phar/tests/zip/frontcontroller12.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.zip (renamed from ext/phar/tests/zip/frontcontroller12.phar.zip)bin465 -> 465 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller2.phar.inc (renamed from ext/phar/tests/zip/frontcontroller2.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller2.phar.zip (renamed from ext/phar/tests/zip/frontcontroller2.phar.zip)bin531 -> 531 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.inc (renamed from ext/phar/tests/zip/frontcontroller3.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.zip (renamed from ext/phar/tests/zip/frontcontroller3.phar.zip)bin826 -> 826 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.inc (renamed from ext/phar/tests/zip/frontcontroller4.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.zip (renamed from ext/phar/tests/zip/frontcontroller4.phar.zip)bin822 -> 822 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller5.phar.inc (renamed from ext/phar/tests/zip/frontcontroller5.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller5.phar.zip (renamed from ext/phar/tests/zip/frontcontroller5.phar.zip)bin554 -> 554 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller6.phar.inc (renamed from ext/phar/tests/zip/frontcontroller6.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller6.phar.zip (renamed from ext/phar/tests/zip/frontcontroller6.phar.zip)bin559 -> 559 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller7.phar.inc (renamed from ext/phar/tests/zip/frontcontroller7.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller7.phar.zip (renamed from ext/phar/tests/zip/frontcontroller7.phar.zip)bin559 -> 559 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller8.phar.inc (renamed from ext/phar/tests/zip/frontcontroller8.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller8.phar.zip (renamed from ext/phar/tests/zip/frontcontroller8.phar.zip)bin684 -> 684 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller9.phar.inc (renamed from ext/phar/tests/zip/frontcontroller9.phar.inc)0
-rw-r--r--ext/phar/tests/zip/files/frontcontroller9.phar.zip (renamed from ext/phar/tests/zip/frontcontroller9.phar.zip)bin697 -> 697 bytes
-rw-r--r--ext/phar/tests/zip/files/make_invalid_tar.php.inc (renamed from ext/phar/tests/zip/make_invalid_tar.php.inc)0
-rw-r--r--ext/phar/tests/zip/files/zipmaker.php.inc (renamed from ext/phar/tests/zip/tarmaker.php.inc)44
-rw-r--r--ext/phar/tests/zip/open_for_write_existing.phpt24
-rwxr-xr-xext/phar/tests/zip/open_for_write_existing_b.phpt27
-rwxr-xr-xext/phar/tests/zip/open_for_write_existing_c.phpt29
-rw-r--r--ext/phar/tests/zip/open_for_write_newfile.phpt27
-rwxr-xr-xext/phar/tests/zip/open_for_write_newfile_b.phpt34
-rwxr-xr-xext/phar/tests/zip/open_for_write_newfile_c.phpt34
-rw-r--r--ext/phar/tests/zip/phar_setalias.phpt24
-rw-r--r--ext/phar/tests/zip/phar_setalias2.phpt28
-rwxr-xr-xext/phar/tests/zip/phar_stub_error.phpt23
-rw-r--r--ext/phar/tests/zip/refcount1.phpt42
-rw-r--r--ext/phar/tests/zip/rename.phpt33
43 files changed, 292 insertions, 301 deletions
diff --git a/ext/phar/tests/zip/033.phpt b/ext/phar/tests/zip/033.phpt
index 410fd56f60..084afaa944 100644
--- a/ext/phar/tests/zip/033.phpt
+++ b/ext/phar/tests/zip/033.phpt
@@ -7,31 +7,29 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$pname = 'phar://hio';
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>');
-$a->addFile('.phar/alias.txt', 'hio');
-$a->mkDir('test');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar['test/'] = '';
+$phar->stopBuffering();
try {
- $a = new Phar($fname);
- var_dump($a['a.php']->isExecutable());
- $a['a.php']->chmod(0777);
- var_dump($a['a.php']->isExecutable());
- $a['a.php']->chmod(0666);
- var_dump($a['a.php']->isExecutable());
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0777);
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0666);
+ var_dump($phar['a.php']->isExecutable());
echo "test dir\n";
- var_dump($a['test']->isDir());
- var_dump($a['test']->isReadable());
- $a['test']->chmod(0000);
- var_dump($a['test']->isReadable());
- $a['test']->chmod(0666);
- var_dump($a['test']->isReadable());
+ var_dump($phar['test']->isDir());
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0000);
+ var_dump($phar['test']->isReadable());
+ $phar['test']->chmod(0666);
+ var_dump($phar['test']->isReadable());
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
@@ -39,7 +37,7 @@ try {
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
?>
--EXPECT--
bool(false)
diff --git a/ext/phar/tests/zip/033a.phpt b/ext/phar/tests/zip/033a.phpt
index 71e154f480..af4b56a487 100644
--- a/ext/phar/tests/zip/033a.phpt
+++ b/ext/phar/tests/zip/033a.phpt
@@ -7,31 +7,29 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$pname = 'phar://hio';
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>');
-$a->addFile('.phar/alias.txt', 'hio');
-$a->mkDir('test');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar['test/'] = '';
+$phar->stopBuffering();
ini_set('phar.readonly', 1);
try {
- $a = new Phar($fname);
- var_dump($a['a.php']->isExecutable());
- $a['a.php']->chmod(0777);
- var_dump($a['a.php']->isExecutable());
- $a['a.php']->chmod(0666);
- var_dump($a['a.php']->isExecutable());
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0777);
+ var_dump($phar['a.php']->isExecutable());
+ $phar['a.php']->chmod(0666);
+ var_dump($phar['a.php']->isExecutable());
echo "test dir\n";
- var_dump($a['test']->isExecutable());
- $a['test']->chmod(0777);
- var_dump($a['test']->isExecutable());
- $a['test']->chmod(0666);
- var_dump($a['test']->isExecutable());
+ var_dump($phar['test']->isExecutable());
+ $phar['test']->chmod(0777);
+ var_dump($phar['test']->isExecutable());
+ $phar['test']->chmod(0666);
+ var_dump($phar['test']->isExecutable());
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
@@ -39,9 +37,9 @@ try {
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
?>
--EXPECTF--
bool(false)
-Cannot modify permissions for file "a.php" in phar "%sa.1.phar.php", write operations are prohibited
+Cannot modify permissions for file "a.php" in phar "%sa.phar.zip", write operations are prohibited
===DONE===
diff --git a/ext/phar/tests/zip/delete.phpt b/ext/phar/tests/zip/delete.phpt
index 85b4a44d4e..06078b3a39 100644
--- a/ext/phar/tests/zip/delete.phpt
+++ b/ext/phar/tests/zip/delete.phpt
@@ -7,28 +7,25 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
$file = "<?php
Phar::mapPhar('hio');
__HALT_COMPILER(); ?>";
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a', 'a');
-$a->addFile('.phar/stub.php', $file);
-$a->close();
-
$phar = new Phar($fname);
+$phar['a'] = 'a';
+$phar->setStub($file);
+$phar->stopBuffering();
-echo file_get_contents($pname . '/a') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
$phar->delete('a');
-echo file_get_contents($pname . '/a') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
?>
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
a
-Warning: file_get_contents(phar://%sdelete.phar.php/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.php" in %sdelete.php on line %d \ No newline at end of file
+Warning: file_get_contents(phar://%sdelete.phar.zip/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.zip" in %sdelete.php on line %d \ No newline at end of file
diff --git a/ext/phar/tests/zip/delete_in_phar.phpt b/ext/phar/tests/zip/delete_in_phar.phpt
index 43f6874c0c..b7bda7ca4b 100644
--- a/ext/phar/tests/zip/delete_in_phar.phpt
+++ b/ext/phar/tests/zip/delete_in_phar.phpt
@@ -7,33 +7,32 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; ?>');
-$a->addFile('b.php', '<?php echo "This is b\n"; ?>');
-$a->addFile('b/c.php', '<?php echo "This is b/c\n"; ?>');
-$a->addFile('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/b/c.php');
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
?>
===AFTER===
<?php
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
This is a
This is b
@@ -42,9 +41,9 @@ This is b/c
This is a
This is b
-Warning: include(%sdelete_in_phar.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.php" in %sdelete_in_phar.php on line %d
+Warning: include(%sdelete_in_phar.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.zip" in %sdelete_in_phar.php on line %d
-Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
+Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
===DONE===
\ No newline at end of file
diff --git a/ext/phar/tests/zip/delete_in_phar_b.phpt b/ext/phar/tests/zip/delete_in_phar_b.phpt
index cb01890444..7bc3a2bf1a 100644
--- a/ext/phar/tests/zip/delete_in_phar_b.phpt
+++ b/ext/phar/tests/zip/delete_in_phar_b.phpt
@@ -7,34 +7,33 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; ?>');
-$a->addFile('b.php', '<?php echo "This is b\n"; ?>');
-$a->addFile('b/c.php', '<?php echo "This is b/c\n"; ?>');
-$a->addFile('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
ini_set('phar.readonly', 1);
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/b/c.php');
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
?>
===AFTER===
<?php
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
This is a
This is b
diff --git a/ext/phar/tests/zip/delete_in_phar_confirm.phpt b/ext/phar/tests/zip/delete_in_phar_confirm.phpt
index 29743e0132..fdd0b42b5c 100644
--- a/ext/phar/tests/zip/delete_in_phar_confirm.phpt
+++ b/ext/phar/tests/zip/delete_in_phar_confirm.phpt
@@ -7,36 +7,37 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; ?>');
-$a->addFile('b.php', '<?php echo "This is b\n"; ?>');
-$a->addFile('b/c.php', '<?php echo "This is b/c\n"; ?>');
-$a->addFile('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
-$a->close();
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+
$md5 = md5_file($fname);
-unlink($pname . '/b/c.php');
+unlink($alias . '/b/c.php');
clearstatcache();
$md52 = md5_file($fname);
if ($md5 == $md52) echo 'file was not modified';
?>
===AFTER===
<?php
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/a.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
This is a
This is b
@@ -45,8 +46,8 @@ This is b/c
This is a
This is b
-Warning: include(%sdelete_in_phar_confirm.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.php" in %sdelete_in_phar_confirm.php on line %d
+Warning: include(%sdelete_in_phar_confirm.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.zip" in %sdelete_in_phar_confirm.php on line %d
-Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
+Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
===DONE===
diff --git a/ext/phar/tests/zip/frontcontroller.phar.inc b/ext/phar/tests/zip/files/frontcontroller.phar.inc
index 241dceb57b..241dceb57b 100644
--- a/ext/phar/tests/zip/frontcontroller.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller.phar.zip b/ext/phar/tests/zip/files/frontcontroller.phar.zip
index 4ee905dd3a..4ee905dd3a 100644
--- a/ext/phar/tests/zip/frontcontroller.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller10.phar.inc b/ext/phar/tests/zip/files/frontcontroller10.phar.inc
index c973cc15d9..c973cc15d9 100644
--- a/ext/phar/tests/zip/frontcontroller10.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller10.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller10.phar.zip b/ext/phar/tests/zip/files/frontcontroller10.phar.zip
index c37cb381fb..c37cb381fb 100644
--- a/ext/phar/tests/zip/frontcontroller10.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller10.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller11.phar.inc b/ext/phar/tests/zip/files/frontcontroller11.phar.inc
index c24a6f14e4..c24a6f14e4 100644
--- a/ext/phar/tests/zip/frontcontroller11.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller11.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller11.phar.zip b/ext/phar/tests/zip/files/frontcontroller11.phar.zip
index 48e5fc678a..48e5fc678a 100644
--- a/ext/phar/tests/zip/frontcontroller11.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller11.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller12.phar.inc b/ext/phar/tests/zip/files/frontcontroller12.phar.inc
index 77c4a1dd0e..77c4a1dd0e 100644
--- a/ext/phar/tests/zip/frontcontroller12.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller12.phar.zip b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
index c086c4d4a4..c086c4d4a4 100644
--- a/ext/phar/tests/zip/frontcontroller12.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller2.phar.inc b/ext/phar/tests/zip/files/frontcontroller2.phar.inc
index 6cfa052a83..6cfa052a83 100644
--- a/ext/phar/tests/zip/frontcontroller2.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller2.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller2.phar.zip b/ext/phar/tests/zip/files/frontcontroller2.phar.zip
index 7ef43dc000..7ef43dc000 100644
--- a/ext/phar/tests/zip/frontcontroller2.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller2.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller3.phar.inc b/ext/phar/tests/zip/files/frontcontroller3.phar.inc
index ab28f7b3d0..ab28f7b3d0 100644
--- a/ext/phar/tests/zip/frontcontroller3.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller3.phar.zip b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
index 40c1d4994b..40c1d4994b 100644
--- a/ext/phar/tests/zip/frontcontroller3.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller4.phar.inc b/ext/phar/tests/zip/files/frontcontroller4.phar.inc
index d78399142e..d78399142e 100644
--- a/ext/phar/tests/zip/frontcontroller4.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller4.phar.zip b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
index 4dc83408b0..4dc83408b0 100644
--- a/ext/phar/tests/zip/frontcontroller4.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller5.phar.inc b/ext/phar/tests/zip/files/frontcontroller5.phar.inc
index 931fa975e1..931fa975e1 100644
--- a/ext/phar/tests/zip/frontcontroller5.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller5.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller5.phar.zip b/ext/phar/tests/zip/files/frontcontroller5.phar.zip
index 0ab0472101..0ab0472101 100644
--- a/ext/phar/tests/zip/frontcontroller5.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller5.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller6.phar.inc b/ext/phar/tests/zip/files/frontcontroller6.phar.inc
index 3b551f268d..3b551f268d 100644
--- a/ext/phar/tests/zip/frontcontroller6.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller6.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller6.phar.zip b/ext/phar/tests/zip/files/frontcontroller6.phar.zip
index bf98255fe9..bf98255fe9 100644
--- a/ext/phar/tests/zip/frontcontroller6.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller6.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller7.phar.inc b/ext/phar/tests/zip/files/frontcontroller7.phar.inc
index 42c10bc739..42c10bc739 100644
--- a/ext/phar/tests/zip/frontcontroller7.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller7.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller7.phar.zip b/ext/phar/tests/zip/files/frontcontroller7.phar.zip
index 02fc3e27b6..02fc3e27b6 100644
--- a/ext/phar/tests/zip/frontcontroller7.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller7.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller8.phar.inc b/ext/phar/tests/zip/files/frontcontroller8.phar.inc
index e04ac414e9..e04ac414e9 100644
--- a/ext/phar/tests/zip/frontcontroller8.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller8.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller8.phar.zip b/ext/phar/tests/zip/files/frontcontroller8.phar.zip
index 41952ce745..41952ce745 100644
--- a/ext/phar/tests/zip/frontcontroller8.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller8.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/frontcontroller9.phar.inc b/ext/phar/tests/zip/files/frontcontroller9.phar.inc
index 50440451f7..50440451f7 100644
--- a/ext/phar/tests/zip/frontcontroller9.phar.inc
+++ b/ext/phar/tests/zip/files/frontcontroller9.phar.inc
diff --git a/ext/phar/tests/zip/frontcontroller9.phar.zip b/ext/phar/tests/zip/files/frontcontroller9.phar.zip
index d3f4ff8404..d3f4ff8404 100644
--- a/ext/phar/tests/zip/frontcontroller9.phar.zip
+++ b/ext/phar/tests/zip/files/frontcontroller9.phar.zip
Binary files differ
diff --git a/ext/phar/tests/zip/make_invalid_tar.php.inc b/ext/phar/tests/zip/files/make_invalid_tar.php.inc
index cec8ef7793..cec8ef7793 100644
--- a/ext/phar/tests/zip/make_invalid_tar.php.inc
+++ b/ext/phar/tests/zip/files/make_invalid_tar.php.inc
diff --git a/ext/phar/tests/zip/tarmaker.php.inc b/ext/phar/tests/zip/files/zipmaker.php.inc
index da2add772b..aceab0d26b 100644
--- a/ext/phar/tests/zip/tarmaker.php.inc
+++ b/ext/phar/tests/zip/files/zipmaker.php.inc
@@ -1,6 +1,6 @@
<?php
// stolen from PEAR2_Pyrus_Developer_Creator_Zip by Greg Beaver, the original author, for use in unit tests
-class tarmaker
+class zipmaker
{
/**
* Path to archive file
@@ -9,19 +9,17 @@ class tarmaker
*/
protected $archive;
/**
- * @var Phar
+ * @var ZIPArchive
*/
protected $zip;
protected $path;
- /**
- * this is the location we'll create the phar, then we'll copy() it to $path
- * @var string
- */
- protected $tmppath;
function __construct($path)
{
+ if (!class_exists('ZIPArchive')) {
+ throw new Exception(
+ 'Zip extension is not available');
+ }
$this->path = $path;
- $this->tmppath = dirname($path) . "/.tmp.thingy.phar";
}
/**
@@ -31,12 +29,11 @@ class tarmaker
*/
function addFile($path, $fileOrStream)
{
- if ($path == '.phar/stub.php') {
- $this->zip->setStub($fileOrStream);
- } elseif ($path == '.phar/alias.txt') {
- $this->zip->setAlias($fileOrStream);
+ if (is_resource($fileOrStream)) {
+ $this->zip->addFromString($path, stream_get_contents($fileOrStream));
+ } else {
+ $this->zip->addFromString($path, $fileOrStream);
}
- $this->zip[$path] = $fileOrStream;
}
/**
@@ -44,8 +41,12 @@ class tarmaker
*/
function init()
{
- $this->zip = new Phar($this->tmppath);
- $this->zip->convertToZip();
+ $this->zip = new ZipArchive;
+ if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) {
+ throw new Exception(
+ 'Cannot open ZIP archive ' . $this->path
+ );
+ }
}
/**
@@ -56,8 +57,7 @@ class tarmaker
*/
function mkdir($dir)
{
- if ($dir[strlen($dir)-1] != '/') $dir .= '/';
- $this->zip[$dir] = '';
+ $this->zip->addEmptyDir($dir);
}
/**
@@ -65,14 +65,6 @@ class tarmaker
*/
function close()
{
- $this->zip->stopBuffering();
- copy($this->tmppath, $this->path);
- $this->zip->setAlias('not.to.be.used'); // for preventing alias conflict
- $this->zip->stopBuffering();
- }
-
- function __destruct()
- {
- unlink($this->tmppath);
+ $this->zip->close();
}
} \ No newline at end of file
diff --git a/ext/phar/tests/zip/open_for_write_existing.phpt b/ext/phar/tests/zip/open_for_write_existing.phpt
index a68f9897ed..94f85b4e3f 100644
--- a/ext/phar/tests/zip/open_for_write_existing.phpt
+++ b/ext/phar/tests/zip/open_for_write_existing.phpt
@@ -7,31 +7,33 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$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) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
fwrite($fp, 'extra');
fclose($fp);
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECT--
extra
===DONE===
diff --git a/ext/phar/tests/zip/open_for_write_existing_b.phpt b/ext/phar/tests/zip/open_for_write_existing_b.phpt
index 7468ef330d..347a1ce719 100755
--- a/ext/phar/tests/zip/open_for_write_existing_b.phpt
+++ b/ext/phar/tests/zip/open_for_write_existing_b.phpt
@@ -7,21 +7,24 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$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) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
+
ini_set('phar.readonly', 1);
function err_handler($errno, $errstr, $errfile, $errline) {
@@ -30,17 +33,17 @@ function err_handler($errno, $errstr, $errfile, $errline) {
set_error_handler("err_handler", E_RECOVERABLE_ERROR);
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
fwrite($fp, 'extra');
fclose($fp);
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip.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: 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
diff --git a/ext/phar/tests/zip/open_for_write_existing_c.phpt b/ext/phar/tests/zip/open_for_write_existing_c.phpt
index 8586b8694f..b66a77b212 100755
--- a/ext/phar/tests/zip/open_for_write_existing_c.phpt
+++ b/ext/phar/tests/zip/open_for_write_existing_c.phpt
@@ -1,5 +1,5 @@
--TEST--
-Phar: fopen a .phar for writing (existing file) tar-based
+Phar: fopen a .phar for writing (existing file) zip-based
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
@@ -7,34 +7,37 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$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) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
+
ini_set('phar.readonly', 1);
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
fwrite($fp, 'extra');
fclose($fp);
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_existing_c.phar.zip.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: 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
diff --git a/ext/phar/tests/zip/open_for_write_newfile.phpt b/ext/phar/tests/zip/open_for_write_newfile.phpt
index 9d6a3be63d..c3782d4fd3 100644
--- a/ext/phar/tests/zip/open_for_write_newfile.phpt
+++ b/ext/phar/tests/zip/open_for_write_newfile.phpt
@@ -7,32 +7,35 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$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) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
-$fp = fopen($pname . '/b/new.php', 'wb');
+$fp = fopen($alias . '/b/new.php', 'wb');
fwrite($fp, 'extra');
fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECT--
This is b/c
extra
diff --git a/ext/phar/tests/zip/open_for_write_newfile_b.phpt b/ext/phar/tests/zip/open_for_write_newfile_b.phpt
index 05ea2d6bfb..44ad7487fa 100755
--- a/ext/phar/tests/zip/open_for_write_newfile_b.phpt
+++ b/ext/phar/tests/zip/open_for_write_newfile_b.phpt
@@ -7,21 +7,24 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$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) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
+
ini_set('phar.readonly', 1);
function err_handler($errno, $errstr, $errfile, $errline) {
@@ -30,27 +33,28 @@ function err_handler($errno, $errstr, $errfile, $errline) {
set_error_handler("err_handler", E_RECOVERABLE_ERROR);
-$fp = fopen($pname . '/b/new.php', 'wb');
+$fp = fopen($alias . '/b/new.php', 'wb');
fwrite($fp, 'extra');
fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_newfile_b.phar.zip.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: 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.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.zip.php" in %sopen_for_write_newfile_b.php on line %d
+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.php/b/new.php' for inclusion (include_path='%s') 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===
diff --git a/ext/phar/tests/zip/open_for_write_newfile_c.phpt b/ext/phar/tests/zip/open_for_write_newfile_c.phpt
index 499dfc5774..b664397a99 100755
--- a/ext/phar/tests/zip/open_for_write_newfile_c.phpt
+++ b/ext/phar/tests/zip/open_for_write_newfile_c.phpt
@@ -7,44 +7,48 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$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) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
+
ini_set('phar.readonly', 1);
-$fp = fopen($pname . '/b/new.php', 'wb');
+$fp = fopen($alias . '/b/new.php', 'wb');
fwrite($fp, 'extra');
fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip.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: 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.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.zip.php" in %sopen_for_write_newfile_c.php on line %d
+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.php/b/new.php' for inclusion (include_path='%s') 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
diff --git a/ext/phar/tests/zip/phar_setalias.phpt b/ext/phar/tests/zip/phar_setalias.phpt
index ecd969a1dd..1a5d8504b5 100644
--- a/ext/phar/tests/zip/phar_setalias.phpt
+++ b/ext/phar/tests/zip/phar_setalias.phpt
@@ -7,24 +7,24 @@ phar.require_hash=0
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
$files = array();
+
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
-$files['.phar/alias.txt'] = 'hio';
+
foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
-$phar = new Phar($fname);
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
echo $phar->getAlias() . "\n";
@@ -32,8 +32,8 @@ echo $phar->getAlias() . "\n";
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.zip');
__HALT_COMPILER();
?>
--EXPECT--
diff --git a/ext/phar/tests/zip/phar_setalias2.phpt b/ext/phar/tests/zip/phar_setalias2.phpt
index 89057931a5..a17dd8fd2b 100644
--- a/ext/phar/tests/zip/phar_setalias2.phpt
+++ b/ext/phar/tests/zip/phar_setalias2.phpt
@@ -7,27 +7,28 @@ phar.require_hash=0
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
$files = array();
+
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
-$files['.phar/alias.txt'] = 'hio';
+
foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
-$phar = new Phar($fname);
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
echo $phar->getAlias() . "\n";
+
$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
try {
$phar->setAlias('test');
@@ -38,13 +39,12 @@ try {
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-unlink(dirname(__FILE__) . '/notphar.phar');
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.zip');
__HALT_COMPILER();
?>
--EXPECTF--
hio
test
-alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
+alias "test" is already used for archive "%sphar_setalias2.phar.zip" and cannot be used for other archives
===DONE===
diff --git a/ext/phar/tests/zip/phar_stub_error.phpt b/ext/phar/tests/zip/phar_stub_error.phpt
index fce7a83427..50d0cb1b01 100755
--- a/ext/phar/tests/zip/phar_stub_error.phpt
+++ b/ext/phar/tests/zip/phar_stub_error.phpt
@@ -7,22 +7,15 @@ phar.require_hash=0
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', $stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
-$files = array();
-$files['a'] = 'a';
-$files['.phar/alias.txt'] = 'hio';
-foreach ($files as $n => $file) {
-$a->addFile($n, $file);
-}
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
$phar = new Phar($fname);
+$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
+$phar['a'] = 'a';
+$phar->stopBuffering();
+
var_dump($stub);
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);
@@ -46,14 +39,14 @@ var_dump($phar->getStub() == $stub);
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
__HALT_COMPILER();
?>
--EXPECTF--
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
bool(true)
-Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.php"
+Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
bool(true)
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
diff --git a/ext/phar/tests/zip/refcount1.phpt b/ext/phar/tests/zip/refcount1.phpt
index b16bcb6ead..6d7b7420c6 100644
--- a/ext/phar/tests/zip/refcount1.phpt
+++ b/ext/phar/tests/zip/refcount1.phpt
@@ -9,61 +9,61 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php __HALT_COMPILER(); ?>");
+$phar->setAlias('hio');
$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"; ?>';
-$files['.phar/alias.txt'] = 'hio';
+
foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+ $phar[$n] = $file;
}
-$a->close();
+$phar->stopBuffering();
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
fwrite($fp, "extra");
fclose($fp);
echo "===CLOSE===\n";
-$p = new Phar($fname);
-$b = fopen($pname . '/b/c.php', 'rb');
-$a = $p['b/c.php'];
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
var_dump($a);
var_dump(fread($b, 20));
rewind($b);
echo "===UNLINK===\n";
-unlink($pname . '/b/c.php');
+unlink($alias . '/b/c.php');
var_dump($a);
var_dump(fread($b, 20));
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
===CLOSE===
object(PharFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
- string(%d) "phar://%srefcount1.phar.php/b"
+ string(%d) "phar://%srefcount1.phar.zip/b"
["fileName":"SplFileInfo":private]=>
- string(%d) "phar://%srefcount1.phar.php/b/c.php"
+ string(%d) "phar://%srefcount1.phar.zip/b/c.php"
}
string(5) "extra"
===UNLINK===
-Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.php", has open file pointers, cannot unlink in %srefcount1.php on line %d
+Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.zip", has open file pointers, cannot unlink in %srefcount1.php on line %d
object(PharFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
- string(%d) "phar://%srefcount1.phar.php/b"
+ string(%d) "phar://%srefcount1.phar.zip/b"
["fileName":"SplFileInfo":private]=>
- string(%s) "phar://%srefcount1.phar.php/b/c.php"
+ string(%s) "phar://%srefcount1.phar.zip/b/c.php"
}
string(5) "extra"
extra
diff --git a/ext/phar/tests/zip/rename.phpt b/ext/phar/tests/zip/rename.phpt
index 7e6d3118da..9b1f5c98cd 100644
--- a/ext/phar/tests/zip/rename.phpt
+++ b/ext/phar/tests/zip/rename.phpt
@@ -7,33 +7,28 @@ phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php
Phar::mapPhar('hio');
__HALT_COMPILER(); ?>");
-
-$files = array();
-$files['a'] = 'a';
-foreach ($files as $n => $file) {
-$a->addFile($n, $file);
-}
-$a->close();
+$phar['a'] = 'a';
+$phar->stopBuffering();
include $fname;
-echo file_get_contents($pname . '/a') . "\n";
-rename($pname . '/a', $pname . '/b');
-echo file_get_contents($pname . '/b') . "\n";
-echo file_get_contents($pname . '/a') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
+rename($alias . '/a', $alias . '/b');
+echo file_get_contents($alias . '/b') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
?>
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
--EXPECTF--
a
a
-Warning: file_get_contents(phar://%srename.phar.php/a): 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
+Warning: file_get_contents(phar://%srename.phar.zip/a): 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