/** * Find mass leave requests assigned to gm * * @param User $generalManager * @param array $paginationParameters * @param array $parameters * @return Paginator */ public function findMassLeaveRequests(User $generalManager, array $paginationParameters, array $parameters) { $dq = $this->createQueryBuilder('lr'); $dq->select('lr')->where($dq->expr()->eq('lr.generalManager', '(:generalManager)'))->andWhere($dq->expr()->isNotNull('lr.leaveRequestGroup'))->andWhere($dq->expr()->eq('lr.generalManager', $generalManager->getId()))->setParameter('generalManager', $generalManager->getId()); $dq = $this->findByParams($parameters, $dq); $dq->setFirstResult($paginationParameters['firstResult']); $dq->setMaxResults($paginationParameters['maxResults']); return new Paginator($dq->getQuery(), true); }
/** * test findUsersUsingIn method */ public function testFindUsersUsingIn() { $user = $this->em->getRepository("OpitOpitHrmUserBundle:User")->findUsersUsingIn($this->user->getId()); $this->assertNotNull($user, 'testFindUsersUsingIn: The given result is null.'); }
/** * test findUserGroupsArray method */ public function testFindUserGroupsArray() { $userGroups = $this->em->getRepository("OpitOpitHrmUserBundle:Groups")->findUserGroupsArray($this->user->getId()); $this->assertNotNull($userGroups, 'testFindUserGroupsArray: The given result is null.'); }
/** * @internal */ public function setEditRights(User $user, TravelRequest $travelRequest, $isNewTravelRequest, $currentStatusId) { $isEditLocked = true; $isStatusLocked = false; $userId = $user->getId(); if (false === $isNewTravelRequest) { // the currently logged in user is always set as default $isStatusLocked = true; $isEditLocked = false; } else { if ($this->securityContext->isGranted('ROLE_ADMIN')) { $isEditLocked = false; $isStatusLocked = false; if (in_array($currentStatusId, array(Status::APPROVED, Status::REJECTED))) { $isEditLocked = true; $isStatusLocked = true; } elseif ($currentStatusId === Status::FOR_APPROVAL) { $isEditLocked = true; } } elseif ($userId === $travelRequest->getUser()->getId()) { if (Status::CREATED !== $currentStatusId && Status::REVISE !== $currentStatusId) { return false; } $isEditLocked = false; } elseif ($userId === $travelRequest->getGeneralManager()->getId()) { if (Status::FOR_APPROVAL !== $currentStatusId) { return false; } } } return array('isEditLocked' => $isEditLocked, 'isStatusLocked' => $isStatusLocked); }
/** * testing the resetPassword action. * * This should be the last method, because this is reset the password for the admin. */ public function testResetPasswordAction() { $crawler = $this->client->request('POST', '/secured/user/password/reset', array('id' => $this->user->getId())); $this->assertJson($this->client->getResponse()->getContent(), 'testResetPasswordAction: The response\'s content is not a JSON object.'); $this->assertTrue($this->client->getResponse()->headers->contains('Content-Type', 'application/json'), 'testResetPasswordAction: The content-type is not a json.'); }