/**
  * 
  * @return fpErrorNotifier
  */
 protected function notifier()
 {
     if (!($instance = fpErrorNotifier::getInstance())) {
         $instance = new fpErrorNotifier($this->configuration->getEventDispatcher());
         fpErrorNotifier::setInstance($instance);
     }
     return $instance;
 }
 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'));
 }
 public function testConstruct()
 {
     $stubHelper = $this->getStubStrict('fpErrorNotifierMessageHelper', array('formatSummary' => array('foo' => 'bar'), 'formatSubject' => 'Foo Subject'));
     $notifier = $this->getStubStrict('fpErrorNotifier', array('helper' => $stubHelper), array(), '', false);
     fpErrorNotifier::setInstance($notifier);
     $message = new fpErrorNotifierMessage('foo');
     $this->assertAttributeEquals(array('Summary' => array('foo' => 'bar')), '_data', $message);
     $this->assertEquals('Foo Subject', $message->subject());
     return $message;
 }
 public function testRender()
 {
     $helper = new fpErrorNotifierMessageHelper();
     $notifier = $this->getStubStrict('fpErrorNotifier', array('helper' => $helper), array(), '', false);
     fpErrorNotifier::setInstance($notifier);
     $message = new fpErrorNotifierMessage('foo title');
     $message->addSection('test one', array('bar' => 'foo'));
     $decorator = new fpErrorNotifierDecoratorHtml($message);
     $text = $decorator->render();
     $this->assertType('string', $text);
     $this->assertContains('Summary', $text);
     $this->assertContains('Environment', $text);
     $this->assertContains('Test One', $text);
 }
 public function testFormatSummary()
 {
     sfConfig::set('sf_environment', 'foo_env');
     $stubContext = $this->getStubStrict('sfContext', array('getModuleName' => 'FooModule', 'getActionName' => 'BarAction'));
     $notifier = $this->getStubStrict('fpErrorNotifier', array('context' => $stubContext), array(), '', false);
     fpErrorNotifier::setInstance($notifier);
     $helper = new fpErrorNotifierMessageHelper();
     $summaryData = $helper->formatSummary('FooTitle');
     $this->assertInternalType('array', $summaryData);
     $expectedKeys = array('subject', 'uri', 'environment', 'module', 'action', 'generated at');
     $this->assertEquals($expectedKeys, array_keys($summaryData));
     $this->assertEquals('FooTitle', $summaryData['subject']);
     $this->assertEquals('foo_env', $summaryData['environment']);
 }
 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);
 }
Ejemplo n.º 7
0
<?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();
Ejemplo n.º 8
0
<?php

require_once dirname(__FILE__) . '/include.php';
fpErrorNotifier::initialize(sfContext::getInstance()->getConfiguration());
 /**
  * 
  * @return fpErrorNotifier
  */
 protected function notifier()
 {
     return fpErrorNotifier::getInstance();
 }
 protected function getHeandler()
 {
     sfConfig::set('sf_notify_handler', array('class' => 'fpErrorNotifierHandlerTest', 'options' => array()));
     $notifier = new fpErrorNotifier(new sfEventDispatcher());
     return $notifier->handler();
 }
 /**
  * 
  * @depends testDecorator
  * @depends testMessage
  */
 public function testDecoratedMessage()
 {
     $decoratorMock = $this->getMockForAbstractClass('fpBaseErrorNotifierDecorator', array(), '', false);
     sfConfig::set('sf_notify_decorator', array('class' => get_class($decoratorMock)));
     $messageMock = $this->getMockForAbstractClass('fpBaseErrorNotifierMessage');
     sfConfig::set('sf_notify_message', array('class' => get_class($messageMock)));
     $notifier = new fpErrorNotifier(new sfEventDispatcher());
     $decoratedMessage = $notifier->decoratedMessage('Foo Title');
     $this->assertInstanceOf(get_class($decoratorMock), $decoratedMessage);
     $this->assertAttributeInstanceOf(get_class($messageMock), 'message', $decoratedMessage);
 }
Ejemplo n.º 12
0
 /**
  * 
  * @param fpErrorNotifier
  * 
  * @return fpErrorNotifier
  */
 public static function setInstance(fpErrorNotifier $notifier)
 {
   return self::$instance = $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);
 }
 /**
  * 
  * @return void
  */
 public function initialize()
 {
     fpErrorNotifier::initialize($this->configuration);
 }