Skip to content

Commit f86f3ed

Browse files
committed
Migrate fpm_get_status test
1 parent 140def4 commit f86f3ed

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

sapi/fpm/tests/025.phpt renamed to sapi/fpm/tests/fpm_get_status_basic.phpt

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
--TEST--
2-
FPM: Test fpm_get_status function
2+
FPM: Function fpm_get_status basic test
33
--SKIPIF--
44
<?php include "skipif.inc"; ?>
55
--FILE--
66
<?php
77

8-
include "include.inc";
9-
10-
$logfile = __DIR__.'/php-fpm.log.tmp';
11-
$srcfile = __DIR__.'/php-fpm.tmp.php';
12-
$port = 9000+PHP_INT_SIZE;
8+
require_once "tester.inc";
139

1410
$cfg = <<<EOT
1511
[global]
16-
error_log = $logfile
12+
error_log = {{FILE:LOG}}
1713
[unconfined]
18-
listen = 127.0.0.1:$port
14+
listen = {{ADDR}}
1915
pm = dynamic
2016
pm.max_children = 5
2117
pm.start_servers = 1
@@ -29,29 +25,19 @@ echo "Test Start\n";
2925
var_dump(fpm_get_status());
3026
echo "Test End\n";
3127
EOT;
32-
file_put_contents($srcfile, $code);
3328

34-
$fpm = run_fpm($cfg, $tail);
35-
if (is_resource($fpm)) {
36-
fpm_display_log($tail, 2);
37-
try {
38-
$req = run_request('127.0.0.1', $port, $srcfile);
39-
echo strstr($req, "Test Start");
40-
echo "Request ok\n";
41-
} catch (Exception $e) {
42-
echo "Request error\n";
43-
}
44-
proc_terminate($fpm);
45-
fpm_display_log($tail, -1);
46-
fclose($tail);
47-
proc_close($fpm);
48-
}
29+
$headers = [];
30+
$tester = new FPM\Tester($cfg, $code);
31+
$tester->start();
32+
$tester->expectLogStartNotices();
33+
$tester->request()->printBody();
34+
$tester->terminate();
35+
$tester->expectLogTerminatingNotices();
36+
$tester->close();
4937

5038
?>
5139
Done
5240
--EXPECTF--
53-
[%s] NOTICE: fpm is running, pid %d
54-
[%s] NOTICE: ready to handle connections
5541
Test Start
5642
array(15) {
5743
["pool"]=>
@@ -118,15 +104,9 @@ array(15) {
118104
}
119105
}
120106
Test End
121-
122-
Request ok
123-
[%s] NOTICE: Terminating ...
124-
[%s] NOTICE: exiting, bye-bye!
125107
Done
126108
--CLEAN--
127109
<?php
128-
$logfile = __DIR__.'/php-fpm.log.tmp';
129-
$srcfile = __DIR__.'/php-fpm.tmp.php';
130-
@unlink($logfile);
131-
@unlink($srcfile);
110+
require_once "tester.inc";
111+
FPM\Tester::clean();
132112
?>

sapi/fpm/tests/response.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Response
124124
*/
125125
public function printBody()
126126
{
127-
echo $this->getBody();
127+
echo $this->getBody() . "\n";
128128
}
129129

130130
/**

0 commit comments

Comments
 (0)