Esempio n. 1
0
 /**
  * @covers DmMailer\Manager\Campaign
  */
 protected function setUp()
 {
     $this->entityManagerMock = $this->getMockBuilder('Doctrine\\Orm\\EntityManager')->disableOriginalConstructor()->setMethods(['persist', 'flush', 'remove'])->getMock();
     $this->requestMock = $this->getMockBuilder('Zend\\Http\\PhpEnvironment\\Request')->disableOriginalConstructor()->setMethods(['isPost', 'getPost'])->getMock();
     $inputFilterMock = $this->getMockBuilder('DmMailer\\InputFilter\\Campaign')->disableOriginalConstructor()->setMethods(['init'])->getMock();
     $this->formMock = $this->getMockBuilder('DmMailer\\Form\\CampaignForm')->disableOriginalConstructor()->setMethods(['getData', 'isValid', 'get', 'bind', 'build', 'getInputFilter', 'setData'])->getMock();
     $this->formMock->expects($this->any())->method('getInputFilter')->will($this->returnValue($inputFilterMock));
     $this->sut = new Campaign($this->entityManagerMock, $this->requestMock, null, $this->formMock);
     $this->templateRepoMock = $this->getMockBuilder('DmMailer\\Repository\\Template')->disableOriginalConstructor()->setMethods(['findOneBy'])->getMock();
     $this->sut->setTemplateRepository($this->templateRepoMock);
     $messageMethods = ['getBody', 'getSubject', 'getId', 'setCampaign', 'setQueuedAt', 'setSendAt', 'setOnHalt', 'setSystemMessage', 'populate'];
     $this->messageMock = $this->getMockBuilder('DmMailer\\Entity\\Message')->disableOriginalConstructor()->setMethods($messageMethods)->getMock();
     $this->campaignMock = $this->getMockBuilder('DmMailer\\Entity\\Campaign')->disableOriginalConstructor()->setMethods(['populate'])->getMock();
 }
Esempio n. 2
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return CampaignManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var EntityManager $entityManager */
     $entityManager = $serviceLocator->get('Doctrine\\ORM\\EntityManager');
     /** @var PhpRequest $request */
     $request = $serviceLocator->get('request');
     /** @var CampaignRepository $mainRepository */
     $mainRepository = $serviceLocator->get('DmMailer\\Repository\\Campaign');
     /** @var CampaignForm $form */
     $form = $serviceLocator->get('DmMailer\\Form\\CampaignForm');
     /** @var Paginator $paginatorFactory */
     $paginatorFactory = $serviceLocator->get('DmMailer\\Service\\Factory\\Paginator');
     $manager = new CampaignManager($entityManager, $request, $mainRepository, $form, $paginatorFactory);
     /** @var TemplateRepository $templateRepository */
     $templateRepository = $serviceLocator->get('DmMailer\\Repository\\Template');
     $manager->setTemplateRepository($templateRepository);
     return $manager;
 }