assertHeader fails
Can anyone tell me why assertHeader and assertHeaderContains fail for me? Everything else works fine.
I have a response object that is clearly returning valid data (see below). I'm running some basic controller unit-tests against this response, all of which work, except for "assertHeader" and "assertHeaderContains".
Here's a dump of my Zend_Http_Response, without the body. This response is returned by a controller method (customer/read):
.object(Zend_Http_Response)#182 (5) {
["version":protected]=>
string(3) "1.1"
["code":protected]=>
int(200)
["message":protected]=>
string(2) "OK"
["headers":protected]=>
array(8) {
["Connection"]=>
string(5) "close"
["Date"]=>
string(29) "Thu, 27 Jan 2011 14:30:07 GMT"
["Server"]=>
string(17) "Microsoft-IIS/6.0"
["X-powered-by"]=>
string(7) "ASP.NET"
["X-aspnet-version"]=>
string(9) "2.0.50727"
["Cache-control"]=>
string(7) "private"
["Content-type"]=>
string(8) "text/xml"
["Content-length"]=>
str开发者_开发问答ing(4) "2075"
}
["body":protected]=>
Here's my unit tests:
public function testCustomerRead(){
$this->dispatch('customer/read'); // works
$this->assertResponsecode(200); // works
$this->assertController('customer'); // works
$this->assertAction('read'); // works
// FAILS with: Failed asserting response header "Content-type" found**
$this->assertHeader('Content-type');
**// FAILS with: Failed asserting response header "Content-type" exists and contains "text/xml"**
$this->assertHeaderContains('Content-type', 'text/xml');
}
Give a try to 'Content-Type'. Something like that:
$this->assertHeaderContains('Content-Type', 'text/xml');
精彩评论