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
1 changed files with 7 additions and 13 deletions

View File

@ -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();
}
/**