Answer the question
In order to leave comments, you need to log in
How to call a controller method with parameters in Laravel unit tests?
Friends, hello everyone.
Can you please tell me how to call a controller method with parameters from tests?
Let's say here is an example of a controller with a method to be called for a test:
class PostController
{
public function attach($id) {
dd($id);
}
}
public function testAccountAttach()
{
$response = $this->call('GET', route('accountattach'), [
'id' => 1
]);
}
Answer the question
In order to leave comments, you need to log in
public function testAccountAttach()
{
$response = $this->call('GET', route('accountattach',[
'id' => 1
]));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question