/** * 测试反向解析 */ function testReservedParse() { $context = QContext::instance(); $router = new QRouter($context); foreach ($this->_tests_args as $offset => $test) { $copy = $test; $path = $test['_path']; unset($test['_path']); $context->module_name = isset($test['module']) ? $test['module'] : null; $context->namespace = isset($test['namespace']) ? $test['namespace'] : null; $context->controller_name = isset($test['controller']) ? $test['controller'] : null; $context->action_name = isset($test['action']) ? $test['action'] : null; $context->setRequestUDI(); $test['module'] = $context->module_name; $test['namespace'] = $context->namespace; $test['controller'] = $context->controller_name; $test['action'] = $context->action_name; $result = $router->url($test); list($route_name) = explode(':', $offset); if ($route_name != $router->reserve_matched_route_name) { QDebug::dump($test, "Expected route name is [{$offset}] : {$path}."); } $this->assertEquals($route_name, $router->reserve_matched_route_name, "Expected route name is [{$route_name}]."); $this->assertEquals($path, $result, print_r($copy, true) . "\n" . print_r($test, true)); } }
/** * QDebug::dump() 的简写,用于输出一个变量的内容 * * @param mixed $vars 要输出的变量 * @param string $label 输出变量时显示的标签 * @param boolean $return 是否返回输出内容 * * @return string */ function dump($vars, $label = null, $return = false) { if ($return) { ob_start(); } QDebug::dump($vars, $label); if ($return) { $return = ob_get_clean(); return $return; } }
/** * 异常处理方法 * * @param Exception $ex */ function handler(Exception $ex) { QDebug::dump(__METHOD__); $this->_trans_failed = true; $this->_exception = $ex; }
/** * 析构函数 */ function __destruct() { // $this->_helper->release(); unset($this->_helper); $this->_helper = null; QDebug::dump(__METHOD__); if ($this->_trans_failed) { $this->rollback(); } else { $this->commit(); } }
/** * QDebug::dump() 的简写,用于输出一个变量的内容 * * @param mixed $vars 要输出的变量 * @param string $label 输出变量时显示的标签 * @param boolean $return 是否返回输出内容 * * @return string */ function dump($vars, $label = null, $return = false) { return QDebug::dump($vars, $label, $return); }