/**
  * @covers Monolog\Handler\ElasticSearchHandler::write
  * @covers Monolog\Handler\ElasticSearchHandler::handleBatch
  * @covers Monolog\Handler\ElasticSearchHandler::bulkSend
  * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter
  */
 public function testHandle()
 {
     // log message
     $msg = array('level' => Logger::ERROR, 'level_name' => 'ERROR', 'channel' => 'meh', 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass()), 'datetime' => new \DateTime("@0"), 'extra' => array(), 'message' => 'log');
     // format expected result
     $formatter = new ElasticaFormatter($this->options['index'], $this->options['type']);
     $expected = array($formatter->format($msg));
     // setup ES client mock
     $this->client->expects($this->any())->method('addDocuments')->with($expected);
     // perform tests
     $handler = new ElasticSearchHandler($this->client, $this->options);
     $handler->handle($msg);
     $handler->handleBatch(array($msg));
 }
示例#2
0
 public function __construct(TokenStorage $token, $index, $type)
 {
     $this->token = $token;
     parent::__construct($index, $type);
 }
 /**
  * @covers Monolog\Formatter\ElasticaFormatter::getIndex
  * @covers Monolog\Formatter\ElasticaFormatter::getType
  */
 public function testGetters()
 {
     $formatter = new ElasticaFormatter('my_index', 'doc_type');
     $this->assertEquals('my_index', $formatter->getIndex());
     $this->assertEquals('doc_type', $formatter->getType());
 }