NewRelicHandlerTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. class NewRelicHandlerTest extends TestCase
  14. {
  15. /**
  16. * @expectedException Monolog\Handler\MissingExtensionException
  17. */
  18. public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded()
  19. {
  20. $handler = new StubNewRelicHandlerWithoutExtension();
  21. $handler->handle($this->getRecord(Logger::ERROR));
  22. }
  23. public function testThehandlerCanHandleTheRecord()
  24. {
  25. $handler = new StubNewRelicHandler();
  26. $handler->handle($this->getRecord(Logger::ERROR));
  27. }
  28. public function testThehandlerCanAddParamsToTheNewRelicTrace()
  29. {
  30. $handler = new StubNewRelicHandler();
  31. $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
  32. }
  33. }
  34. class StubNewRelicHandlerWithoutExtension extends NewRelicHandler
  35. {
  36. protected function isNewRelicEnabled()
  37. {
  38. return false;
  39. }
  40. }
  41. class StubNewRelicHandler extends NewRelicHandler
  42. {
  43. protected function isNewRelicEnabled()
  44. {
  45. return true;
  46. }
  47. }
  48. function newrelic_notice_error() {
  49. return true;
  50. }
  51. function newrelic_add_custom_parameter() {
  52. return true;
  53. }