2
一個附加功能,我已被告知,我們也測試通過蛋糕像添加/刪除創建的功能...我如何可以測試CakePHP2.0
如果我有這樣一個功能,怎麼樣如果它沒有任何回報,重定向或甚至視圖,我可以測試它嗎? (我使用AJAX來執行它)
public function add() {
if ($this->request->is('post')) {
$this->Comment->create();
if ($this->Comment->save($this->request->data)) {
$this->Session->setFlash(__('The comment has been saved'));
} else {
$this->Session->setFlash(__('The comment could not be saved. Please, try again.'));
}
}
}
感謝
謝謝夥計!但是......這不是更好,而不是回聲? (數組('status'=>'ok')));}}; 然後正確解碼。 – Alvaro 2012-04-16 17:57:22
@Steve yup,你可以使用$ this-> response-> body()。 TNX .. – thecodeparadox 2012-04-16 17:58:32