public function testCollect()
 {
     $c = new LoggerDataCollector(new TestLogger());
     $c->collect(new Request(), new Response());
     $this->assertSame('logger', $c->getName());
     $this->assertSame(1337, $c->countErrors());
     $this->assertSame(array('foo'), $c->getLogs());
 }
 /**
  * @dataProvider getCollectTestData
  */
 public function testCollect($nb, $logs, $expected)
 {
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface');
     $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
     $logger->expects($this->once())->method('getLogs')->will($this->returnValue($logs));
     $c = new LoggerDataCollector($logger);
     $c->collect(new Request(), new Response());
     $this->assertSame('logger', $c->getName());
     $this->assertSame($nb, $c->countErrors());
     $this->assertSame($expected ? $expected : $logs, $c->getLogs());
 }
Пример #3
0
 /**
  * @dataProvider getCollectTestData
  */
 public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
 {
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface');
     $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
     $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
     $c = new LoggerDataCollector($logger);
     $c->lateCollect();
     $this->assertSame('logger', $c->getName());
     $this->assertSame($nb, $c->countErrors());
     $this->assertSame($expectedLogs ?: $logs, $c->getLogs());
     $this->assertSame($expectedDeprecationCount, $c->countDeprecations());
     $this->assertSame($expectedScreamCount, $c->countScreams());
     if (isset($expectedPriorities)) {
         $this->assertSame($expectedPriorities, $c->getPriorities());
     }
 }
Пример #4
0
 /**
  * @dataProvider getCollectTestData
  */
 public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount, $expectedScreamCount, $expectedPriorities = null)
 {
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface');
     $logger->expects($this->once())->method('countErrors')->will($this->returnValue($nb));
     $logger->expects($this->exactly(2))->method('getLogs')->will($this->returnValue($logs));
     $c = new LoggerDataCollector($logger);
     $c->lateCollect();
     // Remove the trace from the real logs, to ease fixtures creation.
     $logs = array_map(function ($log) {
         unset($log['context']['trace'], $log['context']['exception']['trace']);
         return $log;
     }, $c->getLogs());
     $this->assertEquals('logger', $c->getName());
     $this->assertEquals($nb, $c->countErrors());
     $this->assertEquals($expectedLogs, $logs);
     $this->assertEquals($expectedDeprecationCount, $c->countDeprecations());
     $this->assertEquals($expectedScreamCount, $c->countScreams());
     if (isset($expectedPriorities)) {
         $this->assertSame($expectedPriorities, $c->getPriorities());
     }
 }