Query params being ignored when integration testing a JSON API
I'm trying to build integration tests for a JSON API where the response is paginated. Calling the endpoint with postman shows the endpoint paginates just fine if I add ?limit=1&page=2 to the URL.
I can get the integration tests working fine with no query params but if I add any query params at all, they get completely ignore. An example test is:
$this->get('http://api.eventhq8.dev/webhooks?limit=1&page=1') ->shouldReturnJson() ->seeStatusCode(200) // check for correct pagination params ->seeJson(['count' => 1, 'current_page' => 1, 'per_page' => 1, 'total' => 2, 'total_pages' => 2]);
and the underlying endpoint (webhooks/index) is
public function index() {
// exclude records associated with an Event
$this->webhook->pushCriteria(new EventIdCriteria(null));
// exclude records associated with an Integration
$this->webhook->pushCriteria(new IntegrationIdCriteria(null));
return $this->response
->setStatusCode(200)
->setContent($this->webhook->paginate());
}
Digging through the code, the params get passed along as part of the URL to the call() function, but always as part of the URL, never in the parameters array. I lose track after a while though as the calls go to deep into the guts of laravel and Symfony for me to follow.
Any ideas?
Please or to participate in this conversation.