/** * Basic test for the basic funcitonality */ public function testDispatcher() { /** @var \PSFS\Dispatcher $dispatcher */ $dispatcher = Dispatcher::getInstance(); // Is instance of Dispatcher? $this->assertTrue($dispatcher instanceof Dispatcher); // Did timestamp generated? $this->assertTrue($dispatcher->getTs() > 0); }
/** * Método que mete en las variables de las plantillas las cabeceras de debug * @param array $vars * * @return array */ public static function setDebugHeaders(array $vars) { if (Config::getParam('debug', true)) { Logger::log('Adding debug headers to render response'); $vars["__DEBUG__"]["includes"] = get_included_files(); $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); } return $vars; }
/** * Método que devuelve una instancia del Dspatcher * @param PHPUnit_Framework_MockObject_MockObject $config * @param PHPUnit_Framework_MockObject_MockObject $router * @param PHPUnit_Framework_MockObject_MockObject $security * @return Dispatcher */ private function getInstance($config = null, $router = null, $security = null) { $dispatcher = Dispatcher::getInstance(); if (null !== $config) { $dispatcher->config = $config; } if (null !== $router) { $dispatcher->router = $router; } if (null !== $security) { $dispatcher->security = $security; } return $dispatcher; }
function pre($var, $die = FALSE) { $html = '<pre style="padding:10px;margin:0;display:block;background: #EEE; box-shadow: inset 0 0 3px 3px #DDD; color: #666; text-shadow: 1px 1px 1px #CCC;border-radius: 5px;">'; $html .= is_null($var) ? '<b>NULL</b>' : print_r($var, TRUE); $html .= '</pre>'; if (class_exists('\\PSFS\\Dispatcher')) { $html .= '<pre>[' . round(\PSFS\Dispatcher::getInstance()->getMem('MBytes'), 3) . 'Mb - ' . round(\PSFS\Dispatcher::getInstance()->getTs(), 3) . 's]</pre>'; } ob_start(); echo $html; ob_flush(); ob_end_clean(); if ($die) { if (class_exists('\\PSFS\\base\\Logger')) { \PSFS\base\Logger::log('Execution finished via pre', LOG_WARNING); } die; } }