テストで時々問題が発生します。テストが実行され、アクションの結果を取得することもできますが、テストが正常に実行されたかどうかを示す緑または赤のメッセージがテストに表示されません。(28/28 のテスト メソッドが完了しました: 28 回のパス、0 回の失敗、95 回のアサーション、0 回の例外...)、時間、ピーク メモリなど。
例えば。このテストを実行しようとした場合にのみ、クラッシュします:
public function testGetHotVideo() {
$result = $this->testAction("/posts/getHotVideo/");
$this->assertEquals($result, 'GoG_Tv5G17M');
}
このメソッドを呼び出します。
public function getHotVideo(){
$video = $this->Post->getHotVideo();
return $video[0][0]['video'];
}
そして、ビデオ文字列を正しく返します。したがって、テスト変数 $result に出力することもできます。
何が起きてる?
アップデート
ビューにリダイレクトするメソッドを呼び出すと、同じことが発生することにも気付きました。この場合、Cake Bake で作成されたデフォルトの削除を使用します。
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' => 'index'));
}
$this->Session->setFlash(__('Comment was not deleted'));
return $this->redirect(array('controller' => 'posts', 'action' => 'index'));
}