/** * @covers Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter::__construct * @covers Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter::setProfiler * @covers Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter::getProfiler * @uses Fabfuel\Prophiler\Toolbar\Formatter\BenchmarkFormatterAbstract */ public function testSetAndGetProfiler() { $profiler = $this->getProfilerMock(); $formatter = new TimelineFormatter($profiler); $this->assertSame($profiler, $formatter->getProfiler()); $anotherProfiler = $this->getProfilerMock(); $this->assertNotSame($anotherProfiler, $formatter->getProfiler()); $formatter->setProfiler($anotherProfiler); $this->assertSame($anotherProfiler, $formatter->getProfiler()); }
/** * @covers Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter::getOffset * @covers Fabfuel\Prophiler\Toolbar\Formatter\TimelineFormatter::getProfilerDuration * @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->any())->method('getStartTime')->willReturn($startTimeBenchmark); $this->profiler->expects($this->any())->method('getStartTime')->willReturn($startTimeProfiler); $this->profiler->expects($this->any())->method('getDuration')->willReturn($durationProfiler); $offset = $startTimeBenchmark - $startTimeProfiler; $expectedOffset = number_format($offset / ($durationProfiler * TimelineFormatter::TIMEBUFFER_FACTOR) * 100, 2, '.', ''); $this->assertSame($expectedOffset, $this->formatter->getOffset()); }