/** * @dataProvider getCollectTestData */ public function testCollect($nb, $logs, $expectedLogs, $expectedDeprecationCount) { $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 ? $expectedLogs : $logs, $c->getLogs()); $this->assertSame($expectedDeprecationCount, $c->countDeprecations()); }
/** * @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()); } }