1--TEST--
2FPM: FastCGI env var path info fix for Apache handler basic
3--SKIPIF--
4<?php
5include "skipif.inc";
6if (ini_get('doc_root')) {
7    die('skip: The doc_root ini has to be unset for this test to work');
8}
9?>
10--FILE--
11<?php
12
13require_once "tester.inc";
14
15$cfg = <<<EOT
16[global]
17error_log = {{FILE:LOG}}
18[unconfined]
19listen = {{ADDR}}
20pm = dynamic
21pm.max_children = 5
22pm.start_servers = 1
23pm.min_spare_servers = 1
24pm.max_spare_servers = 3
25php_admin_value[cgi.fix_pathinfo] = yes
26EOT;
27
28$code = <<<EOT
29<?php
30echo \$_SERVER["SCRIPT_NAME"] . "\n";
31echo \$_SERVER["SCRIPT_FILENAME"] . "\n";
32echo \$_SERVER["PATH_INFO"] . "\n";
33echo \$_SERVER["PHP_SELF"];
34EOT;
35
36$tester = new FPM\Tester($cfg, $code);
37[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
38$tester->start();
39$tester->expectLogStartNotices();
40$tester
41    ->request(
42        headers: [
43            'PATH_INFO' => '/pinfo',
44            'PATH_TRANSLATED' => __DIR__ . '/pinfo',
45            'DOCUMENT_ROOT' => null,
46        ],
47        uri: $scriptName . '/pinfo',
48        scriptFilename: "proxy:fcgi://" . $tester->getAddr() . $sourceFilePath,
49        scriptName: $scriptName,
50    )
51    ->expectBody([$scriptName, $sourceFilePath, '/pinfo', $scriptName . '/pinfo']);
52$tester->terminate();
53$tester->close();
54
55?>
56Done
57--EXPECT--
58Done
59--CLEAN--
60<?php
61require_once "tester.inc";
62FPM\Tester::clean();
63?>
64