9 namespace Fossology\Lib\Util;
15 public $timestamp = 3.1415926;
16 public function getTimestamp()
18 return $this->timestamp;
26 protected function setUp() :
void
28 $this->logger = M::mock(
'Monolog\Logger');
29 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
32 protected function tearDown() :
void
34 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
38 public function testTicToc()
44 $expected = sprintf(
"%s (%.3fms)", $text, ($endTime - $startTime) * 1000);
45 $this->logger->shouldReceive(
'debug')->with($expected);
46 $hackedTimingLogger->timestamp = $startTime;
47 $hackedTimingLogger->tic();
48 $hackedTimingLogger->timestamp = $endTime;
49 $hackedTimingLogger->toc($text);
52 public function testTicTocOtherWatch()
58 $watch =
'otherWatch';
59 $expected = sprintf(
"%s (%.3fms)", $text, ($endTime - $startTime) * 1000);
60 $this->logger->shouldReceive(
'debug')->with($expected);
61 $hackedTimingLogger->timestamp = $startTime;
62 $hackedTimingLogger->tic($watch);
63 $hackedTimingLogger->timestamp = ($startTime+$endTime)/2;
64 $hackedTimingLogger->tic(
'default');
65 $hackedTimingLogger->timestamp = $endTime;
66 $hackedTimingLogger->toc($text,$watch);