POST
コントローラーのアクションにデータをディスパッチしています。そのアクションは、json でエンコードされた文字列をエコーします。そのアクションの json エンコードされた文字列が希望どおりであることを確認したいと思います。その文字列を取得する方法を知りたいですか?
私のテストは次のようになります。
$this->request->setMethod('POST')
->setPost(['test' => 'databaseschema_Database']);
$params = ['action' => 'analysis', 'controller' => 'Index', 'module' => 'default'];
$urlParams = $this->urlizeOptions($params);
$url = $this->url($urlParams);
$result = $this->dispatch($url);
$this->assertJsonStringEqualsJsonString(
$result, json_encode(["status" => "Success"])
);
テストが失敗し、次のメッセージが表示されます。
1) IndexControllerTest::testAnalysisAction
Expected value JSON decode error - Unknown error
stdClass Object (...) does not match expected type "NULL".
これを行う方法を教えてもらえますか?