ZendMonitorHandlerTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Logger;
  12. use Monolog\TestCase;
  13. class ZendMonitorHandlerTest extends TestCase
  14. {
  15. protected $zendMonitorHandler;
  16. public function setUp()
  17. {
  18. if (!function_exists('zend_monitor_custom_event')) {
  19. $this->markTestSkipped('ZendServer is not installed');
  20. }
  21. }
  22. /**
  23. * @covers \Monolog\Handler\ZendMonitor::__construct
  24. * @covers \Monolog\Handler\ZendMonitor::isZendServer
  25. */
  26. public function testIsZendServerReturnsTrue()
  27. {
  28. $zendMonitor = new ZendMonitorHandler();
  29. $this->assertTrue($zendMonitor->isZendServer());
  30. }
  31. /**
  32. * @covers \Monolog\Handler\ZendMonitor::write
  33. */
  34. public function testWrite()
  35. {
  36. $record = $this->getRecord();
  37. $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
  38. ->setMethods(array('writeZendMonitorCustomEvent'))
  39. ->getMock();
  40. $levelMap = $zendMonitor->getLevelMap();
  41. $zendMonitor->expects($this->once())
  42. ->method('writeZendMonitorCustomEvent')
  43. ->with($levelMap[$record['level']], $record['message']);
  44. $zendMonitor->handle($record);
  45. }
  46. public function testGetDefaultFormatterReturnsNormalizerFormatter()
  47. {
  48. $zendMonitor = new ZendMonitorHandler();
  49. $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
  50. }
  51. }