JsonFormatterTest.php 1015B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\Formatter;
  11. use Monolog\Logger;
  12. use Monolog\TestCase;
  13. class JsonFormatterTest extends TestCase
  14. {
  15. /**
  16. * @covers Monolog\Formatter\JsonFormatter::format
  17. */
  18. public function testFormat()
  19. {
  20. $formatter = new JsonFormatter();
  21. $record = $this->getRecord();
  22. $this->assertEquals(json_encode($record), $formatter->format($record));
  23. }
  24. /**
  25. * @covers Monolog\Formatter\JsonFormatter::formatBatch
  26. */
  27. public function testFormatBatch()
  28. {
  29. $formatter = new JsonFormatter();
  30. $records = array(
  31. $this->getRecord(Logger::WARNING),
  32. $this->getRecord(Logger::DEBUG),
  33. );
  34. $this->assertEquals(json_encode($records), $formatter->formatBatch($records));
  35. }
  36. }