/**
  * {@inheritdoc}
  *
  * @author  Florian Preusner
  * @version 2.1
  * @since   2014-11
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $messages = $this->logger->getMessages();
     $requestId = $request->getUri();
     // clear log to have only messages related to symfony request context
     $this->logger->clear();
     $logGroup = $this->getLogGroup($requestId);
     $logGroup->setRequestName($request->getPathInfo());
     $logGroup->setMessages($messages);
 }
 /**
  * Test Call Count
  *
  * @author  Florian Preusner
  * @version 2.1
  * @since   2015-06
  *
  * @covers  EightPoints\Bundle\GuzzleBundle\DataCollector\HttpDataCollector::getCallCount
  */
 public function testCallCount()
 {
     $this->logger->expects($this->once())->method('getMessages')->willReturn(['test message #1', 'test message #2']);
     $collector = new HttpDataCollector($this->logger);
     $response = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Response')->getMock();
     $request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->getMock();
     $request->expects($this->once())->method('getPathInfo')->willReturn('id');
     $collector->collect($request, $response);
     $this->assertSame(2, $collector->getCallCount());
 }
Esempio n. 3
0
 /**
  * Test Clearing Messages
  *
  * @author  Florian Preusner
  * @version 2.1
  * @since   2015-05
  *
  * @covers  EightPoints\Bundle\GuzzleBundle\Log\Logger::clear
  */
 public function testClear()
 {
     $logger = new Logger();
     $logger->log('test', 'test message');
     $logger->log('test', 'test message');
     $this->assertCount(2, $logger->getMessages());
     $this->assertTrue($logger->hasMessages());
     $logger->clear();
     $this->assertCount(0, $logger->getMessages());
     $this->assertFalse($logger->hasMessages());
 }