There is ajax method, which is at the end of tojson . In the method, data is generated, then they are grouped into an array of the form $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 to test such a method using unit tests, or is it only functional tests possible?

Closed due to the fact that the essence of the question is not clear to the participants 0xdb , cheops , Kosta B. , Jarvis_J , Grundy Aug 15 '18 at 12:06 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

    0