From b70e218a278d77cbdf9e4c24650a477389a38644 Mon Sep 17 00:00:00 2001 From: huzhifeng Date: Thu, 2 Mar 2017 10:03:57 +0800 Subject: [PATCH] Add tests for http request (isDelete, isGet, isPatch) --- tests/http_is_delete.phpt | 84 +++++++++++++++++++++++++++++++++++++++ tests/http_is_get.phpt | 84 +++++++++++++++++++++++++++++++++++++++ tests/http_is_patch.phpt | 84 +++++++++++++++++++++++++++++++++++++++ tests/php.ini | 1 + 4 files changed, 253 insertions(+) create mode 100644 tests/http_is_delete.phpt create mode 100644 tests/http_is_get.phpt create mode 100644 tests/http_is_patch.phpt create mode 100644 tests/php.ini diff --git a/tests/http_is_delete.phpt b/tests/http_is_delete.phpt new file mode 100644 index 00000000..526dda52 --- /dev/null +++ b/tests/http_is_delete.phpt @@ -0,0 +1,84 @@ +--TEST-- +Check isDelete +--SKIPIF-- + +--INI-- + +--FILE-- +getRequest()->isDelete()); + return false; + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . '/index.php', << array( + "directory" => APPLICATION_PATH, + ), +); +\$app = new Yaf_Application(\$config); +\$app->bootstrap()->run(); + +PHP +); + + +$handle = php_cli_server_start(null, "index.php", "-c php.ini"); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)? :80; +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +$returnStr = ''; +if(fwrite($fp, <<
+--INI-- + +--FILE-- +getRequest()->isGet()); + return false; + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . '/index.php', << array( + "directory" => APPLICATION_PATH, + ), +); +\$app = new Yaf_Application(\$config); +\$app->bootstrap()->run(); + +PHP +); + + +$handle = php_cli_server_start(null, "index.php", "-c php.ini"); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)? :80; +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +$returnStr = ''; +if(fwrite($fp, <<
+--INI-- + +--FILE-- +getRequest()->isPatch()); + return false; + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . '/index.php', << array( + "directory" => APPLICATION_PATH, + ), +); +\$app = new Yaf_Application(\$config); +\$app->bootstrap()->run(); + +PHP +); + + +$handle = php_cli_server_start(null, "index.php", "-c php.ini"); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)? :80; +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} +$returnStr = ''; +if(fwrite($fp, <<