diff --git a/classes/Kohana/Unittest/Integration/TestCase.php b/classes/Kohana/Unittest/Integration/TestCase.php new file mode 100644 index 0000000..20a065b --- /dev/null +++ b/classes/Kohana/Unittest/Integration/TestCase.php @@ -0,0 +1,73 @@ + + * @copyright (c) 2008-2009 Kohana Team + * @license http://kohanaphp.com/license + */ +abstract class Kohana_Unittest_Integration_TestCase extends Unittest_TestCase { + + /** + * Assert that a given Response status match the expected value. + * + * @param integer $code expected status code + * @param Response $response Response object + * @param string $message message displayed if the test fail + */ + public function assertStatus($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->assertStatus(200, $response, $message); + } + + public function assertPermanentRedirection($location, Response $response, $message = NULL) + { + $this->assertStatus(301, $response, $message); + $this->assertEquals($location, $response->headers('Location')); + } + + public function assertTemporaryRedirection($location, Response $response, $message = NULL) + { + $this->assertStatus(302, $response, $message); + $this->assertEquals($location, $response->headers('Location')); + } + + public function assertUnauthorized(Response $response, $message = NULL) + { + $this->assertStatus(401, $response, $message); + } + + public function assertForbidden(Response $response, $message = NULL) + { + $this->assertStatus(403, $response, $message); + } + + public function assertNotFound(Response $response, $message = NULL) + { + $this->assertStatus(404, $response, $message); + } + + public function assertServiceUnavailable(Response $response, $message = NULL) + { + $this->assertStatus(503, $response, $message); + } + +} diff --git a/classes/Unittest/Integration/TestCase.php b/classes/Unittest/Integration/TestCase.php new file mode 100644 index 0000000..70539f9 --- /dev/null +++ b/classes/Unittest/Integration/TestCase.php @@ -0,0 +1,3 @@ +