2
0

LineFormatterTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. class LineFormatterTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testDefFormatWithString()
  15. {
  16. $formatter = new LineFormatter(null, 'Y-m-d');
  17. $message = $formatter->format(array(
  18. 'level_name' => 'WARNING',
  19. 'channel' => 'log',
  20. 'message' => 'foo',
  21. 'datetime' => new \DateTime,
  22. 'extra' => array(),
  23. ));
  24. $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo'."\n", $message['message']);
  25. }
  26. public function testDefFormatWithArray()
  27. {
  28. $formatter = new LineFormatter(null, 'Y-m-d');
  29. $message = $formatter->format(array(
  30. 'level_name' => 'ERROR',
  31. 'channel' => 'meh',
  32. 'datetime' => new \DateTime,
  33. 'extra' => array(),
  34. 'message' => array(
  35. 'channel' => 'log',
  36. 'level_name' => 'WARNING',
  37. 'message' => 'foo',
  38. )
  39. ));
  40. $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo'."\n", $message['message']);
  41. }
  42. }