Example #1
0
 /**
  * @covers DmMailer\Manager\Template
  */
 public function testHandlePostReturnsTrueOnSaveSuccess()
 {
     $postData = [\DmMailer\Entity\Subscriber::CAMPAIGNS => []];
     $this->formMock->expects($this->any())->method('isValid')->will($this->returnValue(true));
     $this->formMock->expects($this->any())->method('getData')->will($this->returnValue($postData));
     $this->requestMock->expects($this->any())->method('isPost')->will($this->returnValue(true));
     $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue([]));
     $actualResult = $this->sut->handlePost($this->templateMock);
     $this->assertTrue($actualResult);
 }
 /**
  * @return ViewModel
  */
 public function updateAction()
 {
     $entity = $this->templateRepository->getOneById($this->params('entityId'));
     if (!$entity) {
         return $this->redirect()->toRoute(static::BASE_ROUTE);
     }
     try {
         if ($this->manager->handlePost($entity)) {
             $msg = $this->userText->getMessage(EntityName::TEMPLATE, Message::UPDATE_SUCCESS);
             $this->flashMessenger()->addSuccessMessage($msg);
             return $this->redirect()->toRoute(static::BASE_ROUTE);
         }
     } catch (Manager\Exception\Db $exc) {
         $msg = $this->userText->getMessage(EntityName::TEMPLATE, Message::SAVE_FAILED);
         $this->currentMessages[FeedbackType::DANGER][] = $msg;
     }
     $this->layout()->currentMessages = $this->currentMessages;
     return new ViewModel(['form' => $this->manager->getForm()]);
 }