createMock(Response::class); $response->expects($this->once()) ->method('withView') ->with('pages/design') ->willReturn($response); $request = new Request(['theme' => 42]); $config = new Config(); $controller = new DesignController($response, $config); $return = $controller->index($request); $this->assertEquals($response, $return); } /** * @covers \Engelsystem\Controllers\DesignController::index */ public function testIndexSetTheme() { /** @var Response|MockObject $response */ $response = $this->createMock(Response::class); $response->expects($this->once()) ->method('withView') ->willReturnCallback(function (string $view, array $data) use ($response) { $this->assertTrue(isset($data['theme'])); $this->assertEquals('42', $data['theme']); return $response; }); $request = new Request(); $request->attributes->set('theme', '42'); $config = new Config(['themes' => [42 => [ 'name' => 'Meaning of Live']]]); $controller = new DesignController($response, $config); $controller->index($request); } }