From 88f799be6f458f71f9df87e05d24273f9a0058b9 Mon Sep 17 00:00:00 2001 From: Jozef Selesi Date: Fri, 21 Nov 2008 21:07:36 +0000 Subject: Fixed a bug in the REST controller dispatcher and added a test case that excercises it. --- core/tests/REST_Controller_Test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'core/tests/REST_Controller_Test.php') diff --git a/core/tests/REST_Controller_Test.php b/core/tests/REST_Controller_Test.php index 72c86bda..20a5269e 100644 --- a/core/tests/REST_Controller_Test.php +++ b/core/tests/REST_Controller_Test.php @@ -54,6 +54,26 @@ class REST_Controller_Test extends Unit_Test_Case { $this->assert_equal("Mock_Model", get_class($this->mock_controller->resource)); } + public function dispatch_404_test() { + /* The dispatcher should throw a 404 if the resource isn't loaded and the method isn't POST. */ + $methods = array( + array("GET", ""), + array("POST", "PUT"), + array("POST", "DELETE")); + + foreach ($methods as $method) { + $_SERVER["REQUEST_METHOD"] = $method[0]; + $_POST["_method"] = $method[1]; + $exception_caught = false; + try { + $this->mock_not_loaded_controller->__call(rand(), ""); + } catch (Kohana_404_Exception $e) { + $exception_caught = true; + } + $this->assert_true($exception_caught, "$method[0], $method[1]"); + } + } + public function dispatch_create_test() { $_SERVER["REQUEST_METHOD"] = "POST"; $_POST["_method"] = ""; -- cgit v1.2.3