/** * @param ServiceLocatorInterface $serviceLocator * * @return CampaignForm */ public function createService(ServiceLocatorInterface $serviceLocator) { /** @var TemplateRepository $templateRepository */ $templateRepository = $serviceLocator->get('DmMailer\\Repository\\Template'); $templateOptions = $templateRepository->getSelectOptions(); $form = new CampaignForm(); $form->setInputFilter(new CampaignInputFilter()); $form->setTemplateOptions($templateOptions); return $form; }
/** * @param CampaignForm $form * * @return array */ private function getMessageData(CampaignForm $form) { $formData = $form->getData(); $messageData = []; $messageData[MessageEntity::BODY] = $formData[CampaignForm::WELCOME_MESSAGE]; $messageData[MessageEntity::SUBJECT] = $formData[CampaignForm::WELCOME_SUBJECT]; return $messageData; }
/** * @covers DmMailer\Form\CampaignForm */ public function testBuild() { $this->sut->build(); $this->assertInstanceOf('Zend\\Form\\Element\\Hidden', $this->sut->get(Form::ENTITY_ID)); $this->assertInstanceOf('Zend\\Form\\Element\\Text', $this->sut->get(Form::NAME)); $this->assertInstanceOf('Zend\\Form\\Element\\Email', $this->sut->get(Form::SENDER)); $this->assertInstanceOf('Zend\\Form\\Element\\Email', $this->sut->get(Form::REPLY_TO)); $this->assertInstanceOf('Zend\\Form\\Element\\Email', $this->sut->get(Form::FROM)); $this->assertInstanceOf('Zend\\Form\\Element\\Url', $this->sut->get(Form::UNSUBSCRIBE_URL)); $this->assertInstanceOf('Zend\\Form\\Element\\Select', $this->sut->get(Form::TEMPLATE)); $this->assertInstanceOf('Zend\\Form\\Element\\Text', $this->sut->get(Form::WELCOME_SUBJECT)); $this->assertInstanceOf('Zend\\Form\\Element\\Textarea', $this->sut->get(Form::WELCOME_MESSAGE)); $this->assertInstanceOf('Zend\\Form\\Element\\Csrf', $this->sut->get(Form::SECURITY)); }