我在我的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