2010-11-23 20:38:15 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2010-11-23 20:38:15 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class HTTPResponseTest extends SapphireTest {
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testStatusDescriptionStripsNewlines() {
|
2010-11-23 20:38:15 +01:00
|
|
|
$r = new SS_HTTPResponse('my body', 200, "my description \nwith newlines \rand carriage returns");
|
|
|
|
$this->assertEquals(
|
|
|
|
"my description with newlines and carriage returns",
|
|
|
|
$r->getStatusDescription()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testContentLengthHeader() {
|
2011-07-26 08:25:09 +02:00
|
|
|
$r = new SS_HTTPResponse('123ü');
|
|
|
|
$this->assertNotNull($r->getHeader('Content-Length'), 'Content-length header is added');
|
|
|
|
$this->assertEquals(
|
|
|
|
5,
|
|
|
|
$r->getHeader('Content-Length'),
|
|
|
|
'Header matches actual content length in bytes'
|
|
|
|
);
|
|
|
|
|
|
|
|
$r->setBody('1234ü');
|
|
|
|
$this->assertEquals(
|
|
|
|
6,
|
|
|
|
$r->getHeader('Content-Length'),
|
|
|
|
'Header is updated when body is changed'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|