]> granicus.if.org Git - php/commitdiff
Allow CLI server test scripts to specify the name of the router file.
authorAdam Harvey <aharvey@php.net>
Tue, 6 Jan 2015 01:22:59 +0000 (01:22 +0000)
committerAdam Harvey <aharvey@php.net>
Tue, 6 Jan 2015 01:22:59 +0000 (01:22 +0000)
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.)

sapi/cli/tests/bug61977.phpt
sapi/cli/tests/php_cli_server.inc
sapi/cli/tests/php_cli_server_009.phpt
sapi/cli/tests/php_cli_server_010.phpt
sapi/cli/tests/php_cli_server_013.phpt
sapi/cli/tests/php_cli_server_014.phpt

index 09a6ba6d230974aab7bb655fa97c0bc2651cee50..d897737c3c667bdb069c41b8eb0eea939a29fb90 100644 (file)
@@ -7,7 +7,7 @@ include "skipif.inc";
 --FILE--
 <?php
 include "php_cli_server.inc";
-php_cli_server_start('<?php ?>', true);
+php_cli_server_start('<?php ?>', null);
 
 /*
  * If a Mime Type is added in php_cli_server.c, add it to this array and update
index 40c53619957fd87efb7eb0583031fcb419c2bb9e..c7222b4f254206b6760c171e4476fd4797725847 100644 (file)
@@ -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) {
+function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.php') {
        $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 -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 -S " . PHP_CLI_SERVER_ADDRESS;
-               if (!$no_router) {
+               if (!is_null($router)) {
                        $cmd .= " {$router}";
                }
                $cmd .= " 2>/dev/null";
index 2beaeedab6be9fa6376111b13192552d0baddec5..5706af1c4977a5f9d143435fc7370542dbd40805 100644 (file)
@@ -10,7 +10,7 @@ include "skipif.inc";
 --FILE--
 <?php
 include "php_cli_server.inc";
-php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', TRUE);
+php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', null);
 
 list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
 $port = intval($port)?:80;
index 2ef018b8579e6c2a522c9eaee6e6107f4804e7c7..20f4e5ad9122aa85378faa495521bbc69610a7e3 100644 (file)
@@ -7,7 +7,7 @@ include "skipif.inc";
 --FILE--
 <?php
 include "php_cli_server.inc";
-php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', TRUE);
+php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', null);
 
 list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
 $port = intval($port)?:80;
index 0e3f4ff74f5b2969ddfd825fb4deb8d7867c4b76..3ea3ea9cadb0b64b6a0151f5e2df80658c4b8588 100644 (file)
@@ -7,7 +7,7 @@ include "skipif.inc";
 --FILE--
 <?php
 include "php_cli_server.inc";
-php_cli_server_start(NULL, TRUE);
+php_cli_server_start(NULL, NULL);
 
 list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
 $port = intval($port)?:80;
index e8bb5fa8a2f3c7aa08e38df26136a5f98922f916..4f812e2f63533dbc842142c01bafdf0150f92a68 100644 (file)
@@ -7,7 +7,7 @@ include "skipif.inc";
 --FILE--
 <?php
 include "php_cli_server.inc";
-php_cli_server_start('echo done, "\n";', TRUE);
+php_cli_server_start('echo done, "\n";', null);
 
 list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
 $port = intval($port)?:80;