mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Throwing and catcing an error in tests is mad
This commit is contained in:
parent
3c532cea0c
commit
90e74a608e
@ -23,29 +23,17 @@ class HTTPResponseTest extends SapphireTest
|
|||||||
$response = new HTTPResponse("Test", 200, 'OK');
|
$response = new HTTPResponse("Test", 200, 'OK');
|
||||||
|
|
||||||
// Confirm that the exception's statusCode and statusDescription take precedence
|
// Confirm that the exception's statusCode and statusDescription take precedence
|
||||||
try {
|
$e = new HTTPResponse_Exception($response, 404, 'not even found');
|
||||||
throw new HTTPResponse_Exception($response, 404, 'not even found');
|
$this->assertEquals(404, $e->getResponse()->getStatusCode());
|
||||||
} catch (HTTPResponse_Exception $e) {
|
$this->assertEquals('not even found', $e->getResponse()->getStatusDescription());
|
||||||
$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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExceptionContentPlainByDefault()
|
public function testExceptionContentPlainByDefault()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Confirm that the exception's statusCode and statusDescription take precedence
|
// Confirm that the exception's statusCode and statusDescription take precedence
|
||||||
try {
|
$e = new HTTPResponse_Exception("Some content that may be from a hacker", 404, 'not even found');
|
||||||
throw new HTTPResponse_Exception("Some content that may be from a hacker", 404, 'not even found');
|
$this->assertEquals("text/plain", $e->getResponse()->getHeader("Content-Type"));
|
||||||
} 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');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemoveHeader()
|
public function testRemoveHeader()
|
||||||
|
Loading…
Reference in New Issue
Block a user