1--TEST--
2PUT x-www-form-urlencoded
3--EXTENSIONS--
4zend_test
5--SKIPIF--
6<?php include "skipif.inc"; ?>
7--FILE--
8<?php
9
10require_once "tester.inc";
11
12$cfg = <<<EOT
13[global]
14error_log = {{FILE:LOG}}
15[unconfined]
16listen = {{ADDR}}
17pm = dynamic
18pm.max_children = 5
19pm.start_servers = 1
20pm.min_spare_servers = 1
21pm.max_spare_servers = 3
22EOT;
23
24$code = <<<'EOT'
25<?php
26$_POST = ['post_global'];
27$_FILES = ['files_global'];
28[$post, $files] = request_parse_body();
29echo json_encode([
30    'post' => $post,
31    'files' => $files,
32    'post_global' => $_POST,
33    'files_global' => $_FILES,
34], JSON_PRETTY_PRINT);
35EOT;
36
37$tester = new FPM\Tester($cfg, $code);
38$tester->start();
39$tester->expectLogStartNotices();
40echo $tester
41    ->request(
42        method: 'PUT',
43        headers: ['CONTENT_TYPE' => 'application/x-www-form-urlencoded'],
44        stdin: 'foo=foo&bar[]=1&bar[]=2'
45    )
46    ->getBody();
47$tester->terminate();
48$tester->expectLogTerminatingNotices();
49$tester->close();
50
51?>
52--CLEAN--
53<?php
54require_once "tester.inc";
55FPM\Tester::clean();
56$file_path = __DIR__ . '/put_multipart_uploaded_file.txt';
57@unlink($file_path);
58?>
59--EXPECT--
60{
61    "post": {
62        "foo": "foo",
63        "bar": [
64            "1",
65            "2"
66        ]
67    },
68    "files": [],
69    "post_global": [
70        "post_global"
71    ],
72    "files_global": [
73        "files_global"
74    ]
75}
76