ajax 経由で jquery によって呼び出されるアクションのテストの作成に問題があります。アクションによってビューに送り返されているデータをキャッチする方法がわからないので、それが正しいかどうかをアサートできます。私の $.ajax(...) スクリプトは、コントローラーによってエコーされた結果を textarea 要素に挿入しますが、テスト スクリプトでは、結果は null です。失敗メッセージ:
Failed asserting that null matches expected '...
これまでの私のテストコードは次のとおりです。
$this->getRequest()->setRawBody('some json containing input params im testing');
$this->getRequest()->setMethod('GET');
$this->getRequest->setHeader('HTTP_X_REQUESTED_WITH','XMLHttpRequest');
$this->dispatch('my url');
$result = json_decode($this->getResponse()->getBody(),true);
$expectedResult = 'some string';
$this->assertEquals($expectedResult, $result['targeted element']);