ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
TestHandlerTest.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\Handler;
13 
15 use Monolog\Logger;
16 
21 {
25  public function testHandler($method, $level)
26  {
27  $handler = new TestHandler;
28  $record = $this->getRecord($level, 'test'.$method);
29  $this->assertFalse($handler->{'has'.$method}($record), 'has'.$method);
30  $this->assertFalse($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
31  $this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
32  return true;
33  }), 'has'.$method.'ThatPasses');
34  $this->assertFalse($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
35  $this->assertFalse($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
36  $handler->handle($record);
37 
38  $this->assertFalse($handler->{'has'.$method}('bar'), 'has'.$method);
39  $this->assertTrue($handler->{'has'.$method}($record), 'has'.$method);
40  $this->assertTrue($handler->{'has'.$method}('test'.$method), 'has'.$method);
41  $this->assertTrue($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains');
42  $this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function ($rec) {
43  return true;
44  }), 'has'.$method.'ThatPasses');
45  $this->assertTrue($handler->{'has'.$method.'ThatMatches'}('/test\w+/'));
46  $this->assertTrue($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records');
47 
48  $records = $handler->getRecords();
49  unset($records[0]['formatted']);
50  $this->assertEquals(array($record), $records);
51  }
52 
53  public function methodProvider()
54  {
55  return array(
56  array('Emergency', Logger::EMERGENCY),
57  array('Alert' , Logger::ALERT),
58  array('Critical' , Logger::CRITICAL),
59  array('Error' , Logger::ERROR),
60  array('Warning' , Logger::WARNING),
61  array('Info' , Logger::INFO),
62  array('Notice' , Logger::NOTICE),
63  array('Debug' , Logger::DEBUG),
64  );
65  }
66 }
testHandler($method, $level)
methodProvider
$records
Definition: simple_test.php:22
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const DEBUG
Create styles array
The data for the language used.
Used for testing purposes.
Definition: TestHandler.php:66