/** * Triggers end display of the profiling data * * @param object $dbConnection * @throws Exception */ public function display($dbConnection = null) { if (!isset($this->display)) { throw new Exception('Display object has not been injected into Profiler'); } if (!isset($this->console)) { throw new Exception('Console object has not been injected into Profiler'); } $this->display->setStartTime($this->startTime); $this->display->setConsole($this->console); $this->display->setFileData($this->gatherFileData()); $this->display->setMemoryData($this->gatherMemoryData()); $this->display->setQueryData($this->gatherQueryData($dbConnection)); $this->display->setSpeedData($this->gatherSpeedData()); $this->display->__invoke(); }
public function testDisplay() { $console = new Console(); $profiler = new PhpQuickProfiler(); $reflectedProfiler = new ReflectionClass(get_class($profiler)); $reflectedProperty = $reflectedProfiler->getProperty('startTime'); $reflectedProperty->setAccessible(true); $startTime = $reflectedProperty->getValue($profiler); $expectedDisplay = new Display(); $expectedDisplay->setStartTime($startTime); $expectedDisplay->setConsole($console); $expectedDisplay->setFileData($profiler->gatherFileData()); $expectedDisplay->setMemoryData($profiler->gatherMemoryData()); $expectedDisplay->setQueryData($profiler->gatherQueryData()); $expectedDisplay->setSpeedData($profiler->gatherSpeedData()); ob_start(); $expectedDisplay->__invoke(); ob_end_clean(); $display = new Display(); $profiler->setConsole($console); $profiler->setDisplay($display); ob_start(); $profiler->display(); ob_end_clean(); $this->assertAttributeEquals($expectedDisplay, 'display', $profiler); }