/**
  * @covers Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter::getOffset
  * @uses Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter
  * @uses Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatterAbstract
  */
 public function testGetOffset()
 {
     $startTimeBenchmark = 100000;
     $startTimeProfiler = 100050;
     $durationProfiler = 100;
     $this->benchmark->expects($this->once())->method('getStartTime')->willReturn($startTimeBenchmark);
     $this->profiler->expects($this->once())->method('getStartTime')->willReturn($startTimeProfiler);
     $this->profiler->expects($this->once())->method('getDuration')->willReturn($durationProfiler);
     $offset = $startTimeBenchmark - $startTimeProfiler;
     $expectedOffset = round($offset / ($durationProfiler * TimelineFormatter::TIMEBUFFER_FACTOR) * 100, 2);
     $this->assertSame($expectedOffset, $this->formatter->getOffset());
 }
Example #2
0
 /**
  * @param string $severity
  * @param string $colorClass
  * @dataProvider getLabels
  */
 public function testGetLabels($severity, $colorClass)
 {
     $this->benchmark->expects($this->any())->method('getMetadata')->willReturn(['severity' => $severity]);
     $this->assertSame($colorClass, $this->formatter->getLabel());
 }
 public function testGetMetadata()
 {
     $this->benchmark->expects($this->once())->method('getMetadata')->willReturn(['lorem' => 'ipsum']);
     $this->assertSame(['lorem' => 'ipsum'], $this->formatter->getMetadata());
 }
 public function testFormatMemoryUsage()
 {
     $this->assertSame('1.177 MB', BenchmarkFormatter::formatMemoryUsage(1234567));
 }