Skip to content

Commit 0cc2810

Browse files
committed
Allow CLI server test scripts to specify the name of the router file.
This is required to write tests that behave differently when an index.php isn't present in the document root. (Such as the one I'm about to commit.)
1 parent 339139f commit 0cc2810

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

sapi/cli/tests/bug61977.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include "skipif.inc";
77
--FILE--
88
<?php
99
include "php_cli_server.inc";
10-
php_cli_server_start('<?php ?>', true);
10+
php_cli_server_start('<?php ?>', null);
1111

1212
/*
1313
* If a Mime Type is added in php_cli_server.c, add it to this array and update

sapi/cli/tests/php_cli_server.inc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
33
define ("PHP_CLI_SERVER_PORT", 8964);
44
define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
55

6-
function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE) {
6+
function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.php') {
77
$php_executable = getenv('TEST_PHP_EXECUTABLE');
88
$doc_root = __DIR__;
9-
$router = "index.php";
109

1110
if ($code) {
12-
file_put_contents($doc_root . '/' . $router, '<?php ' . $code . ' ?>');
11+
file_put_contents($doc_root . '/' . ($router ?: 'index.php'), '<?php ' . $code . ' ?>');
1312
}
1413

1514
$descriptorspec = array(
@@ -20,14 +19,14 @@ function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE)
2019

2120
if (substr(PHP_OS, 0, 3) == 'WIN') {
2221
$cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS;
23-
if (!$no_router) {
22+
if (!is_null($router)) {
2423
$cmd .= " {$router}";
2524
}
2625

2726
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
2827
} else {
2928
$cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CLI_SERVER_ADDRESS;
30-
if (!$no_router) {
29+
if (!is_null($router)) {
3130
$cmd .= " {$router}";
3231
}
3332
$cmd .= " 2>/dev/null";

sapi/cli/tests/php_cli_server_009.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include "skipif.inc";
1010
--FILE--
1111
<?php
1212
include "php_cli_server.inc";
13-
php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', TRUE);
13+
php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', null);
1414

1515
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
1616
$port = intval($port)?:80;

sapi/cli/tests/php_cli_server_010.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include "skipif.inc";
77
--FILE--
88
<?php
99
include "php_cli_server.inc";
10-
php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', TRUE);
10+
php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', null);
1111

1212
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
1313
$port = intval($port)?:80;

sapi/cli/tests/php_cli_server_013.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include "skipif.inc";
77
--FILE--
88
<?php
99
include "php_cli_server.inc";
10-
php_cli_server_start(NULL, TRUE);
10+
php_cli_server_start(NULL, NULL);
1111

1212
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
1313
$port = intval($port)?:80;

sapi/cli/tests/php_cli_server_014.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include "skipif.inc";
77
--FILE--
88
<?php
99
include "php_cli_server.inc";
10-
php_cli_server_start('echo done, "\n";', TRUE);
10+
php_cli_server_start('echo done, "\n";', null);
1111

1212
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
1313
$port = intval($port)?:80;

0 commit comments

Comments
 (0)