diff options
author | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-21 21:07:36 +0000 |
---|---|---|
committer | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-21 21:07:36 +0000 |
commit | 88f799be6f458f71f9df87e05d24273f9a0058b9 (patch) | |
tree | 5468c0b1268322fdd3aa49491ff8b7e739fd6e48 /core/tests/REST_Controller_Test.php | |
parent | 4f5e3ad6d58c40a44ee2c4da8ec15c4851e33095 (diff) |
Fixed a bug in the REST controller dispatcher and added a test case that excercises it.
Diffstat (limited to 'core/tests/REST_Controller_Test.php')
-rw-r--r-- | core/tests/REST_Controller_Test.php | 20 |
1 files changed, 20 insertions, 0 deletions
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"] = ""; |