From ef46f3e3a2a7d267e31be072be3e5843901ea278 Mon Sep 17 00:00:00 2001 From: Steph Fox Date: Mon, 11 Feb 2008 20:55:44 +0000 Subject: [PATCH] Funnily enough those frontcontroller tests still pass here! Investigating... --- ext/phar/tests/zip/033.phpt | 42 ++++++++--------- ext/phar/tests/zip/033a.phpt | 42 ++++++++--------- ext/phar/tests/zip/delete.phpt | 23 ++++----- ext/phar/tests/zip/delete_in_phar.phpt | 39 ++++++++-------- ext/phar/tests/zip/delete_in_phar_b.phpt | 35 +++++++------- .../tests/zip/delete_in_phar_confirm.phpt | 43 ++++++++--------- .../zip/{ => files}/frontcontroller.phar.inc | 0 .../zip/{ => files}/frontcontroller.phar.zip | Bin .../{ => files}/frontcontroller10.phar.inc | 0 .../{ => files}/frontcontroller10.phar.zip | Bin .../{ => files}/frontcontroller11.phar.inc | 0 .../{ => files}/frontcontroller11.phar.zip | Bin .../{ => files}/frontcontroller12.phar.inc | 0 .../{ => files}/frontcontroller12.phar.zip | Bin .../zip/{ => files}/frontcontroller2.phar.inc | 0 .../zip/{ => files}/frontcontroller2.phar.zip | Bin .../zip/{ => files}/frontcontroller3.phar.inc | 0 .../zip/{ => files}/frontcontroller3.phar.zip | Bin .../zip/{ => files}/frontcontroller4.phar.inc | 0 .../zip/{ => files}/frontcontroller4.phar.zip | Bin .../zip/{ => files}/frontcontroller5.phar.inc | 0 .../zip/{ => files}/frontcontroller5.phar.zip | Bin .../zip/{ => files}/frontcontroller6.phar.inc | 0 .../zip/{ => files}/frontcontroller6.phar.zip | Bin .../zip/{ => files}/frontcontroller7.phar.inc | 0 .../zip/{ => files}/frontcontroller7.phar.zip | Bin .../zip/{ => files}/frontcontroller8.phar.inc | 0 .../zip/{ => files}/frontcontroller8.phar.zip | Bin .../zip/{ => files}/frontcontroller9.phar.inc | 0 .../zip/{ => files}/frontcontroller9.phar.zip | Bin .../zip/{ => files}/make_invalid_tar.php.inc | 0 .../zipmaker.php.inc} | 44 +++++++----------- .../tests/zip/open_for_write_existing.phpt | 24 +++++----- .../tests/zip/open_for_write_existing_b.phpt | 27 ++++++----- .../tests/zip/open_for_write_existing_c.phpt | 29 ++++++------ .../tests/zip/open_for_write_newfile.phpt | 27 ++++++----- .../tests/zip/open_for_write_newfile_b.phpt | 34 ++++++++------ .../tests/zip/open_for_write_newfile_c.phpt | 34 ++++++++------ ext/phar/tests/zip/phar_setalias.phpt | 24 +++++----- ext/phar/tests/zip/phar_setalias2.phpt | 28 +++++------ ext/phar/tests/zip/phar_stub_error.phpt | 23 ++++----- ext/phar/tests/zip/refcount1.phpt | 42 ++++++++--------- ext/phar/tests/zip/rename.phpt | 33 ++++++------- 43 files changed, 292 insertions(+), 301 deletions(-) rename ext/phar/tests/zip/{ => files}/frontcontroller.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller10.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller10.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller11.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller11.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller12.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller12.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller2.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller2.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller3.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller3.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller4.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller4.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller5.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller5.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller6.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller6.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller7.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller7.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller8.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller8.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller9.phar.inc (100%) rename ext/phar/tests/zip/{ => files}/frontcontroller9.phar.zip (100%) rename ext/phar/tests/zip/{ => files}/make_invalid_tar.php.inc (100%) rename ext/phar/tests/zip/{tarmaker.php.inc => files/zipmaker.php.inc} (51%) 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-- init(); -$a->addFile('a.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'] = ''; +$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-- --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-- init(); -$a->addFile('a.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'] = ''; +$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-- --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-- "; -$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-- - + --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-- init(); -$a->addFile('a.php', ''); -$a->addFile('b.php', ''); -$a->addFile('b/c.php', ''); -$a->addFile('.phar/stub.php', ''); -$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'] = ''; +$phar['b.php'] = ''; +$phar['b/c.php'] = ''; +$phar->setStub(''); +$phar->stopBuffering(); + +include $alias . '/a.php'; +include $alias . '/b.php'; +include $alias . '/b/c.php'; +unlink($alias . '/b/c.php'); ?> ===AFTER=== ===DONE=== --CLEAN-- - + --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-- init(); -$a->addFile('a.php', ''); -$a->addFile('b.php', ''); -$a->addFile('b/c.php', ''); -$a->addFile('.phar/stub.php', ''); -$a->close(); +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar['a.php'] = ''; +$phar['b.php'] = ''; +$phar['b/c.php'] = ''; +$phar->setStub(''); +$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=== ===DONE=== --CLEAN-- - + --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-- init(); -$a->addFile('a.php', ''); -$a->addFile('b.php', ''); -$a->addFile('b/c.php', ''); -$a->addFile('.phar/stub.php', ''); -$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'] = ''; +$phar['b.php'] = ''; +$phar['b/c.php'] = ''; +$phar->setStub(''); +$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=== ===DONE=== --CLEAN-- - + --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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller.phar.zip rename to ext/phar/tests/zip/files/frontcontroller.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller10.phar.inc b/ext/phar/tests/zip/files/frontcontroller10.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller10.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller10.phar.zip rename to ext/phar/tests/zip/files/frontcontroller10.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller11.phar.inc b/ext/phar/tests/zip/files/frontcontroller11.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller11.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller11.phar.zip rename to ext/phar/tests/zip/files/frontcontroller11.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller12.phar.inc b/ext/phar/tests/zip/files/frontcontroller12.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller12.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller12.phar.zip rename to ext/phar/tests/zip/files/frontcontroller12.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller2.phar.inc b/ext/phar/tests/zip/files/frontcontroller2.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller2.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller2.phar.zip rename to ext/phar/tests/zip/files/frontcontroller2.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller3.phar.inc b/ext/phar/tests/zip/files/frontcontroller3.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller3.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller3.phar.zip rename to ext/phar/tests/zip/files/frontcontroller3.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller4.phar.inc b/ext/phar/tests/zip/files/frontcontroller4.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller4.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller4.phar.zip rename to ext/phar/tests/zip/files/frontcontroller4.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller5.phar.inc b/ext/phar/tests/zip/files/frontcontroller5.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller5.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller5.phar.zip rename to ext/phar/tests/zip/files/frontcontroller5.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller6.phar.inc b/ext/phar/tests/zip/files/frontcontroller6.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller6.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller6.phar.zip rename to ext/phar/tests/zip/files/frontcontroller6.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller7.phar.inc b/ext/phar/tests/zip/files/frontcontroller7.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller7.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller7.phar.zip rename to ext/phar/tests/zip/files/frontcontroller7.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller8.phar.inc b/ext/phar/tests/zip/files/frontcontroller8.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller8.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller8.phar.zip rename to ext/phar/tests/zip/files/frontcontroller8.phar.zip diff --git a/ext/phar/tests/zip/frontcontroller9.phar.inc b/ext/phar/tests/zip/files/frontcontroller9.phar.inc similarity index 100% rename from ext/phar/tests/zip/frontcontroller9.phar.inc rename to 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 similarity index 100% rename from ext/phar/tests/zip/frontcontroller9.phar.zip rename to ext/phar/tests/zip/files/frontcontroller9.phar.zip diff --git a/ext/phar/tests/zip/make_invalid_tar.php.inc b/ext/phar/tests/zip/files/make_invalid_tar.php.inc similarity index 100% rename from ext/phar/tests/zip/make_invalid_tar.php.inc rename to 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 similarity index 51% rename from ext/phar/tests/zip/tarmaker.php.inc rename to 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 @@ 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-- init(); -$a->addFile('.phar/stub.php', ""); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(''); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; + 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-- - + --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-- init(); -$a->addFile('.phar/stub.php', ""); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(''); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; + 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-- - + --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-- --INI-- @@ -7,34 +7,37 @@ phar.readonly=0 phar.require_hash=0 --FILE-- init(); -$a->addFile('.phar/stub.php', ""); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(''); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; + 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-- - + --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-- init(); -$a->addFile('.phar/stub.php', ""); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(''); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; + 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-- - + --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-- init(); -$a->addFile('.phar/stub.php', ""); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(''); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; + 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-- - + --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-- init(); -$a->addFile('.phar/stub.php', ""); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(''); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; + 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-- - + --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-- init(); -$a->addFile('.phar/stub.php', ''); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; + +$phar = new Phar($fname); +$phar->setStub(''); +$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-- --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-- init(); -$a->addFile('.phar/stub.php', ''); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; + +$phar = new Phar($fname); +$phar->setStub(''); +$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-- --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-- init(); -$a->addFile('.phar/stub.php', $stub = ''); -$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 = ''); +$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-- --EXPECTF-- string(48) "" string(48) "" 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) "" bool(true) string(48) "" 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-- init(); -$a->addFile('.phar/stub.php', ""); +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub(""); +$phar->setAlias('hio'); $files = array(); + $files['a.php'] = ''; $files['b.php'] = ''; $files['b/c.php'] = ''; -$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-- - + --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-- init(); -$a->addFile('.phar/stub.php', "setStub(""); - -$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-- - + --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 -- 2.40.0