ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Formatter\ElasticaFormatterTest Class Reference
+ Inheritance diagram for Monolog\Formatter\ElasticaFormatterTest:
+ Collaboration diagram for Monolog\Formatter\ElasticaFormatterTest:

Public Member Functions

 setUp ()
 
 testFormat ()
 @covers Monolog\Formatter\ElasticaFormatter::__construct @covers Monolog\Formatter\ElasticaFormatter::format @covers Monolog\Formatter\ElasticaFormatter::getDocument More...
 
 testGetters ()
 @covers Monolog\Formatter\ElasticaFormatter::getIndex @covers Monolog\Formatter\ElasticaFormatter::getType More...
 

Detailed Description

Definition at line 16 of file ElasticaFormatterTest.php.

Member Function Documentation

◆ setUp()

Monolog\Formatter\ElasticaFormatterTest::setUp ( )

Definition at line 18 of file ElasticaFormatterTest.php.

19 {
20 if (!class_exists("Elastica\Document")) {
21 $this->markTestSkipped("ruflin/elastica not installed");
22 }
23 }

◆ testFormat()

Monolog\Formatter\ElasticaFormatterTest::testFormat ( )

@covers Monolog\Formatter\ElasticaFormatter::__construct @covers Monolog\Formatter\ElasticaFormatter::format @covers Monolog\Formatter\ElasticaFormatter::getDocument

Definition at line 30 of file ElasticaFormatterTest.php.

31 {
32 // test log message
33 $msg = array(
34 'level' => Logger::ERROR,
35 'level_name' => 'ERROR',
36 'channel' => 'meh',
37 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
38 'datetime' => new \DateTime("@0"),
39 'extra' => array(),
40 'message' => 'log',
41 );
42
43 // expected values
44 $expected = $msg;
45 $expected['datetime'] = '1970-01-01T00:00:00+0000';
46 $expected['context'] = array(
47 'class' => '[object] (stdClass: {})',
48 'foo' => 7,
49 0 => 'bar',
50 );
51
52 // format log message
53 $formatter = new ElasticaFormatter('my_index', 'doc_type');
54 $doc = $formatter->format($msg);
55 $this->assertInstanceOf('Elastica\Document', $doc);
56
57 // Document parameters
58 $params = $doc->getParams();
59 $this->assertEquals('my_index', $params['_index']);
60 $this->assertEquals('doc_type', $params['_type']);
61
62 // Document data values
63 $data = $doc->getData();
64 foreach (array_keys($expected) as $key) {
65 $this->assertEquals($expected[$key], $data[$key]);
66 }
67 }
const ERROR
Runtime errors.
Definition: Logger.php:57
$data
$params
Definition: example_049.php:96

References $data, $params, and Monolog\Logger\ERROR.

◆ testGetters()

Monolog\Formatter\ElasticaFormatterTest::testGetters ( )

@covers Monolog\Formatter\ElasticaFormatter::getIndex @covers Monolog\Formatter\ElasticaFormatter::getType

Definition at line 73 of file ElasticaFormatterTest.php.

74 {
75 $formatter = new ElasticaFormatter('my_index', 'doc_type');
76 $this->assertEquals('my_index', $formatter->getIndex());
77 $this->assertEquals('doc_type', $formatter->getType());
78 }

The documentation for this class was generated from the following file: