我有Ajax方法,以tojson结尾。在方法中,他们形成并分组为数组$ response = ['code'=> $ responseCode,'message'=> $ message];
public function recoverPasswordAjax() {
$message = _('Произошла ошибка, попробуйте еще раз.');
$responseCode = 0;
$response = [
'code' => $responseCode,
'message' => $message
];
$this->toJSON($response, true);
}
final public function toJSON($var, $send = false, $mask = 0) {
$result = toJSON($var, $mask);
if ($send) {
header('Content-Type: application/json; charset=utf-8');
print($result);
exit();
}
return $result;
}
function toJSON($var, $mask = 0) {
$result = json_encode($var, $mask);
return $result ? $result : '';
}
该如何测试或仅进行功能测试?