I have a API endpoint that I wish to test, it receives a POST payload. The endpoint basically invokes the Omnipay Sage Pay library to handle a Server Notification.
I can POST to this endpoint using Postman client fine, but when using a Laravel phpunit test e.g.
$response = $this->post($url, $data);
The Omnipay library can't see the post data?
I think this is because the Laravel helper $this->post
doesn't use application/x-www-form-urlencoded POST requests? I took a look behind the scenes at $this->post
and it seems to invoke the controllers/methods directly which makes sense..
The closest I got to this working was using Guzzle directly (See below), however this routes the request outside of the 'testing' session and back into my local application I'm assuming? This then breaks my tests as I'm setting up some testing data via factories before the POST call.
$response = $client->request('POST', $url, ['form_params' => $data]);
I'm not too sure where the issue lies, either in my tests or the Omnipay library itself?
Aucun commentaire:
Enregistrer un commentaire