TestCase.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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;
  11. class TestCase extends \PHPUnit_Framework_TestCase
  12. {
  13. /**
  14. * @return array Record
  15. */
  16. protected function getRecord($level = Logger::WARNING, $message = 'test')
  17. {
  18. return array(
  19. 'message' => $message,
  20. 'context' => array(),
  21. 'level' => $level,
  22. 'level_name' => Logger::getLevelName($level),
  23. 'channel' => 'test',
  24. 'datetime' => new \DateTime(),
  25. 'extra' => array(),
  26. );
  27. }
  28. /**
  29. * @return array
  30. */
  31. protected function getMultipleRecords()
  32. {
  33. return array(
  34. $this->getRecord(Logger::DEBUG, 'debug message 1'),
  35. $this->getRecord(Logger::DEBUG, 'debug message 2'),
  36. $this->getRecord(Logger::INFO, 'information'),
  37. $this->getRecord(Logger::WARNING, 'warning'),
  38. $this->getRecord(Logger::ERROR, 'error')
  39. );
  40. }
  41. /**
  42. * @return Monolog\Formatter\FormatterInterface
  43. */
  44. protected function getIdentityFormatter()
  45. {
  46. $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
  47. $formatter->expects($this->any())
  48. ->method('format')
  49. ->will($this->returnCallback(function($record) { return $record['message']; }));
  50. return $formatter;
  51. }
  52. }