laravel-api-debugger
laravel-api-debugger copied to clipboard
Check response data type before appending
My implementation of responses sometimes has integers as the response content. This will of course produce an error trying to access an index of an integer like an array.
I have added a check to make sure the response data is an array before trying to attach the debug property to the response.
Also: I have added a small convenience for seeing the total time of all the queries in the query collection.
@mlanin added :)
Tests are failing now :(
@mlanin looks like for some reason the $this->json()
method is returning the standard Illuminate\Http\Response
type instead of the TestResponse
, which makes sense why it can't find the assertJsonMissingExact()
method.
Did I do anything wrong in the return type?
/** @test */
public function is_does_not_add_debug_if_response_is_integer()
{
$this->app['router']->get('foo', function () {
lad('test if integer');
return response()->json(1234);
});
$this->json('get', '/foo')
->assertStatus(200)
->assertJsonMissingExact([
'debug' => [
'dump' => [
'test if integer',
]
]
]);
}
Tests are failing for php 5.6 version. The highest laravel version that supports this is 5.4.36. But this version doesn't have assertJsonMissingExact
method :(
Can we include this version requirement of laravel in composer.json then? The copy I have installed v5.7.28.
But this package supports 5.4 version. Your PR is really good, please, adjust your test and I'll merge it asap :)
But this package supports 5.4 version. Your PR is really good, please, adjust your test and I'll merge it asap :)
I've updated the composer.json
to use version of packages that are compatible with your requirements so composer doesn't try to install a newer version. I also added requirements for sqlite
since it was missing from my machine and the tests were failing (Ubuntu 19).
Closing from lack of activity from the maintainer. Feel free to reopen if you want it merged.