3 namespace Friendica\Test\src\Util\Logger;
5 use Friendica\Test\MockedTest;
6 use Friendica\Util\Logger\ProfilerLogger;
7 use Friendica\Util\Profiler;
8 use Mockery\MockInterface;
9 use Psr\Log\LoggerInterface;
12 class ProfilerLoggerTest extends MockedTest
17 * @var LoggerInterface|MockInterface
21 * @var Profiler|MockInterface
25 protected function setUp()
29 $this->logger = \Mockery::mock(LoggerInterface::class);
30 $this->profiler = \Mockery::mock(Profiler::class);
34 * Test if the profiler is profiling data
35 * @dataProvider dataTests
37 public function testProfiling($function, $message, array $context)
39 $logger = new ProfilerLogger($this->logger, $this->profiler);
41 $this->logger->shouldReceive($function)->with($message, $context)->once();
42 $this->profiler->shouldReceive('saveTimestamp')->with(\Mockery::any(), 'file', \Mockery::any())->once();
43 $logger->$function($message, $context);
47 * Test the log() function
49 public function testProfilingLog()
51 $logger = new ProfilerLogger($this->logger, $this->profiler);
53 $this->logger->shouldReceive('log')->with(LogLevel::WARNING, 'test', ['a' => 'context'])->once();
54 $this->profiler->shouldReceive('saveTimestamp')->with(\Mockery::any(), 'file', \Mockery::any())->once();
56 $logger->log(LogLevel::WARNING, 'test', ['a' => 'context']);