createMock(Response::class); /** @var SessionInterface|MockObject $session */ $session = $this->getMockForAbstractClass(SessionInterface::class); /** @var UrlGeneratorInterface|MockObject $url */ $url = $this->getMockForAbstractClass(UrlGeneratorInterface::class); $session->expects($this->once()) ->method('invalidate'); $response->expects($this->once()) ->method('redirectTo') ->with('https://foo.bar/'); $url->expects($this->once()) ->method('to') ->with('/') ->willReturn('https://foo.bar/'); $controller = new AuthController($response, $session, $url); $controller->logout(); } }