diff --git a/lib/limonade.php b/lib/limonade.php index 076b616..4de3f99 100644 --- a/lib/limonade.php +++ b/lib/limonade.php @@ -905,13 +905,12 @@ function error_http_status($errno) function request_method($env = null) { if(is_null($env)) $env = env(); - $m = array_key_exists('REQUEST_METHOD', $env['SERVER']) ? $env['SERVER']['REQUEST_METHOD'] : null; - if($m == "POST" && array_key_exists('_method', $env['POST'])) - $m = strtoupper($env['POST']['_method']); - if(!in_array(strtoupper($m), request_methods())) + $m = isset($env['SERVER']['REQUEST_METHOD']) ? $env['SERVER']['REQUEST_METHOD'] : null; + + if($m && !in_array(strtoupper($m), request_methods())) { trigger_error("'$m' request method is unknown or unavailable.", E_USER_WARNING); - $m = false; + $m = null; } return $m; } @@ -2466,7 +2465,7 @@ function file_mime_content_type($filename) { if($finfo = finfo_open(FILEINFO_MIME)) { - if($mime = finfo_file($finfo, $filename)) + if($mime = @finfo_file($finfo, $filename)) { finfo_close($finfo); return $mime; diff --git a/lib/limonade/tests.php b/lib/limonade/tests.php index e2f43e7..ea1cff7 100644 --- a/lib/limonade/tests.php +++ b/lib/limonade/tests.php @@ -18,6 +18,7 @@ * Constants and globals */ if(!defined('DS')) define("DS", DIRECTORY_SEPARATOR); +if(!defined('TESTS_DOC_ROOT')) define('TESTS_DOC_ROOT', 'http://localhost/'); if(!array_key_exists("limonade", $GLOBALS)) $GLOBALS["limonade"] = array(); @@ -82,6 +83,9 @@ function end_test_suite() echo " Passes ".$passed_tests."/".$tests.", "; echo " {$failures} failures for {$assertions} assertions.\n"; echo test_cli_format("===========================================================\n", 'white'); + if ($failures > 0) { + exit(1); + } } /** @@ -139,6 +143,10 @@ function end_test_case() echo " {$test['failures']} failures for {$test['assertions']} assertions.\n"; echo "-----------------------------------------------------------\n"; + + if ($test['failures'] > 0) { + exit(1); + } } $GLOBALS["limonade"]["test_case_current"] = null; } @@ -164,7 +172,7 @@ function test_case_describe($msg = NULL) * Returns all user test case functions * * @access private - * @return void + * @return array */ function test_case_all_func() { @@ -195,6 +203,7 @@ function test_case_execute_current() while($func = array_shift($tests)) { test_call_func(test_before_func_name()); + echo '# ' . $func . PHP_EOL; call_user_func($func); } } diff --git a/tests/all.php b/tests/all.php index d35715c..a0bed7d 100644 --- a/tests/all.php +++ b/tests/all.php @@ -1,106 +1,8 @@