Back

InvalidArgumentException: Recursion detected


Naj posted 1 month ago

I was reading the book Lumen Programming Guide by Paul Redmond which is really a great book. I was on Chapter 6: Responding to error page 81 which I've stumbled upon. It's the part where the show method of the BookController is being tested. I'm new to testing so I'm scratching my head about that Exception.

Code is like this.
https://paste.laravel.io/ca20c2f6-1e62-4039-90a0-c1fae8bac4c3

Basically when I run phpunit it says recursion detected. It started when I change the show method to just return Book::findOrFail($id) from ``` try { return Book::findOrFail($id);
} catch (ModelNotFoundException $e) { return response()->json([ 'error' => [ 'message' => 'Book not found' ] ], 404); }


Thanks
Eugene replied 1 week ago

+1


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us