mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Switch try/catch for exception to use expected exception and code
This commit is contained in:
parent
afc1a3dd25
commit
c0695224d6
@ -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'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user