GelfHandlerTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Monolog\TestCase;
  12. use Monolog\Logger;
  13. use Gelf\MessagePublisher;
  14. class GelfHandlerTest extends TestCase
  15. {
  16. public function setUp()
  17. {
  18. if (!class_exists("Gelf\MessagePublisher"))
  19. {
  20. $this->markTestSkipped("https://github.com/mlehner/gelf-php not installed");
  21. }
  22. }
  23. /**
  24. * @covers Monolog\Handler\GelfHandler::__construct
  25. */
  26. public function testConstruct()
  27. {
  28. $handler = new GelfHandler($this->getMessagePublisher());
  29. $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler);
  30. }
  31. protected function getMessagePublisher()
  32. {
  33. return new MessagePublisher('localhost');
  34. }
  35. public function testStuff()
  36. {
  37. $handler = new GelfHandler($this->getMessagePublisher());
  38. $handler->setFormatter($this->getIdentityFormatter());
  39. $handler->handle($this->getRecord(Logger::DEBUG));
  40. $handler->handle($this->getRecord(Logger::WARNING));
  41. }
  42. }