Skip to content

Commit 6ab4e33

Browse files
committed
Use ephemeral port in more server tests
Port the main php_cli_server.inc to use ephemeral ports, thus allowing CLI server tests to be parallelized. A complication here is that we also need to give each test a separate doc root, to avoid index.php files writing over each other. Closes GH-6375.
1 parent 3859e74 commit 6ab4e33

15 files changed

+89
-97
lines changed

ext/soap/tests/bug73037.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Bug #73037 SoapServer reports Bad Request when gzipped, var 0
3-
--CONFLICTS--
4-
server
53
--SKIPIF--
64
<?php
75
require_once('skipif.inc');

ext/soap/tests/custom_content_type.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ SOAP customized Content-Type, eg. SwA use case
88
echo "skip sapi/cli/tests/php_cli_server.inc required but not found";
99
}
1010
?>
11-
--CONFLICTS--
12-
server
1311
--FILE--
1412
<?php
1513

ext/standard/tests/streams/bug64433.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ if(!$res) {
99
die("skip could not open cli server script");
1010
}
1111
?>
12-
--CONFLICTS--
13-
server
1412
--FILE--
1513
<?php
1614
include __DIR__."/../../../../sapi/cli/tests/php_cli_server.inc";

ext/standard/tests/url/get_headers_error_003.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Test get_headers() function : test with context
3-
--CONFLICTS--
4-
server
53
--FILE--
64
<?php
75

sapi/cli/tests/CONFLICTS

Lines changed: 0 additions & 1 deletion
This file was deleted.

sapi/cli/tests/bug61977.phpt

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,37 @@ include "skipif.inc";
77
--FILE--
88
<?php
99
include "php_cli_server.inc";
10-
php_cli_server_start('<?php ?>', null);
10+
$doc_root = php_cli_server_start('<?php ?>', null)->docRoot;
1111

1212
/*
1313
* If a Mime Type is added in php_cli_server.c, add it to this array and update
1414
* the EXPECTF section accordingly
1515
*/
1616
$mimetypes = ['html', 'htm', 'svg', 'css', 'js', 'png', 'webm', 'ogv', 'ogg'];
1717

18-
function test_mimetypes($mimetypes) {
19-
foreach ($mimetypes as $mimetype) {
20-
$host = PHP_CLI_SERVER_HOSTNAME;
21-
$fp = php_cli_server_connect();
22-
if (!$fp) die('Connect failed');
23-
file_put_contents(__DIR__ . "/foo.{$mimetype}", '');
24-
$header = <<<HEADER
18+
foreach ($mimetypes as $mimetype) {
19+
$host = PHP_CLI_SERVER_HOSTNAME;
20+
$fp = php_cli_server_connect();
21+
if (!$fp) die('Connect failed');
22+
file_put_contents($doc_root . "/foo.{$mimetype}", '');
23+
$header = <<<HEADER
2524
GET /foo.{$mimetype} HTTP/1.1
2625
Host: {$host}
2726
2827
2928
HEADER;
30-
if (fwrite($fp, $header)) {
31-
while (!feof($fp)) {
32-
$text = fgets($fp);
33-
if (strncasecmp("Content-type:", $text, 13) == 0) {
34-
echo "foo.{$mimetype} => ", $text;
35-
}
29+
if (fwrite($fp, $header)) {
30+
while (!feof($fp)) {
31+
$text = fgets($fp);
32+
if (strncasecmp("Content-type:", $text, 13) == 0) {
33+
echo "foo.{$mimetype} => ", $text;
3634
}
37-
@unlink(__DIR__ . "/foo.{$mimetype}");
38-
fclose($fp);
3935
}
36+
@unlink($doc_root . "/foo.{$mimetype}");
37+
fclose($fp);
4038
}
4139
}
4240

43-
test_mimetypes($mimetypes);
4441
?>
4542
--EXPECT--
4643
foo.html => Content-Type: text/html; charset=UTF-8

sapi/cli/tests/bug67429_1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include "skipif.inc";
88
<?php
99
include "php_cli_server.inc";
1010

11-
$proc_handle = php_cli_server_start(<<<PHP
11+
php_cli_server_start(<<<PHP
1212
http_response_code(308);
1313
PHP
1414
);

sapi/cli/tests/bug67429_2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include "skipif.inc";
88
<?php
99
include "php_cli_server.inc";
1010

11-
$proc_handle = php_cli_server_start(<<<PHP
11+
php_cli_server_start(<<<PHP
1212
http_response_code(426);
1313
PHP
1414
);

sapi/cli/tests/bug68291.phpt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ include "skipif.inc";
99
--FILE--
1010
<?php
1111
include "php_cli_server.inc";
12-
file_put_contents(__DIR__ . '/bug68291+test.html', 'Found');
13-
php_cli_server_start(NULL, NULL);
12+
$docRoot = php_cli_server_start(NULL, NULL)->docRoot;
13+
file_put_contents($docRoot . '/bug68291+test.html', 'Found');
1414
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/bug68291+test.html');
15-
?>
16-
--CLEAN--
17-
<?php
18-
@unlink(__DIR__ . '/bug68291+test.html');
15+
@unlink($docRoot . '/bug68291+test.html');
1916
?>
2017
--EXPECT--
2118
Found

sapi/cli/tests/bug69655.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ foreach (['MKCO', 'MKCOLL', 'M'] as $method) {
1717
}
1818
?>
1919
--EXPECTF--
20-
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
20+
Warning: file_get_contents(http://localhost:%d): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
2121
in %s on line %d
2222

23-
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
23+
Warning: file_get_contents(http://localhost:%d): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
2424
in %s on line %d
2525

26-
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
26+
Warning: file_get_contents(http://localhost:%d): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
2727
in %s on line %d

0 commit comments

Comments
 (0)