From c0695224d6307b4c5c25f0f7a6e8a98d57387f22 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 6 Apr 2018 10:24:22 +1200 Subject: [PATCH] Switch try/catch for exception to use expected exception and code --- tests/BlogTest.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/BlogTest.php b/tests/BlogTest.php index 3238a86..59c93e9 100755 --- a/tests/BlogTest.php +++ b/tests/BlogTest.php @@ -330,23 +330,17 @@ class BlogTest extends SapphireTest ); } + /** + * @expectedException HTTPResponse_Exception + * @expectedExceptionCode 404 + */ public function testDisabledProfiles() { Config::modify()->set(BlogController::class, 'disable_profiles', true); - try { - $controller = BlogController::create(); - $controller->setRequest(Controller::curr()->getRequest()); - $controller->profile(); - - $this->fail('The "profile" action should throw a HTTPResponse_Exception when disable_profiles is enabled'); - } catch (HTTPResponse_Exception $e) { - $this->assertEquals( - 404, - $e->getResponse()->getStatusCode(), - 'The response status code should be 404 Not Found' - ); - } + $controller = BlogController::create(); + $controller->setRequest(Controller::curr()->getRequest()); + $controller->profile(); } /**