Нема описа

DoctrineCouchDBHandlerTest.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Handler;
  11. use Monolog\TestCase;
  12. use Monolog\Logger;
  13. class DoctrineCouchDBHandlerTest extends TestCase
  14. {
  15. protected function setup()
  16. {
  17. if (!class_exists('Doctrine\CouchDB\CouchDBClient')) {
  18. $this->markTestSkipped('The "doctrine/couchdb" package is not installed');
  19. }
  20. }
  21. public function testHandle()
  22. {
  23. $client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient')
  24. ->setMethods(array('postDocument'))
  25. ->disableOriginalConstructor()
  26. ->getMock();
  27. $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
  28. $expected = array(
  29. 'message' => 'test',
  30. 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
  31. 'level' => Logger::WARNING,
  32. 'level_name' => 'WARNING',
  33. 'channel' => 'test',
  34. 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
  35. 'extra' => array(),
  36. );
  37. $client->expects($this->once())
  38. ->method('postDocument')
  39. ->with($expected);
  40. $handler = new DoctrineCouchDBHandler($client);
  41. $handler->handle($record);
  42. }
  43. }