diff options
73 files changed, 481 insertions, 783 deletions
diff --git a/ext/phar/tests/tar/033.phpt b/ext/phar/tests/tar/033.phpt index 662e462fa9..2f4e4b2a4f 100644 --- a/ext/phar/tests/tar/033.phpt +++ b/ext/phar/tests/tar/033.phpt @@ -7,38 +7,37 @@ 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.tar'; +$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']->isReadable()); - $a['test']->chmod(0000); - var_dump($a['test']->isReadable()); - $a['test']->chmod(0666); - var_dump($a['test']->isReadable()); + 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"; } + ?> ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECTF-- bool(false) diff --git a/ext/phar/tests/tar/033a.phpt b/ext/phar/tests/tar/033a.phpt index 469dbfb94c..92c089faa9 100644 --- a/ext/phar/tests/tar/033a.phpt +++ b/ext/phar/tests/tar/033a.phpt @@ -3,34 +3,33 @@ Phar::chmod tar-based --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --INI-- -phar.readonly=1 +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.tar'; +$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']->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"; } @@ -38,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.tar'); ?> --EXPECTF-- bool(false) -Cannot modify permissions for file "a.php" in phar "%s033a.1.phar.php", write operations are prohibited +Cannot modify permissions for file "a.php" in phar "%s033a.phar.tar", write operations are prohibited ===DONE=== diff --git a/ext/phar/tests/tar/delete.phpt b/ext/phar/tests/tar/delete.phpt index 9e94116af4..32b2b1e28b 100644 --- a/ext/phar/tests/tar/delete.phpt +++ b/ext/phar/tests/tar/delete.phpt @@ -7,28 +7,26 @@ 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; -$file = "<?php + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar'; +$alias = 'phar://' . $fname; +$stub = "<?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($stub); +$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.tar'); ?> --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.tar/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.tar" in %sdelete.php on line %d
\ No newline at end of file diff --git a/ext/phar/tests/tar/delete_in_phar.phpt b/ext/phar/tests/tar/delete_in_phar.phpt index 6cf539599c..91ef4a2046 100644 --- a/ext/phar/tests/tar/delete_in_phar.phpt +++ b/ext/phar/tests/tar/delete_in_phar.phpt @@ -7,33 +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(); - -include $pname . '/a.php'; -include $pname . '/b.php'; -include $pname . '/b/c.php'; -unlink($pname . '/b/c.php'); + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar'; +$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'; +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.tar'); ?> --EXPECTF-- This is a This is b @@ -42,9 +42,8 @@ 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.tar/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.tar" 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.tar/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/tar/delete_in_phar_b.phpt b/ext/phar/tests/tar/delete_in_phar_b.phpt index 937e69b015..2af1c66deb 100644 --- a/ext/phar/tests/tar/delete_in_phar_b.phpt +++ b/ext/phar/tests/tar/delete_in_phar_b.phpt @@ -3,37 +3,38 @@ Phar: delete a file within a tar-based .phar --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --INI-- -phar.readonly=1 +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.tar'; +$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 $alias . '/a.php'; +include $alias . '/b.php'; +include $alias . '/b/c.php'; +unlink($alias . '/b/c.php'); -include $pname . '/a.php'; -include $pname . '/b.php'; -include $pname . '/b/c.php'; -unlink($pname . '/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.tar'); ?> --EXPECTF-- This is a This is b diff --git a/ext/phar/tests/tar/delete_in_phar_confirm.phpt b/ext/phar/tests/tar/delete_in_phar_confirm.phpt index 971e40d90d..707bcbd0ed 100644 --- a/ext/phar/tests/tar/delete_in_phar_confirm.phpt +++ b/ext/phar/tests/tar/delete_in_phar_confirm.phpt @@ -7,36 +7,36 @@ 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.tar'; +$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.tar/a.php'; +include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/b.php'; +include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/b/c.php'; ?> ===DONE=== --CLEAN-- -<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECTF-- This is a This is b @@ -45,8 +45,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.tar/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.tar" 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.tar/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d ===DONE=== diff --git a/ext/phar/tests/tar/frontcontroller.phar.inc b/ext/phar/tests/tar/frontcontroller.phar.inc deleted file mode 100644 index 6f426e8864..0000000000 --- a/ext/phar/tests/tar/frontcontroller.phar.inc +++ /dev/null @@ -1,13 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a['index.php'] = 'here is my index'; -$a->setStub('<?php -Phar::webPhar(); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller.phar.tar b/ext/phar/tests/tar/frontcontroller.phar.tar Binary files differdeleted file mode 100644 index 522d097845..0000000000 --- a/ext/phar/tests/tar/frontcontroller.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller1.phar.phpt b/ext/phar/tests/tar/frontcontroller1.phar.phpt index 79699678f2..77158169bb 100644 --- a/ext/phar/tests/tar/frontcontroller1.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller1.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller1.phar.php REQUEST_URI=/frontcontroller1.phar.php/a.jpg PATH_INFO=/a.jpg --FILE_EXTERNAL-- -frontcontroller.phar.tar +files/frontcontroller.phar.tar --EXPECTHEADERS-- Content-type: image/jpeg Content-length: 3 diff --git a/ext/phar/tests/tar/frontcontroller10.phar.inc b/ext/phar/tests/tar/frontcontroller10.phar.inc deleted file mode 100644 index 5b132fa117..0000000000 --- a/ext/phar/tests/tar/frontcontroller10.phar.inc +++ /dev/null @@ -1,20 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller10.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.tar'); -$a['index.php'] = '<?php -var_dump($_SERVER["PHP_SELF"]); -var_dump($_SERVER["SCRIPT_NAME"]); -var_dump($_SERVER["SCRIPT_FILENAME"]); -var_dump($_SERVER["REQUEST_URI"]); -var_dump($_SERVER["PHAR_PHP_SELF"]); -var_dump($_SERVER["PHAR_SCRIPT_NAME"]); -var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); -var_dump($_SERVER["PHAR_REQUEST_URI"]); -'; -$a->setStub('<?php -Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE")); -Phar::webPhar(); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller10.phar.phpt b/ext/phar/tests/tar/frontcontroller10.phar.phpt index fbbe312d1e..0ca67b3d3e 100644 --- a/ext/phar/tests/tar/frontcontroller10.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller10.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller10.phar.php REQUEST_URI=/frontcontroller10.phar.php/hi PATH_INFO=/hi --FILE_EXTERNAL-- -frontcontroller4.phar.tar +files/frontcontroller4.phar.tar --EXPECTHEADERS-- Content-type: text/html Status: 403 Access Denied diff --git a/ext/phar/tests/tar/frontcontroller10.phar.tar b/ext/phar/tests/tar/frontcontroller10.phar.tar Binary files differdeleted file mode 100644 index d43ed916a1..0000000000 --- a/ext/phar/tests/tar/frontcontroller10.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller11.phar.inc b/ext/phar/tests/tar/frontcontroller11.phar.inc deleted file mode 100644 index 2fa15f097e..0000000000 --- a/ext/phar/tests/tar/frontcontroller11.phar.inc +++ /dev/null @@ -1,20 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller11.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.tar'); -$a['index.php'] = '<?php -var_dump($_SERVER["PHP_SELF"]); -var_dump($_SERVER["SCRIPT_NAME"]); -var_dump($_SERVER["SCRIPT_FILENAME"]); -var_dump($_SERVER["REQUEST_URI"]); -var_dump($_SERVER["PHAR_PHP_SELF"]); -var_dump($_SERVER["PHAR_SCRIPT_NAME"]); -var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); -var_dump($_SERVER["PHAR_REQUEST_URI"]); -'; -$a->setStub('<?php -Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI")); -Phar::webPhar(); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller11.phar.phpt b/ext/phar/tests/tar/frontcontroller11.phar.phpt index 472abc3026..697718cc69 100644 --- a/ext/phar/tests/tar/frontcontroller11.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller11.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller11.phar.php REQUEST_URI=/frontcontroller11.phar.php/a.php PATH_INFO=/a.php --FILE_EXTERNAL-- -frontcontroller5.phar.tar +files/frontcontroller5.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECTF-- diff --git a/ext/phar/tests/tar/frontcontroller11.phar.tar b/ext/phar/tests/tar/frontcontroller11.phar.tar Binary files differdeleted file mode 100644 index c8f98a1e78..0000000000 --- a/ext/phar/tests/tar/frontcontroller11.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller12.phar.inc b/ext/phar/tests/tar/frontcontroller12.phar.inc deleted file mode 100644 index 693ef0aa01..0000000000 --- a/ext/phar/tests/tar/frontcontroller12.phar.inc +++ /dev/null @@ -1,20 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller12.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.tar'); -$a['index.php'] = '<?php -var_dump($_SERVER["PHP_SELF"]); -var_dump($_SERVER["SCRIPT_NAME"]); -var_dump($_SERVER["SCRIPT_FILENAME"]); -var_dump($_SERVER["REQUEST_URI"]); -var_dump($_SERVER["PHAR_PHP_SELF"]); -var_dump($_SERVER["PHAR_SCRIPT_NAME"]); -var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); -var_dump($_SERVER["PHAR_REQUEST_URI"]); -'; -$a->setStub('<?php -Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI")); -Phar::webPhar(); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller12.phar.phpt b/ext/phar/tests/tar/frontcontroller12.phar.phpt index e49a633bfa..9109586932 100644 --- a/ext/phar/tests/tar/frontcontroller12.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller12.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller12.phar.php REQUEST_URI=/frontcontroller12.phar.php/a.php PATH_INFO=/a.php --FILE_EXTERNAL-- -frontcontroller6.phar.tar +files/frontcontroller6.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECTF-- diff --git a/ext/phar/tests/tar/frontcontroller12.phar.tar b/ext/phar/tests/tar/frontcontroller12.phar.tar Binary files differdeleted file mode 100644 index 06e7e59b03..0000000000 --- a/ext/phar/tests/tar/frontcontroller12.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller13.phar.phpt b/ext/phar/tests/tar/frontcontroller13.phar.phpt index c90a2cc9c1..974145b830 100644 --- a/ext/phar/tests/tar/frontcontroller13.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller13.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller13.phar.php REQUEST_URI=/frontcontroller13.phar.php/a.php PATH_INFO=/a.php --FILE_EXTERNAL-- -frontcontroller7.phar.tar +files/frontcontroller7.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECTF-- diff --git a/ext/phar/tests/tar/frontcontroller14.phar.phpt b/ext/phar/tests/tar/frontcontroller14.phar.phpt index 90ee6fd757..c40f9b6c34 100644 --- a/ext/phar/tests/tar/frontcontroller14.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller14.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller14.phar.php REQUEST_URI=/frontcontroller14.phar.php/a.jpg PATH_INFO=/a.jpg --FILE_EXTERNAL-- -frontcontroller8.phar.tar +files/frontcontroller8.phar.tar --EXPECTHEADERS-- Content-type: foo/bar Content-length: 4 diff --git a/ext/phar/tests/tar/frontcontroller15.phar.phpt b/ext/phar/tests/tar/frontcontroller15.phar.phpt index 66911f373f..154117fda4 100644 --- a/ext/phar/tests/tar/frontcontroller15.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller15.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller15.phar.php REQUEST_URI=/frontcontroller15.phar.php/a.php PATH_INFO=/a.php --FILE_EXTERNAL-- -frontcontroller8.phar.tar +files/frontcontroller8.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller16.phar.phpt b/ext/phar/tests/tar/frontcontroller16.phar.phpt index 381336a29c..042a695eb3 100644 --- a/ext/phar/tests/tar/frontcontroller16.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller16.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller16.phar.php REQUEST_URI=/frontcontroller16.phar.php/a.phps PATH_INFO=/a.phps --FILE_EXTERNAL-- -frontcontroller8.phar.tar +files/frontcontroller8.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller17.phar.phpt b/ext/phar/tests/tar/frontcontroller17.phar.phpt index 639f8b7d7f..17d04baf30 100644 --- a/ext/phar/tests/tar/frontcontroller17.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller17.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller17.phar.php REQUEST_URI=/frontcontroller17.phar.php/fronk.gronk PATH_INFO=/fronk.gronk --FILE_EXTERNAL-- -frontcontroller8.phar.tar +files/frontcontroller8.phar.tar --EXPECTHEADERS-- Content-type: application/octet-stream Content-length: 4 diff --git a/ext/phar/tests/tar/frontcontroller18.phar.phpt b/ext/phar/tests/tar/frontcontroller18.phar.phpt index eb9875ca6f..4ecb69a138 100644 --- a/ext/phar/tests/tar/frontcontroller18.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller18.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller18.phar.php REQUEST_URI=/frontcontroller18.phar.php/fronk.gronk PATH_INFO=/fronk.gronk --FILE_EXTERNAL-- -frontcontroller9.phar.tar +files/frontcontroller9.phar.tar --EXPECTF-- Fatal error: Uncaught exception 'UnexpectedValueException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.phar.php:2 Stack trace: diff --git a/ext/phar/tests/tar/frontcontroller19.phar.phpt b/ext/phar/tests/tar/frontcontroller19.phar.phpt index 9f52f8824f..2cba4a9a56 100644 --- a/ext/phar/tests/tar/frontcontroller19.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller19.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller19.phar.php REQUEST_URI=/frontcontroller19.phar.php/ PATH_INFO=/ --FILE_EXTERNAL-- -frontcontroller10.phar.tar +files/frontcontroller10.phar.tar --EXPECTF-- Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.phar.php:2 Stack trace: diff --git a/ext/phar/tests/tar/frontcontroller2.phar.inc b/ext/phar/tests/tar/frontcontroller2.phar.inc deleted file mode 100644 index 8ae1171a38..0000000000 --- a/ext/phar/tests/tar/frontcontroller2.phar.inc +++ /dev/null @@ -1,12 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller2.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a->setStub('<?php -Phar::webPhar("whatever", "a.php"); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller2.phar.phpt b/ext/phar/tests/tar/frontcontroller2.phar.phpt index 92b9665ba2..a6b1c780fd 100644 --- a/ext/phar/tests/tar/frontcontroller2.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller2.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller2.phar.php REQUEST_URI=/frontcontroller2.phar.php/a.php PATH_INFO=/a.php --FILE_EXTERNAL-- -frontcontroller.phar.tar +files/frontcontroller.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller2.phar.tar b/ext/phar/tests/tar/frontcontroller2.phar.tar Binary files differdeleted file mode 100644 index 857b116890..0000000000 --- a/ext/phar/tests/tar/frontcontroller2.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller20.phar.phpt b/ext/phar/tests/tar/frontcontroller20.phar.phpt index 3a83efb72f..42ec810aee 100644 --- a/ext/phar/tests/tar/frontcontroller20.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller20.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller20.phar.php REQUEST_URI=/frontcontroller20.phar.php/ PATH_INFO=/ --FILE_EXTERNAL-- -frontcontroller11.phar.tar +files/frontcontroller11.phar.tar --EXPECTF-- Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.phar.php:2 Stack trace: diff --git a/ext/phar/tests/tar/frontcontroller21.phar.phpt b/ext/phar/tests/tar/frontcontroller21.phar.phpt index 2313cbba75..eb21897226 100644 --- a/ext/phar/tests/tar/frontcontroller21.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller21.phar.phpt @@ -8,7 +8,7 @@ REQUEST_URI=/frontcontroller21.phar.php/index.php?test=hi PATH_INFO=/index.php QUERY_STRING=test=hi --FILE_EXTERNAL-- -frontcontroller12.phar.tar +files/frontcontroller12.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECTF-- diff --git a/ext/phar/tests/tar/frontcontroller3.phar.inc b/ext/phar/tests/tar/frontcontroller3.phar.inc deleted file mode 100644 index 9729d0065b..0000000000 --- a/ext/phar/tests/tar/frontcontroller3.phar.inc +++ /dev/null @@ -1,18 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller3.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a->setStub('<?php -function s($a) -{ - static $b = array("/hi" => "a.phps"); - if (isset($b[$a])) return $b[$a]; - return $a; -} -Phar::webPhar("whatever", "/index.php", null, array(), "s"); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller3.phar.phpt b/ext/phar/tests/tar/frontcontroller3.phar.phpt index 9980ea2d29..dee16ee2b2 100644 --- a/ext/phar/tests/tar/frontcontroller3.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller3.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller3.phar.php REQUEST_URI=/frontcontroller3.phar.php/a.phps PATH_INFO=/a.phps --FILE_EXTERNAL-- -frontcontroller.phar.tar +files/frontcontroller.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller3.phar.tar b/ext/phar/tests/tar/frontcontroller3.phar.tar Binary files differdeleted file mode 100644 index f733884d12..0000000000 --- a/ext/phar/tests/tar/frontcontroller3.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller4.phar.inc b/ext/phar/tests/tar/frontcontroller4.phar.inc deleted file mode 100644 index eb1d56f0d4..0000000000 --- a/ext/phar/tests/tar/frontcontroller4.phar.inc +++ /dev/null @@ -1,18 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller4.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a->setStub('<?php -function s($a) -{ - static $b = array("/hi" => false); - if (isset($b[$a])) return $b[$a]; - return $a; -} -Phar::webPhar("whatever", "index.php", null, array(), "s"); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller4.phar.phpt b/ext/phar/tests/tar/frontcontroller4.phar.phpt index da16c389c6..db4846c69b 100644 --- a/ext/phar/tests/tar/frontcontroller4.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller4.phar.phpt @@ -6,7 +6,7 @@ Phar front controller index.php relocate (no /) tar-based SCRIPT_NAME=/frontcontroller4.phar.php REQUEST_URI=/frontcontroller4.phar.php --FILE_EXTERNAL-- -frontcontroller.phar.tar +files/frontcontroller.phar.tar --EXPECTHEADERS-- Status: 301 Moved Permanently Location: /frontcontroller4.phar.php/index.php diff --git a/ext/phar/tests/tar/frontcontroller4.phar.tar b/ext/phar/tests/tar/frontcontroller4.phar.tar Binary files differdeleted file mode 100644 index 5d11af499c..0000000000 --- a/ext/phar/tests/tar/frontcontroller4.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller5.phar.inc b/ext/phar/tests/tar/frontcontroller5.phar.inc deleted file mode 100644 index d6204c7d97..0000000000 --- a/ext/phar/tests/tar/frontcontroller5.phar.inc +++ /dev/null @@ -1,12 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller5.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a->setStub('<?php -Phar::webPhar("whatever", "index.php", null, array(0 => "oops")); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller5.phar.phpt b/ext/phar/tests/tar/frontcontroller5.phar.phpt index a8c122b834..534e66a1e3 100644 --- a/ext/phar/tests/tar/frontcontroller5.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller5.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller5.phar.php REQUEST_URI=/frontcontroller5.phar.php/ PATH_INFO=/ --FILE_EXTERNAL-- -frontcontroller.phar.tar +files/frontcontroller.phar.tar --EXPECTHEADERS-- Status: 301 Moved Permanently Location: /frontcontroller5.phar.php/index.php diff --git a/ext/phar/tests/tar/frontcontroller5.phar.tar b/ext/phar/tests/tar/frontcontroller5.phar.tar Binary files differdeleted file mode 100644 index e6e9015bf8..0000000000 --- a/ext/phar/tests/tar/frontcontroller5.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller6.phar.inc b/ext/phar/tests/tar/frontcontroller6.phar.inc deleted file mode 100644 index 66212d82e8..0000000000 --- a/ext/phar/tests/tar/frontcontroller6.phar.inc +++ /dev/null @@ -1,12 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller6.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a->setStub('<?php -Phar::webPhar("whatever", "index.php", null, array("blah" => 100)); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller6.phar.phpt b/ext/phar/tests/tar/frontcontroller6.phar.phpt index 313630929b..5375beef8c 100644 --- a/ext/phar/tests/tar/frontcontroller6.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller6.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller6.phar.php REQUEST_URI=/frontcontroller6.phar.php/notfound.php PATH_INFO=/notfound.php --FILE_EXTERNAL-- -frontcontroller.phar.tar +files/frontcontroller.phar.tar --EXPECTHEADERS-- Status: 404 Not Found --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller6.phar.tar b/ext/phar/tests/tar/frontcontroller6.phar.tar Binary files differdeleted file mode 100644 index d30b7ab9eb..0000000000 --- a/ext/phar/tests/tar/frontcontroller6.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller7.phar.inc b/ext/phar/tests/tar/frontcontroller7.phar.inc deleted file mode 100644 index 74adf2c008..0000000000 --- a/ext/phar/tests/tar/frontcontroller7.phar.inc +++ /dev/null @@ -1,12 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller7.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.tar'); -$a['a.php'] = 'hio'; -$a['a.jpg'] = 'hio'; -$a['a.phps'] = '<?php function hio(){}'; -$a->setStub('<?php -Phar::webPhar("whatever", "index.php", null, array("blah" => null)); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller7.phar.phpt b/ext/phar/tests/tar/frontcontroller7.phar.phpt index b15ca07ff4..3b73f2075c 100644 --- a/ext/phar/tests/tar/frontcontroller7.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller7.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller7.phar.php REQUEST_URI=/frontcontroller7.phar.php/ PATH_INFO=/ --FILE_EXTERNAL-- -frontcontroller2.phar.tar +files/frontcontroller2.phar.tar --EXPECTHEADERS-- Status: 301 Moved Permanently Location: /frontcontroller7.phar.php/a.php diff --git a/ext/phar/tests/tar/frontcontroller7.phar.tar b/ext/phar/tests/tar/frontcontroller7.phar.tar Binary files differdeleted file mode 100644 index c7ccc940c1..0000000000 --- a/ext/phar/tests/tar/frontcontroller7.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller8.phar.inc b/ext/phar/tests/tar/frontcontroller8.phar.inc deleted file mode 100644 index f51a762806..0000000000 --- a/ext/phar/tests/tar/frontcontroller8.phar.inc +++ /dev/null @@ -1,13 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller8.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.tar'); -$a['a.phps'] = 'hio1'; -$a['a.jpg'] = 'hio2'; -$a['a.php'] = '<?php function hio(){}'; -$a['fronk.gronk'] = 'hio3'; -$a->setStub('<?php -Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller8.phar.phpt b/ext/phar/tests/tar/frontcontroller8.phar.phpt index 0f6f50c700..19844cb199 100644 --- a/ext/phar/tests/tar/frontcontroller8.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller8.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller8.phar.php REQUEST_URI=/frontcontroller8.phar.php/ PATH_INFO=/ --FILE_EXTERNAL-- -frontcontroller3.phar.tar +files/frontcontroller3.phar.tar --EXPECTHEADERS-- Status: 404 Not Found --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller8.phar.tar b/ext/phar/tests/tar/frontcontroller8.phar.tar Binary files differdeleted file mode 100644 index 98495717ce..0000000000 --- a/ext/phar/tests/tar/frontcontroller8.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/frontcontroller9.phar.inc b/ext/phar/tests/tar/frontcontroller9.phar.inc deleted file mode 100644 index 758ce4ff4e..0000000000 --- a/ext/phar/tests/tar/frontcontroller9.phar.inc +++ /dev/null @@ -1,14 +0,0 @@ -<?php -@unlink(dirname(__FILE__) . '/frontcontroller9.phar.tar'); -$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.tar'); -$a['a.phps'] = 'hio1'; -$a['a.jpg'] = 'hio2'; -$a['a.php'] = '<?php function hio(){}'; -$a['fronk.gronk'] = 'hio3'; -$a->setStub('<?php -Phar::mungServer(array()); -Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); -echo "oops did not run\n"; -var_dump($_ENV, $_SERVER); -__HALT_COMPILER();'); -?> diff --git a/ext/phar/tests/tar/frontcontroller9.phar.phpt b/ext/phar/tests/tar/frontcontroller9.phar.phpt index 93540a68b4..080db58f8f 100644 --- a/ext/phar/tests/tar/frontcontroller9.phar.phpt +++ b/ext/phar/tests/tar/frontcontroller9.phar.phpt @@ -7,7 +7,7 @@ SCRIPT_NAME=/frontcontroller9.phar.php REQUEST_URI=/frontcontroller9.phar.php/hi PATH_INFO=/hi --FILE_EXTERNAL-- -frontcontroller3.phar.tar +files/frontcontroller3.phar.tar --EXPECTHEADERS-- Content-type: text/html --EXPECT-- diff --git a/ext/phar/tests/tar/frontcontroller9.phar.tar b/ext/phar/tests/tar/frontcontroller9.phar.tar Binary files differdeleted file mode 100644 index 481864c1cf..0000000000 --- a/ext/phar/tests/tar/frontcontroller9.phar.tar +++ /dev/null diff --git a/ext/phar/tests/tar/make_invalid_tar.php.inc b/ext/phar/tests/tar/make_invalid_tar.php.inc deleted file mode 100644 index c18bd199b3..0000000000 --- a/ext/phar/tests/tar/make_invalid_tar.php.inc +++ /dev/null @@ -1,9 +0,0 @@ -<?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -class corrupter extends tarmaker { -function close() -{ - fwrite($this->tmp, 'oopsie'); - fclose($this->tmp); -} -}
\ No newline at end of file diff --git a/ext/phar/tests/tar/open_for_write_existing.phpt b/ext/phar/tests/tar/open_for_write_existing.phpt index 8e57d10f44..641e5ce21d 100644 --- a/ext/phar/tests/tar/open_for_write_existing.phpt +++ b/ext/phar/tests/tar/open_for_write_existing.phpt @@ -7,31 +7,36 @@ phar.readonly=0 phar.require_hash=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub("<?php __HALT_COMPILER(); ?>"); $files = array(); + $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $phar[$n] = $file; } -$a->close(); -$fp = fopen($pname . '/b/c.php', 'wb'); +$phar->stopBuffering(); + +$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.tar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECT-- extra ===DONE=== diff --git a/ext/phar/tests/tar/open_for_write_existing_b.phpt b/ext/phar/tests/tar/open_for_write_existing_b.phpt index e462133431..54ec5855fb 100755 --- a/ext/phar/tests/tar/open_for_write_existing_b.phpt +++ b/ext/phar/tests/tar/open_for_write_existing_b.phpt @@ -3,46 +3,54 @@ Phar: fopen a .phar for writing (existing file) tar-based --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --INI-- -phar.readonly=1 +phar.readonly=0 phar.require_hash=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub("<?php __HALT_COMPILER(); ?>"); $files = array(); + $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $phar[$n] = $file; } -$a->close(); + +$phar->stopBuffering(); +ini_set('phar.readonly', 1); function err_handler($errno, $errstr, $errfile, $errline) { - echo "Catchable fatal error: $errstr in $errfile on line $errline\n"; + echo "Catchable fatal error: $errstr in $errfile on line $errline\n"; } set_error_handler("err_handler", E_RECOVERABLE_ERROR); -$fp = fopen($pname . '/b/c.php', 'wb'); +$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.tar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECTF-- -Warning: fopen(phar://%sopen_for_write_existing_b.phar.tar.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.tar/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d -Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d +Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_b.php on line %d Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d This is b/c -===DONE===
\ No newline at end of file + +===DONE=== diff --git a/ext/phar/tests/tar/open_for_write_existing_c.phpt b/ext/phar/tests/tar/open_for_write_existing_c.phpt index b73e9e4200..0e5a181e65 100755 --- a/ext/phar/tests/tar/open_for_write_existing_c.phpt +++ b/ext/phar/tests/tar/open_for_write_existing_c.phpt @@ -3,40 +3,48 @@ Phar: fopen a .phar for writing (existing file) tar-based --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --INI-- -phar.readonly=1 +phar.readonly=0 phar.require_hash=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub("<?php __HALT_COMPILER(); ?>"); $files = array(); + $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $phar[$n] = $file; } -$a->close(); -$fp = fopen($pname . '/b/c.php', 'wb'); +$phar->stopBuffering(); +ini_set('phar.readonly', 1); + +$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.tar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECTF-- -Warning: fopen(phar://%sopen_for_write_existing_c.phar.tar.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.tar/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d This is b/c -===DONE===
\ No newline at end of file + +===DONE=== diff --git a/ext/phar/tests/tar/open_for_write_newfile.phpt b/ext/phar/tests/tar/open_for_write_newfile.phpt index 904f245b05..31e9d4a7e9 100644 --- a/ext/phar/tests/tar/open_for_write_newfile.phpt +++ b/ext/phar/tests/tar/open_for_write_newfile.phpt @@ -7,32 +7,37 @@ phar.readonly=0 phar.require_hash=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub("<?php __HALT_COMPILER(); ?>"); $files = array(); + $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $phar[$n] = $file; } -$a->close(); -$fp = fopen($pname . '/b/new.php', 'wb'); +$phar->stopBuffering(); + +$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.tar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECT-- This is b/c extra diff --git a/ext/phar/tests/tar/open_for_write_newfile_b.phpt b/ext/phar/tests/tar/open_for_write_newfile_b.phpt index 129d54ae85..d3a21b4caf 100755 --- a/ext/phar/tests/tar/open_for_write_newfile_b.phpt +++ b/ext/phar/tests/tar/open_for_write_newfile_b.phpt @@ -3,53 +3,59 @@ Phar: fopen a .phar for writing (new file) tar-based --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --INI-- -phar.readonly=1 +phar.readonly=0 phar.require_hash=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub("<?php __HALT_COMPILER(); ?>"); $files = array(); + $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $phar[$n] = $file; } -$a->close(); + +$phar->stopBuffering(); +ini_set('phar.readonly', 1); function err_handler($errno, $errstr, $errfile, $errline) { - echo "Catchable fatal error: $errstr in $errfile on line $errline\n"; + echo "Catchable fatal error: $errstr in $errfile on line $errline\n"; } set_error_handler("err_handler", E_RECOVERABLE_ERROR); -$fp = fopen($pname . '/b/new.php', 'wb'); +$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.tar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECTF-- -Warning: fopen(phar://%sopen_for_write_newfile_b.phar.tar.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.tar/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d This is b/c -Warning: include(phar://%sopen_for_write_newfile_b.phar.tar.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.tar.php" in %sopen_for_write_newfile_b.php on line %d +Warning: include(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.tar" in %sopen_for_write_newfile_b.php on line %d -Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.tar.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.tar/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/tar/open_for_write_newfile_c.phpt b/ext/phar/tests/tar/open_for_write_newfile_c.phpt index f7b1ef7eee..231241c8ad 100755 --- a/ext/phar/tests/tar/open_for_write_newfile_c.phpt +++ b/ext/phar/tests/tar/open_for_write_newfile_c.phpt @@ -3,47 +3,52 @@ Phar: fopen a .phar for writing (new file) tar-based --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); ?> --INI-- -phar.readonly=1 +phar.readonly=0 phar.require_hash=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar'; +$alias = 'phar://' . $fname; + +$phar = new Phar($fname); +$phar->setStub("<?php __HALT_COMPILER(); ?>"); $files = array(); + $files['a.php'] = '<?php echo "This is a\n"; ?>'; $files['b.php'] = '<?php echo "This is b\n"; ?>'; $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $phar[$n] = $file; } -$a->close(); -$fp = fopen($pname . '/b/new.php', 'wb'); +$phar->stopBuffering(); +ini_set('phar.readonly', 1); + +$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.tar.php'); ?> +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> --EXPECTF-- -Warning: fopen(phar://%sopen_for_write_newfile_c.phar.tar.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.tar/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d This is b/c -Warning: include(phar://%sopen_for_write_newfile_c.phar.tar.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.tar.php" in %sopen_for_write_newfile_c.php on line %d +Warning: include(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.tar" in %sopen_for_write_newfile_c.php on line %d -Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.tar.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.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d ===DONE===
\ No newline at end of file diff --git a/ext/phar/tests/tar/phar_setalias.phpt b/ext/phar/tests/tar/phar_setalias.phpt index db6a22391d..1102df7c19 100644 --- a/ext/phar/tests/tar/phar_setalias.phpt +++ b/ext/phar/tests/tar/phar_setalias.phpt @@ -7,33 +7,35 @@ 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.tar'; + +$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 = new Phar($fname); +$phar->stopBuffering(); + echo $phar->getAlias() . "\n"; $phar->setAlias('test'); 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.tar'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar'); __HALT_COMPILER(); ?> --EXPECT-- diff --git a/ext/phar/tests/tar/phar_setalias2.phpt b/ext/phar/tests/tar/phar_setalias2.phpt index 63be3b5d07..d48c041b76 100644 --- a/ext/phar/tests/tar/phar_setalias2.phpt +++ b/ext/phar/tests/tar/phar_setalias2.phpt @@ -7,44 +7,47 @@ 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.tar'; + +$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 = new Phar($fname); +$phar->stopBuffering(); + echo $phar->getAlias() . "\n"; $phar->setAlias('test'); echo $phar->getAlias() . "\n"; + $phar = new Phar(dirname(__FILE__) . '/notphar.phar'); + try { $phar->setAlias('test'); } catch (Exception $e) { echo $e->getMessage() . "\n"; } + ?> ===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.tar'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar'); __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.tar" and cannot be used for other archives ===DONE=== diff --git a/ext/phar/tests/tar/phar_stub_error.phpt b/ext/phar/tests/tar/phar_stub_error.phpt index 0c4de9657a..5d35b932fe 100755 --- a/ext/phar/tests/tar/phar_stub_error.phpt +++ b/ext/phar/tests/tar/phar_stub_error.phpt @@ -7,35 +7,27 @@ 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.tar'; $phar = new Phar($fname); +$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' ."\r\n"); +$phar->setAlias('hio'); +$phar['a'] = 'a'; +$phar->stopBuffering(); + var_dump($stub); var_dump($phar->getStub()); var_dump($phar->getStub() == $stub); $newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>'; -try -{ + +try { $phar->setStub($newstub); -} -catch(exception $e) -{ +} catch(exception $e) { echo 'Exception: ' . $e->getMessage() . "\n"; } + var_dump($phar->getStub()); var_dump($phar->getStub() == $stub); $phar->stopBuffering(); @@ -46,16 +38,20 @@ 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.tar'); __HALT_COMPILER(); ?> --EXPECTF-- -string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" -string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" +string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?> +" +string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?> +" bool(true) -Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.php" -string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" +Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.tar" +string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?> +" bool(true) -string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" +string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?> +" bool(true) ===DONE=== diff --git a/ext/phar/tests/tar/refcount1.phpt b/ext/phar/tests/tar/refcount1.phpt index add9ebfdab..c6808afb63 100644 --- a/ext/phar/tests/tar/refcount1.phpt +++ b/ext/phar/tests/tar/refcount1.phpt @@ -9,61 +9,65 @@ 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(); ?>"); +include dirname(__FILE__) . '/files/tarmaker.php.inc'; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar'; +$alias = 'phar://' . $fname; +$tar = new tarmaker($fname, 'none'); +$tar->init(); +$tar->addFile('.phar/stub.php', "<?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"; ?>'; $files['.phar/alias.txt'] = 'hio'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $tar->addFile($n, $file); } -$a->close(); -$fp = fopen($pname . '/b/c.php', 'wb'); +$tar->close(); + +$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']; +$phar = new Phar($fname); +$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.tar'); ?> --EXPECTF-- ===CLOSE=== object(PharFileInfo)#%d (2) { ["pathName":"SplFileInfo":private]=> - string(%d) "phar://%srefcount1.phar.php/b" + string(%d) "phar://%srefcount1.phar.tar/b" ["fileName":"SplFileInfo":private]=> - string(%d) "phar://%srefcount1.phar.php/b/c.php" + string(%d) "phar://%srefcount1.phar.tar/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.tar", 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.tar/b" ["fileName":"SplFileInfo":private]=> - string(%s) "phar://%srefcount1.phar.php/b/c.php" + string(%s) "phar://%srefcount1.phar.tar/b/c.php" } string(5) "extra" extra diff --git a/ext/phar/tests/tar/rename.phpt b/ext/phar/tests/tar/rename.phpt index e3e3dfa984..96588a6596 100644 --- a/ext/phar/tests/tar/rename.phpt +++ b/ext/phar/tests/tar/rename.phpt @@ -7,33 +7,36 @@ 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 +include dirname(__FILE__) . '/files/tarmaker.php.inc'; +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar'; +$alias = 'phar://' . $fname; + +$tar = new tarmaker($fname, 'none'); +$tar->init(); +$tar->addFile('.phar/stub.php', "<?php Phar::mapPhar('hio'); __HALT_COMPILER(); ?>"); $files = array(); $files['a'] = 'a'; + foreach ($files as $n => $file) { -$a->addFile($n, $file); + $tar->addFile($n, $file); } -$a->close(); + +$tar->close(); 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.tar'); ?> --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.tar/a): 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/tar_001.phpt b/ext/phar/tests/tar/tar_001.phpt index c0e7ea308c..76242c89fb 100644 --- a/ext/phar/tests/tar/tar_001.phpt +++ b/ext/phar/tests/tar/tar_001.phpt @@ -5,18 +5,19 @@ Phar: tar-based phar corrupted <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?> --FILE-- <?php -include dirname(__FILE__) . '/make_invalid_tar.php.inc'; -$a = new corrupter(dirname(__FILE__) . '/tar_001.phar', 'none'); -$a->init(); -$a->addFile('tar_001.phpt', __FILE__); -$a->close(); +include dirname(__FILE__) . '/files/make_invalid_tar.php.inc'; -$a = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar/tar_001.phpt', 'rb'); +$tar = new corrupter(dirname(__FILE__) . '/tar_001.phar.tar', 'none'); +$tar->init(); +$tar->addFile('tar_001.phpt', __FILE__); +$tar->close(); + +$tar = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar.tar/tar_001.phpt', 'rb'); try { -$a = new Phar(dirname(__FILE__) . '/tar_001.phar'); -echo "should not execute\n"; + $phar = new Phar(dirname(__FILE__) . '/tar_001.phar.tar'); + echo "should not execute\n"; } catch (Exception $e) { -echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> ===DONE=== @@ -25,6 +26,6 @@ echo $e->getMessage() . "\n"; @unlink(dirname(__FILE__) . '/tar_001.phar'); ?> --EXPECTF-- -Warning: fopen(phar://%star_001.phar/tar_001.phpt): failed to open stream: phar error: "%star_001.phar" is a corrupted tar file in %star_001.php on line %d -Cannot open phar file '%star_001.phar' with alias '(null)': phar error: "%star_001.phar" is a corrupted tar file +Warning: fopen(phar://%star_001.phar.tar/tar_001.phpt): failed to open stream: phar error: "%star_001.phar.tar" is a corrupted tar file in %star_001.php on line %d +Cannot open phar file '%star_001.phar.tar' with alias '(null)': phar error: "%star_001.phar.tar" is a corrupted tar file ===DONE===
\ No newline at end of file diff --git a/ext/phar/tests/tar/tar_002.phpt b/ext/phar/tests/tar/tar_002.phpt index b9e4c59392..2674e416b8 100644 --- a/ext/phar/tests/tar/tar_002.phpt +++ b/ext/phar/tests/tar/tar_002.phpt @@ -7,26 +7,28 @@ Phar: tar-based phar corrupted 2 phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/make_invalid_tar.php.inc'; -$a = new corrupter(dirname(__FILE__) . '/tar_002.phar', 'none'); -$a->init(); -$a->addFile('tar_002.phpt', __FILE__); -$a->close(); +include dirname(__FILE__) . '/files/make_invalid_tar.php.inc'; + +$tar = new corrupter(dirname(__FILE__) . '/tar_002.phar.tar', 'none'); +$tar->init(); +$tar->addFile('tar_002.phpt', __FILE__); +$tar->close(); + +$tar = fopen('phar://' . dirname(__FILE__) . '/tar_002.phar.tar/tar_002.phpt', 'rb'); -$a = fopen('phar://' . dirname(__FILE__) . '/tar_002.phar/tar_002.phpt', 'rb'); try { -$a = new Phar(dirname(__FILE__) . '/tar_002.phar'); -echo "should not execute\n"; + $phar = new Phar(dirname(__FILE__) . '/tar_002.phar.tar'); + echo "should not execute\n"; } catch (Exception $e) { -echo $e->getMessage() . "\n"; + echo $e->getMessage() . "\n"; } ?> ===DONE=== --CLEAN-- <?php -@unlink(dirname(__FILE__) . '/tar_002.phar'); +@unlink(dirname(__FILE__) . '/tar_002.phar.tar'); ?> --EXPECTF-- -Warning: fopen(phar://%star_002.phar/tar_002.phpt): failed to open stream: phar error: "%star_002.phar" is a corrupted tar file in %star_002.php on line %d -Cannot open phar file '%star_002.phar' with alias '(null)': phar error: "%star_002.phar" is a corrupted tar file +Warning: fopen(phar://%star_002.phar.tar/tar_002.phpt): failed to open stream: phar error: "%star_002.phar.tar" is a corrupted tar file in %star_002.php on line %d +Cannot open phar file '%star_002.phar.tar' with alias '(null)': phar error: "%star_002.phar.tar" is a corrupted tar file ===DONE===
\ No newline at end of file diff --git a/ext/phar/tests/tar/tar_003.phpt b/ext/phar/tests/tar/tar_003.phpt index b8e5f41d82..e7beecb55c 100644 --- a/ext/phar/tests/tar/tar_003.phpt +++ b/ext/phar/tests/tar/tar_003.phpt @@ -7,41 +7,45 @@ Phar: tar-based phar, valid 1 phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/tar_003.phar'; -$pname = 'phar://' . $fname; - -$a = new tarmaker($fname, 'none'); -$a->init(); -$a->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r')); -$a->addFile('internal/file/here', "hi there!\n"); -$a->mkDir('internal/dir'); -$a->mkDir('dir'); -$a->close(); +include dirname(__FILE__) . '/files/tarmaker.php.inc'; + +$fname = dirname(__FILE__) . '/tar_003.phar.tar'; +$alias = 'phar://' . $fname; + +$tar = new tarmaker($fname, 'none'); +$tar->init(); +$tar->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r')); +$tar->addFile('internal/file/here', "hi there!\n"); +$tar->mkDir('internal/dir'); +$tar->mkDir('dir'); +$tar->close(); + fclose($g); -echo file_get_contents($pname . '/internal/file/here'); -$a = opendir($pname . '/'); -while (false !== ($v = readdir($a))) { - echo (is_file($pname . '/' . $v) ? "file\n" : "dir\n"); +echo file_get_contents($alias . '/internal/file/here'); + +$tar = opendir($alias . '/'); + +while (false !== ($v = readdir($tar))) { + echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); echo $v . "\n"; } -closedir($a); +closedir($tar); /* ensure none of the dir tar files were freed */ echo "second round\n"; -$a = opendir($pname . '/'); -while (false !== ($v = readdir($a))) { - echo (is_file($pname . '/' . $v) ? "file\n" : "dir\n"); +$tar = opendir($alias . '/'); +while (false !== ($v = readdir($tar))) { + echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n"); echo $v . "\n"; } -closedir($a); +closedir($tar); ?> ===DONE=== --CLEAN-- <?php -@unlink(dirname(__FILE__) . '/tar_003.phar'); +@unlink(dirname(__FILE__) . '/tar_003.phar.tar'); ?> --EXPECT-- hi there! diff --git a/ext/phar/tests/tar/tar_004.phpt b/ext/phar/tests/tar/tar_004.phpt index 63a3dd8b91..2dd7ba169f 100644 --- a/ext/phar/tests/tar/tar_004.phpt +++ b/ext/phar/tests/tar/tar_004.phpt @@ -7,31 +7,32 @@ Phar: tar-based phar, tar phar with stub, mapPhar() phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/tar_004.phar'; -$pname = 'phar://' . $fname; +include dirname(__FILE__) . '/files/tarmaker.php.inc'; -$a = new tarmaker($fname, 'none'); -$a->init(); -$a->addFile('tar_004.php', '<?php var_dump(__FILE__);'); -$a->addFile('internal/file/here', "hi there!\n"); -$a->mkDir('internal/dir'); -$a->mkDir('dir'); -$a->addFile('.phar/stub.php', '<?php +$fname = dirname(__FILE__) . '/tar_004.phar.tar'; +$alias = 'phar://' . $fname; + +$tar = new tarmaker($fname, 'none'); +$tar->init(); +$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);'); +$tar->addFile('internal/file/here', "hi there!\n"); +$tar->mkDir('internal/dir'); +$tar->mkDir('dir'); +$tar->addFile('.phar/stub.php', '<?php Phar::mapPhar(); var_dump("it worked"); include "phar://" . __FILE__ . "/tar_004.php"; '); -$a->close(); +$tar->close(); include $fname; ?> ===DONE=== --CLEAN-- <?php -@unlink(dirname(__FILE__) . '/tar_004.phar'); +@unlink(dirname(__FILE__) . '/tar_004.phar.tar'); ?> --EXPECTF-- string(9) "it worked" -string(%d) "phar://%star_004.phar/tar_004.php" +string(%d) "phar://%star_004.phar.tar/tar_004.php" ===DONE===
\ No newline at end of file diff --git a/ext/phar/tests/tar/tar_bz2.phpt b/ext/phar/tests/tar/tar_bz2.phpt index 65f062261f..8c34fbc98a 100644 --- a/ext/phar/tests/tar/tar_bz2.phpt +++ b/ext/phar/tests/tar/tar_bz2.phpt @@ -8,33 +8,37 @@ Phar: tar-based phar, bzipped tar phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; +include dirname(__FILE__) . '/files/tarmaker.php.inc'; + $fname = dirname(__FILE__) . '/tar_bz2.phar'; -$pname = 'phar://' . $fname; +$alias = 'phar://' . $fname; $fname2 = dirname(__FILE__) . '/tar_bz2.phar.tar'; -$pname2 = 'phar://' . $fname2; +$alias2 = 'phar://' . $fname2; -$a = new tarmaker($fname, 'bz2'); -$a->init(); -$a->addFile('tar_004.php', '<?php var_dump(__FILE__);'); -$a->addFile('internal/file/here', "hi there!\n"); -$a->mkDir('internal/dir'); -$a->mkDir('dir'); -$a->addFile('.phar/stub.php', '<?php +$tar = new tarmaker($fname, 'bz2'); +$tar->init(); +$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);'); +$tar->addFile('internal/file/here', "hi there!\n"); +$tar->mkDir('internal/dir'); +$tar->mkDir('dir'); +$tar->addFile('.phar/stub.php', '<?php Phar::mapPhar(); var_dump("it worked"); include "phar://" . __FILE__ . "/tar_004.php"; '); -$a->close(); +$tar->close(); include $fname; -$a = new Phar($fname); -$a['test'] = 'hi'; +$phar = new Phar($fname); +$phar['test'] = 'hi'; + copy($fname, $fname2); -$b = new Phar($fname2); -var_dump($b->isTar()); -var_dump($b->isCompressed() == Phar::BZ2); + +$phar2 = new Phar($fname2); +var_dump($phar2->isTar()); +var_dump($phar2->isCompressed() == Phar::BZ2); + ?> ===DONE=== --CLEAN-- diff --git a/ext/phar/tests/tar/tar_gzip.phpt b/ext/phar/tests/tar/tar_gzip.phpt index 9fccc79226..a7fcb7c228 100644 --- a/ext/phar/tests/tar/tar_gzip.phpt +++ b/ext/phar/tests/tar/tar_gzip.phpt @@ -9,7 +9,7 @@ Phar: tar-based phar, gzipped tar phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; +include dirname(__FILE__) . '/files/tarmaker.php.inc'; $fname = dirname(__FILE__) . '/tar_gzip.phar'; $pname = 'phar://' . $fname; $fname2 = dirname(__FILE__) . '/tar_gzip.phar.tar'; diff --git a/ext/phar/tests/tar/tar_makebz2.phpt b/ext/phar/tests/tar/tar_makebz2.phpt index 3dd2735277..203265b385 100644 --- a/ext/phar/tests/tar/tar_makebz2.phpt +++ b/ext/phar/tests/tar/tar_makebz2.phpt @@ -8,26 +8,29 @@ Phar: tar-based phar, make new bzipped tar phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; + $fname = dirname(__FILE__) . '/tar_makebz2.phar.tar'; -$pname = 'phar://' . $fname; -$fname2 = dirname(__FILE__) . '/tar_makebz22.phar.tar'; -$pname2 = 'phar://' . $fname2; +$alias = 'phar://' . $fname; +$fname2 = dirname(__FILE__) . '/tar_makebz2_b.phar.tar'; +$alias2 = 'phar://' . $fname2; + +$phar = new Phar($fname); +$phar['test'] = 'hi'; +var_dump($phar->isTar()); +$phar->compressAllFilesBZIP2(); -$a = new Phar($fname); -$a['test'] = 'hi'; -var_dump($a->isTar()); -$a->compressAllFilesBZIP2(); copy($fname, $fname2); -$b = new Phar($fname2); -var_dump($b->isTar()); -var_dump($b->isCompressed() == Phar::BZ2); + +$phar2 = new Phar($fname2); +var_dump($phar2->isTar()); +var_dump($phar2->isCompressed() == Phar::BZ2); + ?> ===DONE=== --CLEAN-- <?php @unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar'); -@unlink(dirname(__FILE__) . '/tar_makebz22.phar.tar'); +@unlink(dirname(__FILE__) . '/tar_makebz2_b.phar.tar'); ?> --EXPECTF-- bool(true) diff --git a/ext/phar/tests/tar/tar_makegz.phpt b/ext/phar/tests/tar/tar_makegz.phpt index bf5c065d83..280c51a762 100644 --- a/ext/phar/tests/tar/tar_makegz.phpt +++ b/ext/phar/tests/tar/tar_makegz.phpt @@ -8,26 +8,29 @@ Phar: tar-based phar, make new gzipped tar phar.readonly=0 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; + $fname = dirname(__FILE__) . '/tar_makegz.phar.tar'; -$pname = 'phar://' . $fname; -$fname2 = dirname(__FILE__) . '/tar_makegz2.phar.tar'; -$pname2 = 'phar://' . $fname2; +$alias = 'phar://' . $fname; +$fname2 = dirname(__FILE__) . '/tar_makegz_b.phar.tar'; +$alias2 = 'phar://' . $fname2; + +$phar = new Phar($fname); +$phar['test'] = 'hi'; +var_dump($phar->isTar()); +$phar->compressAllFilesGZ(); -$a = new Phar($fname); -$a['test'] = 'hi'; -var_dump($a->isTar()); -$a->compressAllFilesGZ(); copy($fname, $fname2); -$b = new Phar($fname2); -var_dump($b->isTar()); -var_dump($b->isCompressed() == Phar::GZ); + +$phar2 = new Phar($fname2); +var_dump($phar2->isTar()); +var_dump($phar2->isCompressed() == Phar::GZ); + ?> ===DONE=== --CLEAN-- <?php @unlink(dirname(__FILE__) . '/tar_makegz.phar.tar'); -@unlink(dirname(__FILE__) . '/tar_makegz2.phar.tar'); +@unlink(dirname(__FILE__) . '/tar_makegz_b.phar.tar'); ?> --EXPECTF-- bool(true) diff --git a/ext/phar/tests/tar/tar_nostub.phpt b/ext/phar/tests/tar/tar_nostub.phpt index 9b330251b4..fa4b96ebf1 100644 --- a/ext/phar/tests/tar/tar_nostub.phpt +++ b/ext/phar/tests/tar/tar_nostub.phpt @@ -1,5 +1,5 @@ --TEST-- -Phar: tar-based phar, externally created tar with no stub, Phar->getStub() +Phar: tar-based phar, third-party tar with no stub, Phar->getStub() --SKIPIF-- <?php if (!extension_loaded('phar')) die('skip'); ?> <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?> @@ -7,18 +7,19 @@ Phar: tar-based phar, externally created tar with no stub, Phar->getStub() phar.readonly=1 --FILE-- <?php -include dirname(__FILE__) . '/tarmaker.php.inc'; -$fname = dirname(__FILE__) . '/tar_004.phar'; -$pname = 'phar://' . $fname; +include dirname(__FILE__) . '/files/tarmaker.php.inc'; +$fname = dirname(__FILE__) . '/tar_004.phar.tar'; +$alias = 'phar://' . $fname; -$a = new tarmaker($fname, 'none'); -$a->init(); -$a->addFile('tar_004.php', '<?php var_dump(__FILE__);'); -$a->addFile('internal/file/here', "hi there!\n"); -$a->close(); +$tar = new tarmaker($fname, 'none'); +$tar->init(); +$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);'); +$tar->addFile('internal/file/here', "hi there!\n"); +$tar->close(); + +$phar = new Phar($fname); +var_dump($phar->getStub()); -$b = new Phar($fname); -var_dump($b->getStub()); ?> ===DONE=== --CLEAN-- @@ -27,4 +28,4 @@ var_dump($b->getStub()); ?> --EXPECTF-- string(0) "" -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/phar/tests/tar/tarmaker.php.inc b/ext/phar/tests/tar/tarmaker.php.inc deleted file mode 100644 index 902507881a..0000000000 --- a/ext/phar/tests/tar/tarmaker.php.inc +++ /dev/null @@ -1,169 +0,0 @@ -<?php -// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests -class tarmaker -{ - /** - * Path to archive file - * - * @var string - */ - protected $archive; - /** - * Temporary stream used for creating the archive - * - * @var stream - */ - protected $tmp; - protected $path; - protected $compress; - function __construct($path, $compress = 'zlib') - { - $this->compress = $compress; - if ($compress === 'bz2' && !function_exists('bzopen')) { - throw new PEAR2_Pyrus_Developer_Creator_Exception( - 'bzip2 extension not available'); - } - if ($compress === 'zlib' && !function_exists('gzopen')) { - throw new PEAR2_Pyrus_Developer_Creator_Exception( - 'zlib extension not available'); - } - $this->path = $path; - } - - /** - * save a file inside this package - * - * This code is modified from Vincent Lascaux's File_Archive - * package, which is licensed under the LGPL license. - * @param string relative path within the package - * @param string|resource file contents or open file handle - */ - function addFile($path, $fileOrStream, $stat = null) - { - clearstatcache(); - if ($stat === null) { - if (is_resource($fileOrStream)) { - $stat = fstat($fileOrStream); - } else { - $stat = array( - 'mode' => 0x8000 + 0644, - 'uid' => 0, - 'gid' => 0, - 'size' => strlen($fileOrStream), - 'mtime' => time(), - ); - } - } - - $link = null; - if ($stat['mode'] & 0x4000) { - $type = 5; // Directory - } else if ($stat['mode'] & 0x8000) { - $type = 0; // Regular - } else if ($stat['mode'] & 0xA000) { - $type = 1; // Link - $link = @readlink($current); - } else { - $type = 9; // Unknown - } - - $filePrefix = ''; - if (strlen($path) > 255) { - throw new Exception( - "$path is too long, must be 255 characters or less" - ); - } else if (strlen($path) > 100) { - $filePrefix = substr($path, 0, strlen($path)-100); - $path = substr($path, -100); - } - - $block = pack('a100a8a8a8a12A12', - $path, - decoct($stat['mode']), - sprintf('%6s ',decoct($stat['uid'])), - sprintf('%6s ',decoct($stat['gid'])), - sprintf('%11s ',decoct($stat['size'])), - sprintf('%11s ',decoct($stat['mtime'])) - ); - - $blockend = pack('a1a100a6a2a32a32a8a8a155a12', - $type, - $link, - 'ustar', - '00', - 'Pyrus', - 'Pyrus', - '', - '', - $filePrefix, - ''); - - $checkheader = array_merge(str_split($block), str_split($blockend)); - if (!function_exists('_pear2tarchecksum')) { - function _pear2tarchecksum($a, $b) {return $a + ord($b);} - } - $checksum = 256; // 8 * ord(' '); - $checksum += array_reduce($checkheader, '_pear2tarchecksum'); - - $checksum = pack('a8', sprintf('%6s ', decoct($checksum))); - - fwrite($this->tmp, $block . $checksum . $blockend, 512); - if (is_resource($fileOrStream)) { - stream_copy_to_stream($fileOrStream, $this->tmp); - if ($stat['size'] % 512) { - fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512)); - } - } else { - fwrite($this->tmp, $fileOrStream); - if (strlen($fileOrStream) % 512) { - fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512)); - } - } - } - - /** - * Initialize the package creator - */ - function init() - { - switch ($this->compress) { - case 'zlib' : - $this->tmp = gzopen($this->path, 'wb'); - break; - case 'bz2' : - $this->tmp = bzopen($this->path, 'w'); - break; - case 'none' : - $this->tmp = fopen($this->path, 'wb'); - break; - default : - throw new Exception( - 'unknown compression type ' . $this->compress); - } - } - - /** - * Create an internal directory, creating parent directories as needed - * - * @param string $dir - */ - function mkdir($dir) - { - $this->addFile($dir, "", array( - 'mode' => 0x4000 + 0644, - 'uid' => 0, - 'gid' => 0, - 'size' => 0, - 'mtime' => time(), - )); - } - - /** - * Finish saving the package - */ - function close() - { - fwrite($this->tmp, pack('a1024', '')); - fclose($this->tmp); - } -}
\ No newline at end of file |