修正单元测试

This commit is contained in:
thinkphp
2016-06-29 22:24:56 +08:00
parent 1a91aaa882
commit da7ec5713b
5 changed files with 18 additions and 6 deletions

View File

@@ -150,7 +150,8 @@ return [
// | Trace设置
// +----------------------------------------------------------------------
'trace' => [
'type' => 'Html' //支持Html,Console 设为false则不显示
//支持Html,Console 设为false则不显示
'type' => false,
],
// +----------------------------------------------------------------------

View File

@@ -46,9 +46,15 @@ class Console
$reqs = number_format(1 / $runtime, 2);
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
if (isset($_SERVER['HTTP_HOST'])) {
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$uri = "cmd:" . implode(' ', $_SERVER['argv']);
}
// 页面Trace信息
$base = [
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri,
'运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()),
'查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ',
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',

View File

@@ -48,8 +48,13 @@ class Html
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
// 页面Trace信息
if (isset($_SERVER['HTTP_HOST'])) {
$uri = $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$uri = "cmd:" . implode(' ', $_SERVER['argv']);
}
$base = [
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $uri,
'运行时间' => "{$runtime}s [ 吞吐率:{$reqs}req/s ] 内存消耗:{$mem}kb 文件加载:" . count(get_included_files()),
'查询信息' => Db::$queryTimes . ' queries ' . Db::$executeTimes . ' writes ',
'缓存信息' => Cache::$readTimes . ' reads,' . Cache::$writeTimes . ' writes',

View File

@@ -54,10 +54,10 @@ class appTest extends \PHPUnit_Framework_TestCase
$this->expectOutputString($expectOutputString);
$rc = new ReflectionClass('\think\Loader');
$ns = $rc->getProperty('namespace');
$ns = $rc->getProperty('prefixDirsPsr4');
$ns->setAccessible(true);
$namespace = $ns->getValue();
$this->assertEquals(TEST_PATH, $namespace['tests']);
$this->assertEquals([TEST_PATH], $namespace['tests\\']);
$this->assertEquals(true, function_exists('lang'));
$this->assertEquals(true, function_exists('config'));

View File

@@ -84,7 +84,7 @@ class routeTest extends \PHPUnit_Framework_TestCase
Route::map('hello', 'index/hello');
$this->assertEquals('index/hello', Route::map('hello'));
$result = Route::check($request, 'hello');
$this->assertEquals(['index', 'hello', null], $result['module']);
$this->assertEquals([null, 'index', 'hello'], $result['module']);
}
public function testMixVar()