我正在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".
谁能指导我如何做到这一点?