我在我的Zend Framework应用程序上运行一些单元测试。我无法理解的是,下面的测试失败:Zend Framework单元测试失败assertResponseCode(200)
public function testCreateFaqItem()
{
$this->LoginUser();
$this->dispatch('/faq/admin-faq/create');
var_dump($this->getResponse());
$this->assertResponseCode(200);
$this->assertQueryContentContains('h1', 'Create');
$this->assertController('admin-faq');
$this->assertAction('edit');
}
,如果在assertResponseCode(200),当我删除assertResponseCode(200),测试通过失败。任何帮助都感激不尽。
- 编辑 -
Response对象转储:
object(Zend_Controller_Response_HttpTestCase)#1130 (8) {
["_body":protected]=>
array(1) {
["default"]=>
string(0) ""
}
["_exceptions":protected]=>
array(0) {
}
["_headers":protected]=>
array(1) {
[0]=>
array(3) {
["name"]=>
string(8) "Location"
["value"]=>
string(13) "/user/profile"
["replace"]=>
bool(true)
}
}
["_headersRaw":protected]=>
array(0) {
}
["_httpResponseCode":protected]=>
int(302)
["_isRedirect":protected]=>
bool(true)
["_renderExceptions":protected]=>
bool(false)
["headersSentThrowsException"]=>
bool(true)
}
感谢
什么是实际的响应代码? – ircmaxell 2010-12-16 20:19:42
我发现实际的响应代码是302,不知道为什么:( – 2010-12-16 20:36:38