public function indexAction() { if (!$this->zfcUserAuthentication()->hasIdentity()) { return $this->redirect()->toRoute(static::ROUTE_LOGIN); } $viewModel = new ViewModel(['repositories' => $this->moduleService->currentUserModules()]); $viewModel->setTemplate('zfc-user/user/index'); return $viewModel; }
public function testListUserModulesDoesNotListModulesFromApiNotFoundInDatabase() { $repository = $this->repository(); $moduleMapper = $this->getMockBuilder(Mapper\Module::class)->getMock(); $moduleMapper->expects($this->once())->method('findByUrl')->with($this->equalTo($repository->html_url))->willReturn(null); $currentUserService = $this->getMockBuilder(Api\CurrentUser::class)->getMock(); $currentUserService->expects($this->once())->method('repos')->with($this->equalTo(['type' => 'all', 'per_page' => 100]))->willReturn(new Mock\Collection\RepositoryCollection([$repository])); $githubClient = $this->getMockBuilder(Client::class)->getMock(); $githubClient->expects($this->once())->method('api')->with($this->equalTo('current_user'))->willReturn($currentUserService); $service = new Service\Module($moduleMapper, $githubClient); $this->assertSame([], $service->currentUserModules()); }