public function testRetrieveUserTracker()
 {
     $user = new User();
     $tracker = $this->tracker();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with(self::CLASS_NAME)->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('load')->with(['user' => $user], null, null, [], 0, 1, null)->will($this->returnValue($tracker));
     $this->repository->retrieveUserTracker($user);
 }
 public function testFindAllByTicket()
 {
     $messageReference = $this->getMessageReference();
     $ticket = $messageReference->getTicket();
     $references = array($messageReference);
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('loadAll')->with($this->equalTo(array('ticket' => $ticket)), null, null, null)->will($this->returnValue($references));
     $result = $this->repository->findAllByTicket($ticket);
     $this->assertEquals($references, $result);
 }
 /**
  * @test
  */
 public function thatBranchEmailConfigurationRetrievesByBranchId()
 {
     $branchId = 1;
     $branchEmailConfiguration = $this->getBranchEmailConfiguartion();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('load')->with($this->equalTo(array('branchId' => $branchId)), $this->equalTo(null), $this->equalTo(null), array(), $this->equalTo(0), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($branchEmailConfiguration));
     $retrievedBranchEmailConfiguration = $this->repository->findOneBy(array('branchId' => $branchId));
     $this->assertNotNull($retrievedBranchEmailConfiguration);
     $this->assertEquals($branchEmailConfiguration, $retrievedBranchEmailConfiguration);
 }
 protected function expectBasicLoad($entity, $id, $lockMode = LockMode::NONE, $lockVersion = null)
 {
     if (Version::compare('2.2.0') === -1) {
         $this->em->expects($this->once())->method('find')->with(get_class($this->entity), $id, $lockMode, $lockVersion)->will($this->returnValue($entity));
     } else {
         $this->persister->expects($this->once())->method('load')->with(array('id' => $id))->will($this->returnValue($entity));
     }
 }
 /**
  * @test
  */
 public function thatGetsAll()
 {
     $entities = array(new EntityStub(), new EntityStub());
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('loadAll')->with($this->equalTo(array()), $this->equalTo(null), $this->equalTo(null), $this->equalTo(null))->will($this->returnValue($entities));
     $retrievedEntities = $this->repository->getAll();
     $this->assertEquals($entities, $retrievedEntities);
 }
 public function testListAllByUserAndPeriod()
 {
     $user = new User();
     $period = new Period(new \DateTime('2014-12-01'), new \DateTime('2014-12-31'));
     $worklogs = [$this->worklog()];
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with(self::CLASS_NAME)->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('loadCriteria')->with($this->logicalAnd($this->isInstanceOf('\\Doctrine\\Common\\Collections\\Criteria')))->will($this->returnValue($worklogs));
     $result = $this->repository->listAllByUserAndPeriod($user, $period);
     $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $result);
     $this->assertEquals($result->toArray(), $worklogs);
 }