Пример #1
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return MessageController
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if ($serviceLocator instanceof ControllerManager) {
         $serviceLocator = $serviceLocator->getServiceLocator();
     }
     /** @var MessageRepository $messageRepository */
     $messageRepository = $serviceLocator->get('DmMailer\\Repository\\Message');
     /** @var MessageManager $messageManager */
     $messageManager = $serviceLocator->get('DmMailer\\Manager\\Message');
     /** @var MessageBuilder $messageBuilder */
     $messageBuilder = $serviceLocator->get('DmMailer\\Service\\MessageBuilder');
     /** @var DmMailerHelper $options */
     $options = $serviceLocator->get('DmMailer\\Helper\\Options');
     /** @var UserText $userText */
     $userText = $serviceLocator->get('DmCommon\\View\\Helper\\UserText');
     $controller = new MessageController($messageRepository, $messageManager, $messageBuilder, $options, $userText);
     if ($options->hasSystemMailer()) {
         /** @var Queue $systemQueue */
         $systemQueue = $serviceLocator->get('DmMailer\\Service\\Queue\\System');
         $controller->setQueueService($systemQueue);
     }
     /** @var DmTinymceHelper $options */
     $options = $serviceLocator->get('DmTinymce\\Helper\\Options');
     $controller->setTinyMceLang($options->getTinymceLang());
     return $controller;
 }
 /**
  * @covers DmMailerAdmin\Controller\MessageController
  */
 public function testToggleHaltActionSetsContentFalseOnSaveFailure()
 {
     $paramsMock = $this->mockFactory->getParamsMock(1);
     $flashMessengerMock = $this->mockFactory->getFlashMessengerPluginMock(-1, 0, -1, 1);
     $pluginManagerMock = $this->mockFactory->getPluginMock($paramsMock, $flashMessengerMock);
     $this->sut->setPluginManager($pluginManagerMock);
     $responseMock = $this->mockFactory->getResponseMock();
     $this->repositoryMock->expects($this->any())->method('getOneById')->will($this->returnValue($this->getMessageMock()));
     $this->managerMock->expects($this->once())->method('saveEntity')->will($this->returnValue(false));
     $responseMock->expects($this->once())->method('setContent')->with($this->equalTo('false'));
     $this->sut->setResponse($responseMock);
     $actualResult = $this->sut->toggleOnHaltAction();
     $this->assertSame($responseMock, $actualResult);
 }