xref: /PHP-8.4/ext/opcache/tests/issue0115.phpt (revision 326dc17b)
1--TEST--
2ISSUE #115 (path issue when using phar)
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6phar.readonly=0
7--EXTENSIONS--
8opcache
9phar
10--CONFLICTS--
11server
12--FILE--
13<?php
14$stub = '<?php
15Phar::interceptFileFuncs();
16require "phar://this/index.php";
17__HALT_COMPILER(); ?>';
18$p = new Phar(__DIR__ . '/issue0115_1.phar.php', 0, 'this');
19$p['index.php'] = '<?php
20  echo "Hello from Index 1.\n";
21  require_once "phar://this/hello.php";
22';
23$p['hello.php'] = "Hello World 1!\n";
24$p->setStub($stub);
25unset($p);
26$p = new Phar(__DIR__ . '/issue0115_2.phar.php', 0, 'this');
27$p['index.php'] = '<?php
28  echo "Hello from Index 2.\n";
29  require_once "phar://this/hello.php";
30';
31$p['hello.php'] = "Hello World 2!\n";
32$p->setStub($stub);
33unset($p);
34
35include "php_cli_server.inc";
36
37$ini = '-d opcache.enable=1 -d opcache.enable_cli=1';
38if (file_exists(ini_get('extension_dir').'/phar.'.PHP_SHLIB_SUFFIX)) {
39    $ini .= ' -d extension=phar.'.PHP_SHLIB_SUFFIX;
40}
41php_cli_server_start($ini);
42
43echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0115_1.phar.php');
44echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0115_2.phar.php');
45?>
46--CLEAN--
47<?php
48@unlink(__DIR__ . '/issue0115_1.phar.php');
49@unlink(__DIR__ . '/issue0115_2.phar.php');
50?>
51--EXPECT--
52Hello from Index 1.
53Hello World 1!
54Hello from Index 2.
55Hello World 2!
56