我一直在看食谱上的一些例子,但我不明白: http ://book.cakephp.org/2.0/en/development/testing.html#a-more-complex-example
如何在像这样的删除操作中测试重定向?
public function delete($id = null){
$this->Comment->id = $id;
if (!$this->Comment->exists()) {
throw new NotFoundException(__('Invalid comment'));
}
if ($this->Comment->delete()) {
$this->Session->setFlash(__('Comment deleted'));
return $this->redirect(array('controller' => 'posts', 'action' => 'view', $idPost));
}
$this->Session->setFlash(__('Comment was not deleted'));
return $this->redirect(array('controller' => 'posts', 'action' => 'view', $idPost));
}
}
重定向调用后测试停止,因此它甚至不打印此回显:
public function testDelete(){
$result = $this->testAction("/comments/delete/1");
echo "this is not printed";
print_r($this->headers);
}