Dependeny Injection on Integration Tests


How can I inject dependencies in the controller that I will test in integration tests?
I would like something similar to this in an integration test:

Inject Dependency on FooController Then

I would inject a mocked service class…

I’m currently doing it using events:

$service = $this->createMock(MyService::class);
  function ($event) use($service) {

$this->post('/controller/action', $notificationString);

But it doesn’t seem like an elegant solution.

Does the answer to this question help? I’m not sure if the controller spy will work for your scenario or not.