2
我正在爲登錄系統編寫單元測試 - 但與Zend_Session_Namespace對象交互時遇到困難。我使用PHPUnit框架的擴展Zend_Test(ZF 1.10,PHPUnit的3.4.5)Zend_Session_Namespace單元測試
測試
電流控制器/動作代碼
public function validateAction()
{
$loginSession = new Zend_Session_Namespace("login");
if (!$this->buildForm()->isValid($this->getRequest()->getPost())) {
$loginSession->messages["error"][] = "Please enter your username and password";
}
$loginSession->messages["error"][] = "Could not contact the authentication server";
$this->getResponse()
->setHttpResponseCode(303)
->setHeader("Location", "/auth/login");
}
我的單元測試是在失敗$this->assertObjectHasAttribute("messages", $loginSession);
- 但我期望它在郵件的實際內容上失敗。
我在PHPUnit的引導這些行:
Zend_Session::$_unitTestEnabled = true;
Zend_Session::start();
如何確認會話消息是否設置正確?