/**
  *
  */
 public function testCanSetAffiliations()
 {
     $service = new AffiliationService();
     // Create a dummy user entity
     $affiliation = new Affiliation();
     $affiliation->setId(1);
     // Create a dummy user entity
     $affiliation2 = new Affiliation();
     $affiliation2->setId(2);
     // Mock the repository, disabling the constructor
     $userRepositoryMock = $this->getMockBuilder(\Affiliation\Repository\Affiliation::class)->disableOriginalConstructor()->getMock();
     $userRepositoryMock->expects($this->once())->method('findAll')->will($this->returnValue([$affiliation, $affiliation2]));
     // Mock the entity manager
     $emMock = $this->getMock('EntityManager', ['getRepository'], [], '', false);
     $emMock->expects($this->any())->method('getRepository')->will($this->returnValue($userRepositoryMock));
     $service->setEntityManager($emMock);
     $this->assertEquals(2, sizeof($service->findAll('affiliation')));
 }
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return AffiliationService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $affiliationService = new AffiliationService();
     $affiliationService->setServiceLocator($serviceLocator);
     /** @var EntityManager $entityManager */
     $entityManager = $serviceLocator->get(EntityManager::class);
     $affiliationService->setEntityManager($entityManager);
     /** @var AdminService $adminService */
     $adminService = $serviceLocator->get(AdminService::class);
     $affiliationService->setAdminService($adminService);
     /** @var InvoiceService $invoiceService */
     $invoiceService = $serviceLocator->get(InvoiceService::class);
     $affiliationService->setInvoiceService($invoiceService);
     /** @var VersionService $versionService */
     $versionService = $serviceLocator->get(VersionService::class);
     $affiliationService->setVersionService($versionService);
     /** @var OrganisationService $organisationService */
     $organisationService = $serviceLocator->get(OrganisationService::class);
     $affiliationService->setOrganisationService($organisationService);
     /** @var Authorize $authorizeService */
     $authorizeService = $serviceLocator->get(Authorize::class);
     $affiliationService->setAuthorizeService($authorizeService);
     return $affiliationService;
 }