mirror of
https://github.com/php/php-src.git
synced 2024-12-15 12:54:57 +08:00
Added tests that demonstrate serious PHAR errors
They cannot be easly fixed without algorithms modification
This commit is contained in:
parent
53bbf1238c
commit
d82b5d59b4
32
ext/phar/tests/rename_dir.phpt
Normal file
32
ext/phar/tests/rename_dir.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Phar: rename_dir test
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?php
|
||||
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
|
||||
$pname = 'phar://' . $fname;
|
||||
$file = "<?php
|
||||
Phar::mapPhar('hio');
|
||||
__HALT_COMPILER(); ?>";
|
||||
|
||||
$files = array();
|
||||
$files['a/x'] = 'a';
|
||||
include 'files/phar_test.inc';
|
||||
include $fname;
|
||||
|
||||
echo file_get_contents($pname . '/a/x') . "\n";
|
||||
rename($pname . '/a', $pname . '/b');
|
||||
echo file_get_contents($pname . '/b/x') . "\n";
|
||||
echo file_get_contents($pname . '/a/x') . "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
|
||||
--EXPECTF--
|
||||
a
|
||||
a
|
||||
|
||||
Warning: file_get_contents(phar://%srename.phar.php/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d
|
30
ext/phar/tests/rmdir.phpt
Normal file
30
ext/phar/tests/rmdir.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Phar: rmdir test
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?php
|
||||
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
|
||||
$pname = 'phar://' . $fname;
|
||||
$file = "<?php
|
||||
Phar::mapPhar('hio');
|
||||
__HALT_COMPILER(); ?>";
|
||||
|
||||
$files = array();
|
||||
$files['a/x'] = 'a';
|
||||
include 'files/phar_test.inc';
|
||||
include $fname;
|
||||
|
||||
echo file_get_contents($pname . '/a/x') . "\n";
|
||||
rmdir($pname . '/a');
|
||||
echo file_get_contents($pname . '/a/x') . "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
|
||||
--EXPECTF--
|
||||
a
|
||||
|
||||
Warning: file_get_contents(phar://%srename.phar.php/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d
|
42
ext/phar/tests/tar/rename_dir.phpt
Normal file
42
ext/phar/tests/tar/rename_dir.phpt
Normal file
@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
Phar: rename_dir test tar-based
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?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/x'] = 'a';
|
||||
|
||||
foreach ($files as $n => $file) {
|
||||
$tar->addFile($n, $file);
|
||||
}
|
||||
|
||||
$tar->close();
|
||||
|
||||
include $fname;
|
||||
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
rename($alias . '/a', $alias . '/b');
|
||||
echo file_get_contents($alias . '/b/x') . "\n";
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
|
||||
--EXPECTF--
|
||||
a
|
||||
a
|
||||
|
||||
Warning: file_get_contents(phar://%srename.phar.tar/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d
|
40
ext/phar/tests/tar/rmdir.phpt
Normal file
40
ext/phar/tests/tar/rmdir.phpt
Normal file
@ -0,0 +1,40 @@
|
||||
--TEST--
|
||||
Phar: rmdir test tar-based
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?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/x'] = 'a';
|
||||
|
||||
foreach ($files as $n => $file) {
|
||||
$tar->addFile($n, $file);
|
||||
}
|
||||
|
||||
$tar->close();
|
||||
|
||||
include $fname;
|
||||
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
rmdir($alias . '/a');
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
|
||||
--EXPECTF--
|
||||
a
|
||||
|
||||
Warning: file_get_contents(phar://%srename.phar.tar/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d
|
34
ext/phar/tests/zip/rename_dir.phpt
Normal file
34
ext/phar/tests/zip/rename_dir.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Phar: rename_dir test zip-based
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
|
||||
$alias = 'phar://' . $fname;
|
||||
|
||||
$phar = new Phar($fname);
|
||||
$phar->setStub("<?php
|
||||
Phar::mapPhar('hio');
|
||||
__HALT_COMPILER(); ?>");
|
||||
$phar['a/x'] = 'a';
|
||||
$phar->stopBuffering();
|
||||
|
||||
include $fname;
|
||||
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
rename($alias . '/a', $alias . '/b');
|
||||
echo file_get_contents($alias . '/b/x') . "\n";
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
|
||||
--EXPECTF--
|
||||
a
|
||||
a
|
||||
|
||||
Warning: file_get_contents(phar://%srename.phar.zip/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.zip" in %srename.php on line %d
|
32
ext/phar/tests/zip/rmdir.phpt
Normal file
32
ext/phar/tests/zip/rmdir.phpt
Normal file
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Phar: rmdir test zip-based
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
phar.require_hash=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
|
||||
$alias = 'phar://' . $fname;
|
||||
|
||||
$phar = new Phar($fname);
|
||||
$phar->setStub("<?php
|
||||
Phar::mapPhar('hio');
|
||||
__HALT_COMPILER(); ?>");
|
||||
$phar['a/x'] = 'a';
|
||||
$phar->stopBuffering();
|
||||
|
||||
include $fname;
|
||||
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
rmdir($alias . '/a');
|
||||
echo file_get_contents($alias . '/a/x') . "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
|
||||
--EXPECTF--
|
||||
a
|
||||
|
||||
Warning: file_get_contents(phar://%srename.phar.zip/a/x): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.zip" in %srename.php on line %d
|
Loading…
Reference in New Issue
Block a user