4 * This file is part of the Monolog package.
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
16 public function test($handler, $record)
18 $handler->handle($record);
22 function tester($handler, $record)
24 $handler->handle($record);
27 namespace Monolog\Processor;
31 use Monolog\Handler\TestHandler;
33 class IntrospectionProcessorTest extends TestCase
35 public function getHandler()
37 $processor = new IntrospectionProcessor();
38 $handler = new TestHandler();
39 $handler->pushProcessor($processor);
44 public function testProcessorFromClass()
46 $handler = $this->getHandler();
47 $tester = new \Acme\Tester;
48 $tester->test($handler, $this->getRecord());
49 list($record) = $handler->getRecords();
50 $this->assertEquals(__FILE__, $record['extra']['file']);
51 $this->assertEquals(18, $record['extra']['line']);
52 $this->assertEquals('Acme\Tester', $record['extra']['class']);
53 $this->assertEquals('test', $record['extra']['function']);
56 public function testProcessorFromFunc()
58 $handler = $this->getHandler();
59 \Acme\tester($handler, $this->getRecord());
60 list($record) = $handler->getRecords();
61 $this->assertEquals(__FILE__, $record['extra']['file']);
62 $this->assertEquals(24, $record['extra']['line']);
63 $this->assertEquals(null, $record['extra']['class']);
64 $this->assertEquals('Acme\tester', $record['extra']['function']);
67 public function testLevelTooLow()
70 'level' => Logger::DEBUG,
76 $processor = new IntrospectionProcessor(Logger::CRITICAL);
77 $actual = $processor($input);
79 $this->assertEquals($expected, $actual);
82 public function testLevelEqual()
85 'level' => Logger::CRITICAL,
90 $expected['extra'] = array(
93 'class' => 'ReflectionMethod',
94 'function' => 'invokeArgs',
97 $processor = new IntrospectionProcessor(Logger::CRITICAL);
98 $actual = $processor($input);
100 $this->assertEquals($expected, $actual);
103 public function testLevelHigher()
106 'level' => Logger::EMERGENCY,
111 $expected['extra'] = array(
114 'class' => 'ReflectionMethod',
115 'function' => 'invokeArgs',
118 $processor = new IntrospectionProcessor(Logger::CRITICAL);
119 $actual = $processor($input);
121 $this->assertEquals($expected, $actual);