initDatabase(); (new Faq(['question' => 'Xyz', 'text' => 'Abc']))->save(); (new Faq(['question' => 'Something\'s wrong?', 'text' => 'Nah!']))->save(); $this->app->instance('session', new Session(new MockArraySessionStorage())); $config = new Config(['faq_text' => 'Some Text']); /** @var Response|MockObject $response */ $response = $this->createMock(Response::class); $response->expects($this->once()) ->method('withView') ->willReturnCallback(function (string $view, array $data) use ($response) { $this->assertEquals('pages/faq/overview.twig', $view); $this->assertEquals('Some Text', $data['text']); $this->assertEquals('Nah!', $data['items'][0]->text); return $response; }); $controller = new FaqController($config, new Faq(), $response); $controller->index(); } }