Level 80
@knubbe What have you tried?
Controller dependencies are resolved by the container. You can mock services in the container in Laravel: https://laravel.com/docs/7.x/mocking#mocking-objects
I have invocable controller for rendering some pdf. In route I only need to pass some string as parameter but my method look like this:
public function __invoke(
Request $request,
IncidentPdfGenerationService $incidentPdfGenerationService,
string $report
) {
$pdf = $incidentPdfGenerationService->getRawPdf($request, $report);
$name = $report . '.pdf';
return $pdf->stream($name);
}
IncidentPdfGenerationService is a interface and I bind that in service provider.
How to wrote a test to check this route with only assertStatus(200)?
Please or to participate in this conversation.