33 'index' =>
'my_index',
40 if (!class_exists(
"Elastica\Client")) {
41 $this->markTestSkipped(
"ruflin/elastica not installed");
45 $this->client = $this->getMockBuilder(
'Elastica\Client')
46 ->setMethods(array(
'addDocuments'))
47 ->disableOriginalConstructor()
62 'level_name' =>
'ERROR',
64 'context' => array(
'foo' => 7,
'bar',
'class' =>
new \
stdClass),
71 $formatter =
new ElasticaFormatter($this->options[
'index'], $this->options[
'type']);
72 $expected = array($formatter->format($msg));
75 $this->client->expects($this->any())
76 ->method(
'addDocuments')
93 $this->assertInstanceOf(
'Monolog\Formatter\ElasticaFormatter',
$handler->getFormatter());
94 $this->assertEquals(
'index_new',
$handler->getFormatter()->getIndex());
95 $this->assertEquals(
'type_new',
$handler->getFormatter()->getType());
117 'index' => $this->options[
'index'],
118 'type' => $this->options[
'type'],
119 'ignore_error' =>
false,
122 $this->assertEquals($expected,
$handler->getOptions());
131 $clientOpts = array(
'host' =>
'127.0.0.1',
'port' => 1);
132 $client =
new Client($clientOpts);
133 $handlerOpts = array(
'ignore_error' =>
$ignore);
136 if ($expectedError) {
137 $this->setExpectedException($expectedError[0], $expectedError[1]);
140 $this->assertFalse(
$handler->handle($this->getRecord()));
150 array(
false, array(
'RuntimeException',
'Error sending messages to Elasticsearch')),
167 'level_name' =>
'ERROR',
169 'context' => array(
'foo' => 7,
'bar',
'class' =>
new \
stdClass),
176 $expected[
'datetime'] = $msg[
'datetime']->format(\DateTime::ISO8601);
177 $expected[
'context'] = array(
178 'class' =>
'[object] (stdClass: {})',
188 $this->markTestSkipped(
"Cannot connect to Elastic Search server on localhost");
193 $this->assertNotEmpty($documentId,
'No elastic document id received');
198 $this->options[
'index'],
199 $this->options[
'type'],
202 $this->assertEquals($expected, $document);
205 $client->request(
"/{$this->options['index']}", Request::DELETE);
215 $data = $response->getData();
216 if (!empty(
$data[
'items'][0][
'create'][
'_id'])) {
217 return $data[
'items'][0][
'create'][
'_id'];
231 $resp = $client->request(
"/{$index}/{$type}/{$documentId}", Request::GET);
232 $data = $resp->getData();
233 if (!empty(
$data[
'_source'])) {
234 return $data[
'_source'];
providerTestConnectionErrors()
const ERROR
Runtime errors.
testHandle()
Monolog::write Monolog::handleBatch Monolog::bulkSend Monolog::getDefaultFormatter ...
getDocSourceFromElastic(Client $client, $index, $type, $documentId)
Retrieve document by id from Elasticsearch.
testHandleIntegration()
Integration test using localhost Elastic Search server.
getRecord($level=Logger::WARNING, $message='test', $context=array())
getCreatedDocId(Response $response)
Return last created document id from ES response.
testSetFormatterInvalid()
Monolog::setFormatter InvalidArgumentException ElasticSearchHandler is only compatible with Elastic...
testSetFormatter()
Monolog::setFormatter
testConnectionErrors($ignore, $expectedError)
Monolog::bulkSend providerTestConnectionErrors
while(false !==($line=fgets($in))) if(! $columns) $ignore
testOptions()
Monolog::__construct Monolog::getOptions