/**
  * @test
  */
 public function thatApiUserRetrievesByUsername()
 {
     $email = '*****@*****.**';
     $apiUser = $this->getApiUser();
     $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('email' => $email)), $this->equalTo(null), $this->equalTo(null), array(), $this->equalTo(0), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($apiUser));
     $retrievedApiUser = $this->repository->findOneBy(array('email' => $email));
     $this->assertNotNull($retrievedApiUser);
     $this->assertEquals($apiUser, $retrievedApiUser);
 }
 /**
  * @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(['branchId' => $branchId]), $this->equalTo(null), $this->equalTo(null), $this->equalTo([]), $this->equalTo(null), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($branchEmailConfiguration));
     $retrievedBranchEmailConfiguration = $this->repository->findOneBy(['branchId' => $branchId]);
     $this->assertNotNull($retrievedBranchEmailConfiguration);
     $this->assertEquals($branchEmailConfiguration, $retrievedBranchEmailConfiguration);
 }
 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 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);
 }