TestCase.php 1.5 KB

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