createMock(Response::class); $response->expects($this->once()) ->method('withView') ->with('pages/design') ->willReturnCallback(function (string $view, array $data) use ($response) { $this->assertTrue(isset($data['demo_user'])); $this->assertTrue(isset($data['demo_user_2'])); $this->assertIsArray($data['themes']); return $response; }); $config = new Config(['themes' => [42 => ['name' => 'Foo']]]); $controller = new DesignController($response, $config); $return = $controller->index(); $this->assertEquals($response, $return); } }