I have a Laravel controller with DI in
__construct(Model1 $m1, Model2 $m2, $SomeService $s) {
$this->m1 = $m1;
$this->m2 = $m2;
$this->s = $s;
}
I have an API test with call or endpoint based on this controller. I'm doing 8 same API url calls with different payload. It seems z controller constructor process 1 time and after that works with constructed dependencies.
$response1 = $this->actingAs($admin,'api')->json('POST', '/api/someURL', $payload1);
$response2 = $this->actingAs($admin,'api')->json('POST', '/api/someURL', $payload2);
$responseN = $this->actingAs($admin,'api')->json('POST', '/api/someURL', $payloadN);
Can I somehow set dependencies before each API call in test?