From 5167ef99d3e0d3a47fa6de4db1f429971f74d838 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Tue, 25 Nov 2014 12:49:01 -0500 Subject: [PATCH] Provide basic integration testing with Request and Response objects. --- .../Kohana/Unittest/TestCase/Integration.php | 64 +++++++++++++++++++ classes/Unittest/TestCase/Integration.php | 3 + 2 files changed, 67 insertions(+) create mode 100644 classes/Kohana/Unittest/TestCase/Integration.php create mode 100644 classes/Unittest/TestCase/Integration.php diff --git a/classes/Kohana/Unittest/TestCase/Integration.php b/classes/Kohana/Unittest/TestCase/Integration.php new file mode 100644 index 0000000..f068f4f --- /dev/null +++ b/classes/Kohana/Unittest/TestCase/Integration.php @@ -0,0 +1,64 @@ + + * @copyright (c) 2008-2009 Kohana Team + * @license http://kohanaphp.com/license + */ +abstract class Kohana_Unittest_TestCase_Integration extends Unittest_TestCase { + + public function assertResponse(array $code, Response $response, $message = NULL) + { + if ($message === NULL) + { + $message = $response->body(); + } + + $this->assertEquals($code, $response->status(), $message); + } + + public function assertOk(Response $response, $message = NULL) + { + $this->assertResponse(200, $response, $message); + } + + public function assertPermanentRedirection(Response $response, $message = NULL) + { + $this->assertResponse(301, $response, $message); + } + + public function assertTemporaryRedirection(Response $response, $message = NULL) + { + $this->assertResponse(302, $response, $message); + } + + public function assertUnauthorized(Response $response, $message = NULL) + { + $this->assertResponse(401, $response, $message); + } + + public function assertForbidden(Response $response, $message = NULL) + { + $this->assertResponse(403, $response, $message); + } + + public function assertNotFound(Response $response, $message = NULL) + { + $this->assertResponse(404, $response, $message); + } + + public function assertServiceUnavailable(Response $response, $message = NULL) + { + $this->assertResponse(503, $response, $message); + } + +} diff --git a/classes/Unittest/TestCase/Integration.php b/classes/Unittest/TestCase/Integration.php new file mode 100644 index 0000000..288cf54 --- /dev/null +++ b/classes/Unittest/TestCase/Integration.php @@ -0,0 +1,3 @@ +