jeudi 20 août 2020

How to wrote a test for method in controller with DI?

I have invocable controller for rendering some pdf. In route I only need to pass some string as parameter and 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)?

Aucun commentaire:

Enregistrer un commentaire