2
0

FlowdockFormatterTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\Formatter;
  11. use Monolog\Level;
  12. use Monolog\Test\MonologTestCase;
  13. class FlowdockFormatterTest extends MonologTestCase
  14. {
  15. /**
  16. * @covers Monolog\Formatter\FlowdockFormatter::format
  17. */
  18. public function testFormat()
  19. {
  20. $formatter = new FlowdockFormatter('test_source', 'source@test.com');
  21. $record = $this->getRecord();
  22. $expected = [
  23. 'source' => 'test_source',
  24. 'from_address' => 'source@test.com',
  25. 'subject' => 'in test_source: WARNING - test',
  26. 'content' => 'test',
  27. 'tags' => ['#logs', '#warning', '#test'],
  28. 'project' => 'test_source',
  29. ];
  30. $formatted = $formatter->format($record);
  31. $this->assertEquals($expected, $formatted);
  32. }
  33. /**
  34. * @ covers Monolog\Formatter\FlowdockFormatter::formatBatch
  35. */
  36. public function testFormatBatch()
  37. {
  38. $formatter = new FlowdockFormatter('test_source', 'source@test.com');
  39. $records = [
  40. $this->getRecord(Level::Warning),
  41. $this->getRecord(Level::Debug),
  42. ];
  43. $formatted = $formatter->formatBatch($records);
  44. $this->assertArrayHasKey('from_address', $formatted[0]);
  45. $this->assertArrayHasKey('from_address', $formatted[1]);
  46. }
  47. }