/** * @covers DmMailer\Manager\Subscriber */ protected function setUp() { $this->entityManagerMock = $this->getMockBuilder('Doctrine\\Orm\\EntityManager')->disableOriginalConstructor()->setMethods(['persist', 'flush'])->getMock(); $this->requestMock = $this->getMockBuilder('Zend\\Http\\PhpEnvironment\\Request')->disableOriginalConstructor()->setMethods([])->getMock(); $this->formMock = $this->getMockBuilder('DmMailer\\Form\\CampaignForm')->disableOriginalConstructor()->setMethods(['getData', 'isValid', 'bind', 'build', 'setData'])->getMock(); $this->sut = new Subscriber($this->entityManagerMock, $this->requestMock, null, $this->formMock); $this->campaignRepoMock = $this->getMockBuilder('DmMailer\\Repository\\Campaign')->disableOriginalConstructor()->setMethods(['getByIds'])->getMock(); $this->sut->setCampaignRepository($this->campaignRepoMock); $this->subscriberMock = $this->getMockBuilder('DmMailer\\Entity\\Subscriber')->disableOriginalConstructor()->setMethods(['populate'])->getMock(); }
/** * @param ServiceLocatorInterface $serviceLocator * * @return SubscriberManager */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var EntityManager $entityManager */ $entityManager = $serviceLocator->get('Doctrine\\ORM\\EntityManager'); /** @var PhpRequest $request */ $request = $serviceLocator->get('request'); /** @var SubscriberRepository $mainRepository */ $mainRepository = $serviceLocator->get('DmMailer\\Repository\\Subscriber'); /** @var SubscriberForm $form */ $form = $serviceLocator->get('DmMailer\\Form\\SubscriberForm'); /** @var Paginator $paginatorFactory */ $paginatorFactory = $serviceLocator->get('DmMailer\\Service\\Factory\\Paginator'); $manager = new SubscriberManager($entityManager, $request, $mainRepository, $form, $paginatorFactory); /** @var CampaignRepository $campaignRepository */ $campaignRepository = $serviceLocator->get('DmMailer\\Repository\\Campaign'); $manager->setCampaignRepository($campaignRepository); return $manager; }