InvalidArgumentException: Recursion detected

Naj posted 1 year 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.

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); }

Eugene replied 1 year ago


Sign in to participate in this thread!

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