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