summaryrefslogtreecommitdiff
path: root/sapi/cli/tests/php_cli_server.inc
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2015-01-26 11:52:53 +0100
committerOndřej Surý <ondrej@sury.org>2015-01-26 11:52:53 +0100
commit832b62efb8fceebb220116d8024d945a9bd31d7e (patch)
treee3c65d02b50180c7d7d7c21626d403d2eb87793a /sapi/cli/tests/php_cli_server.inc
parent60fede4c90746ef3408ed27a15dd405b3a46a83b (diff)
downloadphp-upstream/5.6.5+dfsg.tar.gz
New upstream version 5.6.5+dfsgupstream/5.6.5+dfsg
Diffstat (limited to 'sapi/cli/tests/php_cli_server.inc')
-rw-r--r--sapi/cli/tests/php_cli_server.inc9
1 files changed, 4 insertions, 5 deletions
diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc
index 77a79e0f0..6b1e90c4d 100644
--- a/sapi/cli/tests/php_cli_server.inc
+++ b/sapi/cli/tests/php_cli_server.inc
@@ -3,13 +3,12 @@ define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
define ("PHP_CLI_SERVER_PORT", 8964);
define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
-function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE, $cmd_args = null) {
+function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.php', $cmd_args = null) {
$php_executable = getenv('TEST_PHP_EXECUTABLE');
$doc_root = __DIR__;
- $router = "index.php";
if ($code) {
- file_put_contents($doc_root . '/' . $router, '<?php ' . $code . ' ?>');
+ file_put_contents($doc_root . '/' . ($router ?: 'index.php'), '<?php ' . $code . ' ?>');
}
$descriptorspec = array(
@@ -20,14 +19,14 @@ function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE,
if (substr(PHP_OS, 0, 3) == 'WIN') {
$cmd = "{$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
- if (!$no_router) {
+ if (!is_null($router)) {
$cmd .= " {$router}";
}
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true));
} else {
$cmd = "exec {$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS;
- if (!$no_router) {
+ if (!is_null($router)) {
$cmd .= " {$router}";
}
$cmd .= " 2>/dev/null";