Exemplo n.º 1
0
 /**
  * @covers DmMailer\Manager\Subscriber
  */
 public function testHandlePostReturnsRetrievesCampaignsOnSaveSuccess()
 {
     $postData = [\DmMailer\Entity\Subscriber::CAMPAIGNS => [2, 3]];
     $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([]));
     $this->campaignRepoMock->expects($this->once())->method('getByIds');
     $actualResult = $this->sut->handlePost($this->subscriberMock);
     $this->assertTrue($actualResult);
 }
 /**
  * @return ViewModel
  */
 public function updateAction()
 {
     /** @var Subscriber $entity */
     $entity = $this->subscriberRepository->getOneById($this->params('entityId'));
     if (!$entity) {
         return $this->redirect()->toRoute(static::BASE_ROUTE);
     }
     try {
         if ($this->manager->handlePost($entity)) {
             $msg = $this->userText->getMessage(EntityName::SUBSCRIBER, Message::UPDATE_SUCCESS);
             $this->flashMessenger()->addSuccessMessage($msg);
             return $this->redirect()->toRoute(static::BASE_ROUTE);
         }
     } catch (\Exception $ex) {
         $msg = $this->userText->getMessage(EntityName::SUBSCRIBER, Message::SAVE_FAILED);
         $this->currentMessages[FeedbackType::DANGER][] = $msg;
     }
     $this->layout()->currentMessages = $this->currentMessages;
     return new ViewModel(['form' => $this->manager->getForm()]);
 }