2
0

FleepHookHandlerTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php declare(strict_types=1);
  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\Formatter\LineFormatter;
  12. use Monolog\Level;
  13. /**
  14. * @coversDefaultClass \Monolog\Handler\FleepHookHandler
  15. */
  16. class FleepHookHandlerTest extends \Monolog\Test\MonologTestCase
  17. {
  18. /**
  19. * Default token to use in tests
  20. */
  21. const TOKEN = '123abc';
  22. private FleepHookHandler $handler;
  23. public function setUp(): void
  24. {
  25. parent::setUp();
  26. if (!\extension_loaded('openssl')) {
  27. $this->markTestSkipped('This test requires openssl extension to run');
  28. }
  29. // Create instances of the handler and logger for convenience
  30. $this->handler = new FleepHookHandler(self::TOKEN);
  31. }
  32. public function tearDown(): void
  33. {
  34. parent::tearDown();
  35. unset($this->handler);
  36. }
  37. /**
  38. * @covers ::__construct
  39. */
  40. public function testConstructorSetsExpectedDefaults()
  41. {
  42. $this->assertEquals(Level::Debug, $this->handler->getLevel());
  43. $this->assertEquals(true, $this->handler->getBubble());
  44. }
  45. /**
  46. * @covers ::getDefaultFormatter
  47. */
  48. public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays()
  49. {
  50. $record = $this->getRecord(Level::Debug, 'msg');
  51. $expectedFormatter = new LineFormatter(null, null, true, true);
  52. $expected = $expectedFormatter->format($record);
  53. $handlerFormatter = $this->handler->getFormatter();
  54. $actual = $handlerFormatter->format($record);
  55. $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered');
  56. }
  57. /**
  58. * @covers ::__construct
  59. */
  60. public function testConnectionStringisConstructedCorrectly()
  61. {
  62. $this->assertEquals('ssl://fleep.io:443', $this->handler->getConnectionString());
  63. }
  64. }