I have Ajax method, which end with tojson. In method they formed and group to array $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 : '';
}
How testin that or only functional testing?
Aucun commentaire:
Enregistrer un commentaire