From 90e74a608e8461fcff35c7c7252023576a7088b6 Mon Sep 17 00:00:00 2001 From: Dan Hensby Date: Wed, 26 Sep 2018 23:20:23 +0100 Subject: [PATCH] Throwing and catcing an error in tests is mad --- tests/php/Control/HTTPResponseTest.php | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tests/php/Control/HTTPResponseTest.php b/tests/php/Control/HTTPResponseTest.php index 3457b6985..bdd751b19 100644 --- a/tests/php/Control/HTTPResponseTest.php +++ b/tests/php/Control/HTTPResponseTest.php @@ -23,29 +23,17 @@ class HTTPResponseTest extends SapphireTest $response = new HTTPResponse("Test", 200, 'OK'); // Confirm that the exception's statusCode and statusDescription take precedence - try { - throw new HTTPResponse_Exception($response, 404, 'not even found'); - } catch (HTTPResponse_Exception $e) { - $this->assertEquals(404, $e->getResponse()->getStatusCode()); - $this->assertEquals('not even found', $e->getResponse()->getStatusDescription()); - return; - } - // Fail if we get to here - $this->assertFalse(true, 'Something went wrong with our test exception'); + $e = new HTTPResponse_Exception($response, 404, 'not even found'); + $this->assertEquals(404, $e->getResponse()->getStatusCode()); + $this->assertEquals('not even found', $e->getResponse()->getStatusDescription()); } public function testExceptionContentPlainByDefault() { // Confirm that the exception's statusCode and statusDescription take precedence - try { - throw new HTTPResponse_Exception("Some content that may be from a hacker", 404, 'not even found'); - } catch (HTTPResponse_Exception $e) { - $this->assertEquals("text/plain", $e->getResponse()->getHeader("Content-Type")); - return; - } - // Fail if we get to here - $this->assertFalse(true, 'Something went wrong with our test exception'); + $e = new HTTPResponse_Exception("Some content that may be from a hacker", 404, 'not even found'); + $this->assertEquals("text/plain", $e->getResponse()->getHeader("Content-Type")); } public function testRemoveHeader()