I can't replicate ajax calls via codeception.
For example:
$I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password' => 'password'));
$I->seeResponseIsJson();
Will not raise any errors. But in the other hand, if I do the following:
$I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password' => 'password'));
$I->seeResponseIsJson();
$I->seeResponseContainsJson(['login_failed' => 1]);
//or
$I->grabDataFromJsonResponse('data.login_failed');
It gives me this error:
ErrorException: Argument 2 passed to Codeception\Module\REST::arrayHasArray() must be of the type array, null given, called in C:\xampp\htdocs\blog\laravel\vendor\codeception\codeception\src\Codeception\Module\REST.php on line 485 and defined
What I understand from the error above is that seeResponseContainsJson or grabDataFromJsonResponse internally will pass a response as a second argument to arrayHasArray. But it looks like no matter what the response is always empty.
Also, if I do the following:
$I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password' => 'password'));
var_dump($I->grabResponse());
I receive this for var_dump():
object(Codeception\Maybe)#753 (3) {
["position":protected]=>
int(0)
["val":protected]=>
NULL
["assocArray":protected]=>
NULL
}
Everything else works as expected with Codeception, I'm using PhpBrowser.