From: Xinchen Hui Date: Tue, 20 Sep 2011 07:10:46 +0000 (+0000) Subject: Add tests for built-in webserver X-Git-Tag: php-5.4.0beta2~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00bab0493e00b5f39c71bace6ed40e6753fc0efd;p=php Add tests for built-in webserver --- diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc new file mode 100644 index 0000000000..012efa704f --- /dev/null +++ b/sapi/cli/tests/php_cli_server.inc @@ -0,0 +1,29 @@ +'); + + $descriptorspec = array( + 0 => STDIN, + 1 => STDOUT, + 2 => STDERR, + ); + + $cmd = "{$php_executable} -t {$doc_root} -S " . PHP_CLI_SERVER_ADDRESS . " {$router}"; + + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); + sleep(1); + + return $handle; +} + +function php_cli_server_shutdown($handle) { + proc_terminate($handle); + proc_close($handle); + @unlink(__DIR__ . "router.php"); + return true; +} +?> diff --git a/sapi/cli/tests/php_cli_server_001.phpt b/sapi/cli/tests/php_cli_server_001.phpt new file mode 100644 index 0000000000..69ff6a1fdc --- /dev/null +++ b/sapi/cli/tests/php_cli_server_001.phpt @@ -0,0 +1,21 @@ +--TEST-- +basic function +--INI-- +allow_url_fopen = TRUE +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(11) "Hello world" diff --git a/sapi/cli/tests/php_cli_server_002.phpt b/sapi/cli/tests/php_cli_server_002.phpt new file mode 100644 index 0000000000..02a813307d --- /dev/null +++ b/sapi/cli/tests/php_cli_server_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +$_SERVER variable +--INI-- +allow_url_fopen = TRUE +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(%d) "string(%d) "%s/tests" +string(%d) "PHP %s Development Server" +" diff --git a/sapi/cli/tests/php_cli_server_003.phpt b/sapi/cli/tests/php_cli_server_003.phpt new file mode 100644 index 0000000000..9e8e8e6527 --- /dev/null +++ b/sapi/cli/tests/php_cli_server_003.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #55726 (Changing the working directory makes router script inaccessible) +--INI-- +allow_url_fopen = 1 +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(4) "okey" +string(4) "okey"