ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FluentdFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog\Formatter;
13 
14 use Monolog\Logger;
16 
18 {
23  public function testConstruct()
24  {
25  $formatter = new FluentdFormatter();
26  $this->assertEquals(false, $formatter->isUsingLevelsInTag());
27  $formatter = new FluentdFormatter(false);
28  $this->assertEquals(false, $formatter->isUsingLevelsInTag());
29  $formatter = new FluentdFormatter(true);
30  $this->assertEquals(true, $formatter->isUsingLevelsInTag());
31  }
32 
36  public function testFormat()
37  {
38  $record = $this->getRecord(Logger::WARNING);
39  $record['datetime'] = new \DateTime("@0");
40 
41  $formatter = new FluentdFormatter();
42  $this->assertEquals(
43  '["test",0,{"message":"test","context":[],"extra":[],"level":300,"level_name":"WARNING"}]',
44  $formatter->format($record)
45  );
46  }
47 
51  public function testFormatWithTag()
52  {
53  $record = $this->getRecord(Logger::ERROR);
54  $record['datetime'] = new \DateTime("@0");
55 
56  $formatter = new FluentdFormatter(true);
57  $this->assertEquals(
58  '["test.error",0,{"message":"test","context":[],"extra":[]}]',
59  $formatter->format($record)
60  );
61  }
62 }
const ERROR
Runtime errors.
Definition: Logger.php:58
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
testConstruct()
Monolog::__construct Monolog::isUsingLevelsInTag