Annotation of embedaddon/php/ext/phar/tests/mounteddir.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar: mounted manifest directory test
3: --SKIPIF--
4: <?php
5: if (!extension_loaded("phar")) die("skip");
6: if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
7: ?>
8: --INI--
9: phar.readonly=0
10: --FILE--
11: <?php
12: $fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
13: $pname = 'phar://' . $fname;
14:
15: $a = new Phar($fname);
16: $a['index.php'] = '<?php
17: Phar::mount("testit", dirname(Phar::running(0)) . "/testit");
18: echo file_get_contents(Phar::running(1) . "/testit/extfile.php"), "\n";
19: echo file_get_contents(Phar::running(1) . "/testit/directory"), "\n";
20: echo file_get_contents(Phar::running(1) . "/testit/existing.txt"), "\n";
21: include "testit/extfile.php";
22: include "testit/extfile2.php";
23: try {
24: Phar::mount(".phar/stub.php", dirname(Phar::running(0)) . "/testit/extfile.php");
25: } catch (Exception $e) {
26: echo $e->getMessage(),"\n";
27: }
28: ?>';
29: $a['testit/existing.txt'] = 'oops';
30: $a->setStub('<?php
31: set_include_path("phar://" . __FILE__);
32: include "index.php";
33: __HALT_COMPILER();');
34: unset($a);
35: mkdir(dirname(__FILE__) . '/testit');
36: mkdir(dirname(__FILE__) . '/testit/directory');
37: file_put_contents(dirname(__FILE__) . '/testit/extfile.php', '<?php
38: var_dump(__FILE__);
39: ?>');
40: file_put_contents(dirname(__FILE__) . '/testit/extfile2.php', '<?php
41: var_dump(__FILE__);
42: ?>');
43: include dirname(__FILE__) . '/testit/extfile.php';
44: include $fname;
45:
46: $a = opendir($pname . '/testit');
47: $out = array();
48: while (false !== ($b = readdir($a))) {
49: $out[] = $b;
50: }
51: sort($out);
52: foreach ($out as $b) {
53: echo "$b\n";
54: }
55: $out = array();
56: foreach (new Phar($pname . '/testit') as $b) {
57: $out[] = $b->getPathName();
58: }
59: sort($out);
60: foreach ($out as $b) {
61: echo "$b\n";
62: }
63: try {
64: Phar::mount($pname . '/testit', 'another\\..\\mistake');
65: } catch (Exception $e) {
66: echo $e->getMessage(), "\n";
67: }
68: try {
69: Phar::mount($pname . '/notfound', dirname(__FILE__) . '/this/does/not/exist');
70: } catch (Exception $e) {
71: echo $e->getMessage(), "\n";
72: }
73: try {
74: Phar::mount($pname . '/testit', dirname(__FILE__));
75: } catch (Exception $e) {
76: echo $e->getMessage(), "\n";
77: }
78: try {
79: Phar::mount($pname . '/testit/extfile.php', dirname(__FILE__));
80: } catch (Exception $e) {
81: echo $e->getMessage(), "\n";
82: }
83: ?>
84: ===DONE===
85: --CLEAN--
86: <?php
87: @unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
88: @unlink(dirname(__FILE__) . '/testit/extfile.php');
89: @unlink(dirname(__FILE__) . '/testit/extfile2.php');
90: @rmdir(dirname(__FILE__) . '/testit/directory');
91: @rmdir(dirname(__FILE__) . '/testit');
92:
93: ?>
94: --EXPECTF--
95: string(%d) "%sextfile.php"
96: <?php
97: var_dump(__FILE__);
98: ?>
99:
100: Warning: file_get_contents(phar://%stempmanifest1.phar.php/testit/directory): failed to open stream: phar error: path "testit/directory" is a directory in phar://%stempmanifest1.phar.php/index.php on line %d
101:
102: oops
103: string(%d) "phar://%sextfile.php"
104: string(%d) "phar://%sextfile2.php"
105: Mounting of .phar/stub.php to %sextfile.php within phar %stests/tempmanifest1.phar.php failed
106: .
107: ..
108: directory
109: extfile.php
110: extfile2.php
111: phar://%stempmanifest1.phar.php/testit%cdirectory
112: phar://%stempmanifest1.phar.php/testit%cextfile.php
113: phar://%stempmanifest1.phar.php/testit%cextfile2.php
114: Mounting of /testit to another\..\mistake within phar %stempmanifest1.phar.php failed
115: Mounting of /notfound to %stests/this/does/not/exist within phar %stempmanifest1.phar.php failed
116: Mounting of /testit to %stests within phar %stests/tempmanifest1.phar.php failed
117: Mounting of /testit/extfile.php to %stests within phar %stests/tempmanifest1.phar.php failed
118: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>