Author: Jordi Boggiano (j.boggiano@seld.be)
Inheritance: extends Monolog\Processor\WebProcessor
 public function testCanBeConstructedWithExtraFields()
 {
     if (!$this->isExtraFieldsSupported()) {
         $this->markTestSkipped('WebProcessor of the installed Monolog version does not support $extraFields parameter');
     }
     list($event, $server) = $this->createRequestEvent();
     $processor = new WebProcessor(array('url', 'referrer'));
     $processor->onKernelRequest($event);
     $record = $processor($this->getRecord());
     $this->assertCount(2, $record['extra']);
     $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
     $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
 }
Exemplo n.º 2
0
 public function testUsesRequestServerData()
 {
     $server = array('REQUEST_URI' => 'A', 'REMOTE_ADDR' => 'B', 'REQUEST_METHOD' => 'C', 'SERVER_NAME' => 'D', 'HTTP_REFERER' => 'E');
     $request = new Request();
     $request->server->replace($server);
     $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->any())->method('isMasterRequest')->will($this->returnValue(true));
     $event->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $processor = new WebProcessor();
     $processor->onKernelRequest($event);
     $record = $processor($this->getRecord());
     $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']);
     $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']);
     $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
     $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
     $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
 }
 public function __construct(Session $session, array $extraFields = null)
 {
     parent::__construct($extraFields);
     $this->session = $session;
 }