Example #1
0
 /**
  * testing adduser action.
  */
 public function testAddUserAction()
 {
     $crawler = $this->client->request('POST', '/secured/user/add/' . $this->user->getId());
     $this->assertTrue($this->client->getResponse()->headers->contains('Content-Type', 'application/json'));
     $crawler = $this->client->request('POST', '/secured/user/add/' . $this->user->getId(), array('user' => array('username' => $this->user->getUsername(), 'email' => $this->user->getEmail(), 'employeeName' => $this->user->getEmployee()->getEmployeeName(), 'taxIdentification' => $this->user->getEmployee()->getTaxIdentification(), 'bankAccountNumber' => $this->user->getEmployee()->getBankAccountNumber(), 'bankName' => $this->user->getEmployee()->getBankName(), 'userId' => $this->user->getId(), 'isActive' => $this->user->getIsActive())));
     $decodedJson = json_decode($this->client->getResponse()->getContent(), true);
     $this->assertJson($this->client->getResponse()->getContent(), 'testAddUserAction: The response\'s content is not a JSON object.');
     $this->assertTrue($this->client->getResponse()->headers->contains('Content-Type', 'application/json'), 'testAddUserAction: The content-type is not a json.');
     $this->assertArrayHasKey('response', $decodedJson[0], 'testAddUserAction: Missing response array key.');
     $this->assertEquals('error', $decodedJson[0]['response'], 'testAddUserAction: Missing array value.');
 }
 /**
  * Find employees leave requests
  *
  * @param User $generalManager
  * @param mixed $states
  * @param array $paginationParameters
  * @param array $parameters
  * @return Paginator
  */
 public function findEmployeeLeaveRequests(User $generalManager, $states, array $paginationParameters, $parameters)
 {
     $dq = $this->createQueryBuilder('lr');
     $dq->select('lr')->where($dq->expr()->eq('lr.generalManager', '(:generalManager)'))->andWhere($dq->expr()->neq('lr.employee', $generalManager->getEmployee()->getId()))->andWhere($dq->expr()->isNull('lr.leaveRequestGroup'))->andWhere($dq->expr()->in('s.status', ':states'))->innerJoin('lr.states', 's')->setParameter(':states', $states)->setParameter('generalManager', $generalManager->getId());
     $dq = $this->findByParams($parameters, $dq);
     $dq->setFirstResult($paginationParameters['firstResult']);
     $dq->setMaxResults($paginationParameters['maxResults']);
     return new Paginator($dq->getQuery(), true);
 }
 /**
  * test findUserByEmployeeNameUsingLike method
  */
 public function testFindUserByEmployeeNameUsingLike()
 {
     $user = $this->em->getRepository("OpitOpitHrmUserBundle:User")->findUserByEmployeeNameUsingLike($this->user->getEmployee()->getEmployeeName());
     $this->assertNotNull($user, 'testFindUserByEmployeeNameUsingLike: The given result is null.');
 }