public function testHandleEventPageNotFound() { $notifier = fpErrorNotifier::getInstance(); $notifier->driver()->expects($this->once())->method('notify')->with($this->equalTo($notifier->decoratedMessage('foo'))); $handler = new fpErrorNotifierHandler(new sfEventDispatcher(), array()); $notifier->dispather()->connect('controller.page_not_found', array($handler, 'handleEvent')); $notifier->dispather()->notifyUntil(new sfEvent(new Exception('an exception'), 'controller.page_not_found')); }
/** * * @return fpErrorNotifier */ protected function notifier() { if (!($instance = fpErrorNotifier::getInstance())) { $instance = new fpErrorNotifier($this->configuration->getEventDispatcher()); fpErrorNotifier::setInstance($instance); } return $instance; }
public function testHandleErrorIgnoreLoggingDisabled() { $mockDriver = fpErrorNotifier::getInstance()->driver(); $mockDriver->expects($this->never())->method('notify'); $mockLogger = fpErrorNotifier::getInstance()->context()->getLogger(); $mockLogger->expects($this->never())->method('info'); $handler = new fpErrorNotifierHandlerIgnore(new sfEventDispatcher(), array('ignore_errors' => array(E_WARNING => true), 'log_ignored' => false)); $handler->handleError(E_WARNING, 'an error', 'foo.php', 200); }
<?php $configFiles = $this->getConfigPaths('config/notify.yml'); $config = sfDefineEnvironmentConfigHandler::getConfiguration($configFiles); foreach ($config as $name => $value) { sfConfig::set("sf_notify_{$name}", $value); } fpErrorNotifier::setInstance(new fpErrorNotifier($this->getEventDispatcher())); fpErrorNotifier::getInstance()->handler()->initialize();
/** * * @return fpErrorNotifier */ protected function notifier() { return fpErrorNotifier::getInstance(); }
protected function _start() { $this->notifierBackup = fpErrorNotifier::getInstance(); $notifier = new fpErrorNotifier(new sfEventDispatcher()); fpErrorNotifier::setInstance($notifier); }
/** * (non-PHPdoc) * @see plugins/fpErrorNotifierPlugin/lib/driver/fpBaseErrorNotifierDriver#notify($message) */ public function notify(fpBaseErrorNotifierMessage $message) { $swiftMessage = new Swift_Message(); $swiftMessage->setTo($this->getOption('to'))->setFrom($this->getOption('from'))->setBody((string) $message)->setContentType($message->format())->setSubject($message->subject()); @fpErrorNotifier::getInstance()->context()->getMailer()->send($swiftMessage); }