imJohnBon's avatar

Json test helper not acknowledging URL params

Hey guys,

I'm currently working with Fractal to build an API in Laravel 5.3. Because of Fractal, I have URLs like so:

/users?include=comments

Which would respond with a list of users with their respective comments. Everything works fine when I test the API endpoints directly in Postman or in the browser, however when I try to write an automated test that hits a URL with one of those parameters, the response doesn't include the relationship. Like so:

    $this->json('GET', "users/{$user->id}?include=comments");

If I dump-and-die the response of that, it doesn't include the users comments. But again, if I manually test with Postman, it does work correctly. I've also tried an alternative syntax like so:

    $this->json('GET', "users/{$user->id}", ['include' => 'comments']);

However, it still doesn't work. Does anyone know how to get the JSON helper to work correctly in this situation?

0 likes
1 reply

Please or to participate in this conversation.