Switch try/catch for exception to use expected exception and code

This commit is contained in:
Robbie Averill 2018-04-06 10:24:22 +12:00
parent afc1a3dd25
commit c0695224d6

View File

@ -330,23 +330,17 @@ class BlogTest extends SapphireTest
); );
} }
/**
* @expectedException HTTPResponse_Exception
* @expectedExceptionCode 404
*/
public function testDisabledProfiles() public function testDisabledProfiles()
{ {
Config::modify()->set(BlogController::class, 'disable_profiles', true); Config::modify()->set(BlogController::class, 'disable_profiles', true);
try { $controller = BlogController::create();
$controller = BlogController::create(); $controller->setRequest(Controller::curr()->getRequest());
$controller->setRequest(Controller::curr()->getRequest()); $controller->profile();
$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'
);
}
} }
/** /**