summaryrefslogtreecommitdiff
path: root/ext/phar/tests
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-03-12 03:55:12 +0000
committerGreg Beaver <cellog@php.net>2008-03-12 03:55:12 +0000
commit0262e844c4c18a9d1b6574df444b3f6adb5f835a (patch)
tree4d9583b592f9bb5f234cacab634618f7f16838d3 /ext/phar/tests
parent70e30449bb2d55c9698eb5d0c787d20e3b5c1a23 (diff)
downloadphp-git-0262e844c4c18a9d1b6574df444b3f6adb5f835a.tar.gz
implement full support and usage of phar stream in include_path, for both 5.2 and 5.3.
5.3 code expects the proposed patch for stream wrapper in include_path to be committed 5.2 code only supports phar stream wrapper in include_path. this is a 2-step process. After this, more magic, particularly in funcinterceptors.c will be converted to use phar_resolve_path, which is far safer than the current implementation. this needs windows and 5.2 testing unix/windows
Diffstat (limited to 'ext/phar/tests')
-rw-r--r--ext/phar/tests/files/frontcontroller13.pharbin330 -> 330 bytes
-rw-r--r--ext/phar/tests/files/nophar.pharbin6965 -> 7017 bytes
-rw-r--r--ext/phar/tests/include_path.phpt34
-rw-r--r--ext/phar/tests/phar_commitwrite.phpt2
-rw-r--r--ext/phar/tests/phar_convert_repeated.phpt2
-rw-r--r--ext/phar/tests/phar_convert_repeated_b.phpt4
-rw-r--r--ext/phar/tests/phar_create_in_cwd.phpt2
-rw-r--r--ext/phar/tests/phar_createdefaultstub.phpt19
-rw-r--r--ext/phar/tests/phar_magic.phpt1
-rw-r--r--ext/phar/tests/phar_setdefaultstub.phpt17
-rw-r--r--ext/phar/tests/tar/phar_convert_phar.phpt6
-rw-r--r--ext/phar/tests/tar/phar_convert_phar2.phpt6
-rw-r--r--ext/phar/tests/tar/phar_convert_phar3.phpt6
-rw-r--r--ext/phar/tests/tar/phar_magic.phpt1
-rw-r--r--ext/phar/tests/tempmanifest1.phpt34
-rw-r--r--ext/phar/tests/zip/phar_convert_phar.phpt6
-rw-r--r--ext/phar/tests/zip/phar_magic.phpt1
17 files changed, 75 insertions, 66 deletions
diff --git a/ext/phar/tests/files/frontcontroller13.phar b/ext/phar/tests/files/frontcontroller13.phar
index 2434b1e32d..750ff27a8e 100644
--- a/ext/phar/tests/files/frontcontroller13.phar
+++ b/ext/phar/tests/files/frontcontroller13.phar
Binary files differ
diff --git a/ext/phar/tests/files/nophar.phar b/ext/phar/tests/files/nophar.phar
index 3672e4f262..ae04a15ef6 100644
--- a/ext/phar/tests/files/nophar.phar
+++ b/ext/phar/tests/files/nophar.phar
Binary files differ
diff --git a/ext/phar/tests/include_path.phpt b/ext/phar/tests/include_path.phpt
new file mode 100644
index 0000000000..a0c753ccc6
--- /dev/null
+++ b/ext/phar/tests/include_path.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Phar: include_path with phar:// wrapper
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
+$a = new Phar($fname);
+$a['file1.php'] = 'file1.php
+';
+$a['test/file1.php'] = 'test/file1.php
+';
+unset($a);
+set_include_path('.' . PATH_SEPARATOR . 'phar://' . $fname);
+include 'file1.php';
+set_include_path('.' . PATH_SEPARATOR . 'phar://' . $fname . '/test');
+include 'file1.php';
+include 'file2.php';
+?>
+===DONE===
+--CLEAN--
+<?php
+@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
+?>
+--EXPECTF--
+file1.php
+test/file1.php
+
+Warning: include(file2.php): failed to open stream: No such file or directory in %sinclude_path.php on line %d
+
+Warning: include(): Failed opening 'file2.php' for inclusion (include_path='.:phar:///home/cellog/workspace/php5/ext/phar/tests/tempmanifest1.phar.php/test') in %sinclude_path.php on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt
index 2693f0262f..63878355b0 100644
--- a/ext/phar/tests/phar_commitwrite.phpt
+++ b/ext/phar/tests/phar_commitwrite.phpt
@@ -29,7 +29,7 @@ unlink(dirname(__FILE__) . '/brandnewphar.phar');
__HALT_COMPILER();
?>
--EXPECT--
-int(6573)
+int(6651)
string(200) "<?php
function __autoload($class)
{
diff --git a/ext/phar/tests/phar_convert_repeated.phpt b/ext/phar/tests/phar_convert_repeated.phpt
index 0e3c8d9792..480d7900c7 100644
--- a/ext/phar/tests/phar_convert_repeated.phpt
+++ b/ext/phar/tests/phar_convert_repeated.phpt
@@ -115,7 +115,7 @@ string(%d) "%sphar_convert_repeated.phar.zip"
bool(true)
bool(false)
bool(false)
-int(6573)
+int(6651)
string(%d) "%sphar_convert_repeated.phar"
================= convertToZip() =====================
bool(false)
diff --git a/ext/phar/tests/phar_convert_repeated_b.phpt b/ext/phar/tests/phar_convert_repeated_b.phpt
index 28884662b3..9e5b403cc9 100644
--- a/ext/phar/tests/phar_convert_repeated_b.phpt
+++ b/ext/phar/tests/phar_convert_repeated_b.phpt
@@ -104,7 +104,7 @@ NULL
bool(true)
bool(false)
bool(false)
-int(6573)
+int(6651)
NULL
================ convertToTar(GZ) ====================
bool(false)
@@ -116,6 +116,6 @@ NULL
bool(true)
bool(false)
bool(false)
-int(6573)
+int(6651)
NULL
===DONE===
diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt
index 206a92a15f..83de7bed28 100644
--- a/ext/phar/tests/phar_create_in_cwd.phpt
+++ b/ext/phar/tests/phar_create_in_cwd.phpt
@@ -32,7 +32,7 @@ __HALT_COMPILER();
unlink(dirname(__FILE__) . '/brandnewphar.phar');
?>
--EXPECT--
-int(6573)
+int(6651)
string(200) "<?php
function __autoload($class)
{
diff --git a/ext/phar/tests/phar_createdefaultstub.phpt b/ext/phar/tests/phar_createdefaultstub.phpt
index 6569b14d46..a8648dc311 100644
--- a/ext/phar/tests/phar_createdefaultstub.phpt
+++ b/ext/phar/tests/phar_createdefaultstub.phpt
@@ -34,12 +34,13 @@ echo $e->getMessage() . "\n";
?>
===DONE===
--EXPECT--
-string(6573) "<?php
+string(6651) "<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
@@ -143,7 +144,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
-const LEN = 6575;
+const LEN = 6653;
static function go($return = false)
{
@@ -327,12 +328,13 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
-string(6584) "<?php
+string(6662) "<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
@@ -436,7 +438,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6586;
+const LEN = 6664;
static function go($return = false)
{
@@ -620,7 +622,7 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
-int(6964)
+int(7042)
============================================================================
============================================================================
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
@@ -628,12 +630,13 @@ Illegal filename passed in for stub creation, was 401 characters long, and only
============================================================================
============================================================================
============================================================================
-string(6586) "<?php
+string(6664) "<?php
$web = 'the/web.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
@@ -737,7 +740,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6588;
+const LEN = 6666;
static function go($return = false)
{
@@ -921,6 +924,6 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
-int(6964)
+int(7042)
Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE===
diff --git a/ext/phar/tests/phar_magic.phpt b/ext/phar/tests/phar_magic.phpt
index 341a36046a..f6a0a675ef 100644
--- a/ext/phar/tests/phar_magic.phpt
+++ b/ext/phar/tests/phar_magic.phpt
@@ -13,6 +13,7 @@ $p['a'] = '<?php include "b/c.php";' . "\n";
$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
$p['d'] = "in d\n";
$p->setStub('<?php
+set_include_path("phar://" . __FILE__);
include "phar://" . __FILE__ . "/a";
__HALT_COMPILER();');
include $fname;
diff --git a/ext/phar/tests/phar_setdefaultstub.phpt b/ext/phar/tests/phar_setdefaultstub.phpt
index 7e209098e2..a36c005eac 100644
--- a/ext/phar/tests/phar_setdefaultstub.phpt
+++ b/ext/phar/tests/phar_setdefaultstub.phpt
@@ -54,12 +54,13 @@ try {
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
?>
--EXPECT--
-string(6575) "<?php
+string(6653) "<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
@@ -163,7 +164,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
-const LEN = 6575;
+const LEN = 6653;
static function go($return = false)
{
@@ -348,12 +349,13 @@ __HALT_COMPILER(); ?>
"
============================================================================
============================================================================
-string(6586) "<?php
+string(6664) "<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
@@ -457,7 +459,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6586;
+const LEN = 6664;
static function go($return = false)
{
@@ -642,12 +644,13 @@ __HALT_COMPILER(); ?>
"
============================================================================
============================================================================
-string(6588) "<?php
+string(6666) "<?php
$web = 'the/web.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
+set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
@@ -751,7 +754,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
-const LEN = 6588;
+const LEN = 6666;
static function go($return = false)
{
@@ -936,6 +939,6 @@ __HALT_COMPILER(); ?>
"
============================================================================
============================================================================
-int(6966)
+int(7044)
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar.phpt b/ext/phar/tests/tar/phar_convert_phar.phpt
index 92e755bd30..9697329f1b 100644
--- a/ext/phar/tests/tar/phar_convert_phar.phpt
+++ b/ext/phar/tests/tar/phar_convert_phar.phpt
@@ -42,12 +42,12 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
-int(6573)
+int(6651)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
-int(6573)
+int(6651)
bool(true)
-int(6573)
+int(6651)
===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar2.phpt b/ext/phar/tests/tar/phar_convert_phar2.phpt
index 898accc98c..4bfda39069 100644
--- a/ext/phar/tests/tar/phar_convert_phar2.phpt
+++ b/ext/phar/tests/tar/phar_convert_phar2.phpt
@@ -45,14 +45,14 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
-int(6573)
+int(6651)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(4096)
-int(6573)
+int(6651)
bool(true)
bool(true)
-int(6573)
+int(6651)
===DONE===
diff --git a/ext/phar/tests/tar/phar_convert_phar3.phpt b/ext/phar/tests/tar/phar_convert_phar3.phpt
index 3d3b80e9d4..b8b3104a08 100644
--- a/ext/phar/tests/tar/phar_convert_phar3.phpt
+++ b/ext/phar/tests/tar/phar_convert_phar3.phpt
@@ -45,14 +45,14 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
-int(6573)
+int(6651)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(8192)
-int(6573)
+int(6651)
bool(true)
bool(true)
-int(6573)
+int(6651)
===DONE===
diff --git a/ext/phar/tests/tar/phar_magic.phpt b/ext/phar/tests/tar/phar_magic.phpt
index e2da21634f..6af907174d 100644
--- a/ext/phar/tests/tar/phar_magic.phpt
+++ b/ext/phar/tests/tar/phar_magic.phpt
@@ -14,6 +14,7 @@ $p['a'] = '<?php include "b/c.php";' . "\n";
$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
$p['d'] = "in d\n";
$p->setStub('<?php
+set_include_path("phar://" . __FILE__);
include "phar://" . __FILE__ . "/a";
__HALT_COMPILER();');
include $fname;
diff --git a/ext/phar/tests/tempmanifest1.phpt b/ext/phar/tests/tempmanifest1.phpt
deleted file mode 100644
index bff1026b1c..0000000000
--- a/ext/phar/tests/tempmanifest1.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar: temporary manifest entry test
---SKIPIF--
-<?php if (!extension_loaded("phar")) die("skip"); ?>
---INI--
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
-$a = new Phar($fname);
-$a['index.php'] = '<?php
-set_include_path("' . addslashes(dirname(__FILE__)) . '");
-include "extfile.php";
-?>';
-$a->setStub('<?php
-include "phar://" . __FILE__ . "/index.php";
-__HALT_COMPILER();');
-unset($a);
-file_put_contents(dirname(__FILE__) . '/extfile.php', '<?php
-var_dump(__FILE__);
-?>');
-include dirname(__FILE__) . '/extfile.php';
-include $fname;
-?>
-===DONE===
---CLEAN--
-<?php
-@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
-@unlink(dirname(__FILE__) . '/extfile.php');
-?>
---EXPECTF--
-string(%d) "%sextfile.php"
-string(%d) "phar://%sextfile.php"
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/zip/phar_convert_phar.phpt b/ext/phar/tests/zip/phar_convert_phar.phpt
index bf596c3a02..59aad1cdc9 100644
--- a/ext/phar/tests/zip/phar_convert_phar.phpt
+++ b/ext/phar/tests/zip/phar_convert_phar.phpt
@@ -42,12 +42,12 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
-int(6573)
+int(6651)
bool(true)
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
bool(true)
-int(6573)
+int(6651)
bool(true)
-int(6573)
+int(6651)
===DONE===
diff --git a/ext/phar/tests/zip/phar_magic.phpt b/ext/phar/tests/zip/phar_magic.phpt
index 7afcc3a56c..1ac101ec75 100644
--- a/ext/phar/tests/zip/phar_magic.phpt
+++ b/ext/phar/tests/zip/phar_magic.phpt
@@ -14,6 +14,7 @@ $p['a'] = '<?php include "b/c.php";' . "\n";
$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include dirname(__FILE__) . "/../d";';
$p['d'] = "in d\n";
$p->setStub('<?php
+set_include_path("phar://" . __FILE__);
include "phar://" . __FILE__ . "/a";
__HALT_COMPILER();');
include $fname;