UniqueHope's avatar

How to test a single method on a specific controller?

I am looking for what the syntax is, maybe I'm just tired, but can't seem to find a good reference, docs or otherwise. Simple stuff in, stuff out, assert that it is what was expected. If someone could grab one of their tests to use as an example, would be much appreciated.

0 likes
5 replies
UniqueHope's avatar

There on the docs it's making a request to the route, I'd rather not have one for this method if not necessary. Is there no way to target a method directly?

SilenceBringer's avatar
Level 56

@uniquehope try

$result = app(YourController::class)->yourMethod();

then do necessary assertions with result

1 like
UniqueHope's avatar

And where should I look if the method requires Response input for giving a fake/test one?

Please or to participate in this conversation.