SimpleFormatterTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 SimpleFormatterTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testDefFormatWithString()
  15. {
  16. $formatter = new SimpleFormatter(null, 'Y-m-d');
  17. $message = $formatter->format('log', array('level' => Logger::WARNING, 'message' => 'foo'));
  18. $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo'."\n", $message);
  19. }
  20. public function testDefFormatWithArray()
  21. {
  22. $formatter = new SimpleFormatter(null, 'Y-m-d');
  23. $message = $formatter->format('xx', array(
  24. 'level' => Logger::ERROR,
  25. 'message' => array(
  26. 'log' => 'log',
  27. 'level' => 'WARNING',
  28. 'message' => 'foo',
  29. )
  30. ));
  31. $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo'."\n", $message);
  32. }
  33. }