xref: /PHP-7.4/ext/phar/tests/zip/phar_magic.phpt (revision 26dfce7f)
1--TEST--
2Phar: include/fopen magic zip-based
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.require_hash=0
9phar.readonly=0
10--FILE--
11<?php
12$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
13$pname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
14$p = new Phar($fname);
15var_dump($p->isFileFormat(Phar::ZIP));
16$p['a'] = '<?php include "b/c.php";' . "\n";
17$p['b/c.php'] = '<?php echo "in b\n";$a = fopen("a", "r", true);echo stream_get_contents($a);fclose($a);include __DIR__ . "/../d";';
18$p['d'] = "in d\n";
19$p->setStub('<?php
20var_dump(__FILE__);
21var_dump(substr(__FILE__, 0, 4) != "phar");
22set_include_path("phar://" . __FILE__);
23include "phar://" . __FILE__ . "/a";
24__HALT_COMPILER();');
25include $pname;
26?>
27===DONE===
28--CLEAN--
29<?php
30unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php');
31__HALT_COMPILER();
32?>
33--EXPECTF--
34bool(true)
35string(%d) "%sphar_magic.phar.zip.php"
36bool(true)
37in b
38<?php include "b/c.php";
39in d
40===DONE===
41