public function getServiceConfig() { return array('factories' => array('MaglLegacyApplicationOptions' => function ($sl) { $config = $sl->get('Config'); $options = $config['magl_legacy_application']; return new Options\LegacyControllerOptions($options); }, 'MaglControllerService' => function (ServiceManager $sl) { $eventManager = $sl->get('Application')->getEventManager(); $event = new \Zend\Mvc\MvcEvent(); $event->setApplication($sl->get('Application')); $event->setTarget($sl->get('Application')); $event->setRequest($sl->get('Request')); $event->setRouter($sl->get('Router')); $event->setRouteMatch(new RouteMatch(array())); return new Service\ControllerService($eventManager, $event); })); }
/** * @covers \EscoMail\Service\MailLogger::onMailSentError */ public function testLoggerOnMailSentFailure() { $configArray = array('log_dir' => vfsStream::url('exampleDir') . '/tmp'); $serviceManager = new ServiceManager(); $options = new ModuleOptions($configArray); $mailLogger = new MailLogger($options, $serviceManager); $mailSubject = 'Subject of the mail message'; $messageMock = $this->getMock('Zend\\Mail\\Message', array('getSubject')); $messageMock->expects($this->once())->method('getSubject')->will($this->returnValue($mailSubject)); $messageMock->addTo('*****@*****.**'); $mvcEvent = new \Zend\Mvc\MvcEvent(); $mvcEvent->setTarget($messageMock); $mvcEvent->setParam('error_message', 'Error message description'); $logFile = $configArray['log_dir'] . '/mail.log'; $this->assertEmpty(file_get_contents($logFile)); $mailLogger->onMailSentError($mvcEvent); $content = file_get_contents($logFile); $match = preg_match("/^(.*)ERR \\(3\\):(.*)'{$mailSubject}'(.*): foo@bar.com(.*): Error message description/i", $content); $this->assertEquals(1, $match); }