diff --git a/console.php b/console.php
index 3d518e78..fa777801 100644
--- a/console.php
+++ b/console.php
@@ -17,4 +17,4 @@ require __DIR__ . '/base.php';
// 执行应用
App::initCommon();
-Console::init();
\ No newline at end of file
+Console::init();
diff --git a/library/think/Debug.php b/library/think/Debug.php
index 24acd3d3..0b5d022d 100644
--- a/library/think/Debug.php
+++ b/library/think/Debug.php
@@ -174,7 +174,7 @@ class Debug
$output = '
' . $label . $output . '
';
}
if ($echo) {
- echo ($output);
+ echo($output);
return;
} else {
return $output;
diff --git a/library/think/Session.php b/library/think/Session.php
index 6870e164..06adcff6 100644
--- a/library/think/Session.php
+++ b/library/think/Session.php
@@ -1,360 +1,360 @@
-
-// +----------------------------------------------------------------------
-
-namespace think;
-
-use think\exception\ClassNotFoundException;
-
-class Session
-{
- protected static $prefix = '';
- protected static $init = null;
-
- /**
- * 设置或者获取session作用域(前缀)
- * @param string $prefix
- * @return string|void
- */
- public static function prefix($prefix = '')
- {
- if (empty($prefix) && null !== $prefix) {
- return self::$prefix;
- } else {
- self::$prefix = $prefix;
- }
- }
-
- /**
- * session初始化
- * @param array $config
- * @return void
- * @throws \think\Exception
- */
- public static function init(array $config = [])
- {
- if (empty($config)) {
- $config = Config::get('session');
- }
- // 记录初始化信息
- App::$debug && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
- $isDoStart = false;
- if (isset($config['use_trans_sid'])) {
- ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
- }
-
- // 启动session
- if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
- ini_set('session.auto_start', 0);
- $isDoStart = true;
- }
-
- if (isset($config['prefix'])) {
- self::$prefix = $config['prefix'];
- }
- if (isset($config['var_session_id']) && isset($_REQUEST[$config['var_session_id']])) {
- session_id($_REQUEST[$config['var_session_id']]);
- } elseif (isset($config['id']) && !empty($config['id'])) {
- session_id($config['id']);
- }
- if (isset($config['name'])) {
- session_name($config['name']);
- }
- if (isset($config['path'])) {
- session_save_path($config['path']);
- }
- if (isset($config['domain'])) {
- ini_set('session.cookie_domain', $config['domain']);
- }
- if (isset($config['expire'])) {
- ini_set('session.gc_maxlifetime', $config['expire']);
- ini_set('session.cookie_lifetime', $config['expire']);
- }
-
- if (isset($config['use_cookies'])) {
- ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0);
- }
- if (isset($config['cache_limiter'])) {
- session_cache_limiter($config['cache_limiter']);
- }
- if (isset($config['cache_expire'])) {
- session_cache_expire($config['cache_expire']);
- }
- if (!empty($config['type'])) {
- // 读取session驱动
- $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']);
-
- // 检查驱动类
- if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
- throw new ClassNotFoundException('error session handler:' . $class, $class);
- }
- }
- if ($isDoStart) {
- session_start();
- self::$init = true;
- } else {
- self::$init = false;
- }
- }
-
- /**
- * session自动启动或者初始化
- * @return void
- */
- public static function boot()
- {
- if (is_null(self::$init)) {
- self::init();
- } elseif (false === self::$init) {
- if (PHP_SESSION_ACTIVE != session_status()) {
- session_start();
- }
- self::$init = true;
- }
- }
-
- /**
- * session设置
- * @param string $name session名称
- * @param mixed $value session值
- * @param string|null $prefix 作用域(前缀)
- * @return void
- */
- public static function set($name, $value = '', $prefix = null)
- {
- empty(self::$init) && self::boot();
-
- $prefix = !is_null($prefix) ? $prefix : self::$prefix;
- if (strpos($name, '.')) {
- // 二维数组赋值
- list($name1, $name2) = explode('.', $name);
- if ($prefix) {
- $_SESSION[$prefix][$name1][$name2] = $value;
- } else {
- $_SESSION[$name1][$name2] = $value;
- }
- } elseif ($prefix) {
- $_SESSION[$prefix][$name] = $value;
- } else {
- $_SESSION[$name] = $value;
- }
- }
-
- /**
- * session获取
- * @param string $name session名称
- * @param string|null $prefix 作用域(前缀)
- * @return mixed
- */
- public static function get($name = '', $prefix = null)
- {
- empty(self::$init) && self::boot();
- $prefix = !is_null($prefix) ? $prefix : self::$prefix;
- if ('' == $name) {
- // 获取全部的session
- $value = $prefix ? (!empty($_SESSION[$prefix]) ? $_SESSION[$prefix] : []) : $_SESSION;
- } elseif ($prefix) {
- // 获取session
- if (strpos($name, '.')) {
- list($name1, $name2) = explode('.', $name);
- $value = isset($_SESSION[$prefix][$name1][$name2]) ? $_SESSION[$prefix][$name1][$name2] : null;
- } else {
- $value = isset($_SESSION[$prefix][$name]) ? $_SESSION[$prefix][$name] : null;
- }
- } else {
- if (strpos($name, '.')) {
- list($name1, $name2) = explode('.', $name);
- $value = isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null;
- } else {
- $value = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
- }
- }
- return $value;
- }
-
- /**
- * session获取并删除
- * @param string $name session名称
- * @param string|null $prefix 作用域(前缀)
- * @return mixed
- */
- public static function pull($name, $prefix = null)
- {
- $result = self::get($name, $prefix);
- if ($result) {
- self::delete($name, $prefix);
- return $result;
- } else {
- return null;
- }
- }
-
- /**
- * session设置 下一次请求有效
- * @param string $name session名称
- * @param mixed $value session值
- * @param string|null $prefix 作用域(前缀)
- * @return void
- */
- public static function flash($name, $value)
- {
- self::set($name, $value);
- if (!self::has('__flash__.__time__')) {
- self::set('__flash__.__time__', $_SERVER['REQUEST_TIME_FLOAT']);
- }
- self::push('__flash__', $name);
- }
-
- /**
- * 清空当前请求的session数据
- * @return void
- */
- public static function flush()
- {
- if (self::$init) {
- $item = self::get('__flash__');
-
- if (!empty($item)) {
- $time = $item['__time__'];
- if ($_SERVER['REQUEST_TIME_FLOAT'] > $time) {
- unset($item['__time__']);
- self::delete($item);
- self::set('__flash__', []);
- }
- }
- }
- }
-
- /**
- * 删除session数据
- * @param string|array $name session名称
- * @param string|null $prefix 作用域(前缀)
- * @return void
- */
- public static function delete($name, $prefix = null)
- {
- empty(self::$init) && self::boot();
- $prefix = !is_null($prefix) ? $prefix : self::$prefix;
- if (is_array($name)) {
- foreach ($name as $key) {
- self::delete($key, $prefix);
- }
- } elseif (strpos($name, '.')) {
- list($name1, $name2) = explode('.', $name);
- if ($prefix) {
- unset($_SESSION[$prefix][$name1][$name2]);
- } else {
- unset($_SESSION[$name1][$name2]);
- }
- } else {
- if ($prefix) {
- unset($_SESSION[$prefix][$name]);
- } else {
- unset($_SESSION[$name]);
- }
- }
- }
-
- /**
- * 清空session数据
- * @param string|null $prefix 作用域(前缀)
- * @return void
- */
- public static function clear($prefix = null)
- {
- empty(self::$init) && self::boot();
- $prefix = !is_null($prefix) ? $prefix : self::$prefix;
- if ($prefix) {
- unset($_SESSION[$prefix]);
- } else {
- $_SESSION = [];
- }
- }
-
- /**
- * 判断session数据
- * @param string $name session名称
- * @param string|null $prefix
- * @return bool
- */
- public static function has($name, $prefix = null)
- {
- empty(self::$init) && self::boot();
- $prefix = !is_null($prefix) ? $prefix : self::$prefix;
- if (strpos($name, '.')) {
- // 支持数组
- list($name1, $name2) = explode('.', $name);
- return $prefix ? isset($_SESSION[$prefix][$name1][$name2]) : isset($_SESSION[$name1][$name2]);
- } else {
- return $prefix ? isset($_SESSION[$prefix][$name]) : isset($_SESSION[$name]);
- }
- }
-
- /**
- * 添加数据到一个session数组
- * @param string $key
- * @param mixed $value
- * @return void
- */
- public static function push($key, $value)
- {
- $array = self::get($key);
- if (is_null($array)) {
- $array = [];
- }
- $array[] = $value;
- self::set($key, $array);
- }
-
- /**
- * 启动session
- * @return void
- */
- public static function start()
- {
- session_start();
- self::$init = true;
- }
-
- /**
- * 销毁session
- * @return void
- */
- public static function destroy()
- {
- if (!empty($_SESSION)) {
- $_SESSION = [];
- }
- session_unset();
- session_destroy();
- self::$init = null;
- }
-
- /**
- * 重新生成session_id
- * @param bool $delete 是否删除关联会话文件
- * @return void
- */
- private static function regenerate($delete = false)
- {
- session_regenerate_id($delete);
- }
-
- /**
- * 暂停session
- * @return void
- */
- public static function pause()
- {
- // 暂停session
- session_write_close();
- self::$init = false;
- }
-}
+
+// +----------------------------------------------------------------------
+
+namespace think;
+
+use think\exception\ClassNotFoundException;
+
+class Session
+{
+ protected static $prefix = '';
+ protected static $init = null;
+
+ /**
+ * 设置或者获取session作用域(前缀)
+ * @param string $prefix
+ * @return string|void
+ */
+ public static function prefix($prefix = '')
+ {
+ if (empty($prefix) && null !== $prefix) {
+ return self::$prefix;
+ } else {
+ self::$prefix = $prefix;
+ }
+ }
+
+ /**
+ * session初始化
+ * @param array $config
+ * @return void
+ * @throws \think\Exception
+ */
+ public static function init(array $config = [])
+ {
+ if (empty($config)) {
+ $config = Config::get('session');
+ }
+ // 记录初始化信息
+ App::$debug && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
+ $isDoStart = false;
+ if (isset($config['use_trans_sid'])) {
+ ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
+ }
+
+ // 启动session
+ if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
+ ini_set('session.auto_start', 0);
+ $isDoStart = true;
+ }
+
+ if (isset($config['prefix'])) {
+ self::$prefix = $config['prefix'];
+ }
+ if (isset($config['var_session_id']) && isset($_REQUEST[$config['var_session_id']])) {
+ session_id($_REQUEST[$config['var_session_id']]);
+ } elseif (isset($config['id']) && !empty($config['id'])) {
+ session_id($config['id']);
+ }
+ if (isset($config['name'])) {
+ session_name($config['name']);
+ }
+ if (isset($config['path'])) {
+ session_save_path($config['path']);
+ }
+ if (isset($config['domain'])) {
+ ini_set('session.cookie_domain', $config['domain']);
+ }
+ if (isset($config['expire'])) {
+ ini_set('session.gc_maxlifetime', $config['expire']);
+ ini_set('session.cookie_lifetime', $config['expire']);
+ }
+
+ if (isset($config['use_cookies'])) {
+ ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0);
+ }
+ if (isset($config['cache_limiter'])) {
+ session_cache_limiter($config['cache_limiter']);
+ }
+ if (isset($config['cache_expire'])) {
+ session_cache_expire($config['cache_expire']);
+ }
+ if (!empty($config['type'])) {
+ // 读取session驱动
+ $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']);
+
+ // 检查驱动类
+ if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
+ throw new ClassNotFoundException('error session handler:' . $class, $class);
+ }
+ }
+ if ($isDoStart) {
+ session_start();
+ self::$init = true;
+ } else {
+ self::$init = false;
+ }
+ }
+
+ /**
+ * session自动启动或者初始化
+ * @return void
+ */
+ public static function boot()
+ {
+ if (is_null(self::$init)) {
+ self::init();
+ } elseif (false === self::$init) {
+ if (PHP_SESSION_ACTIVE != session_status()) {
+ session_start();
+ }
+ self::$init = true;
+ }
+ }
+
+ /**
+ * session设置
+ * @param string $name session名称
+ * @param mixed $value session值
+ * @param string|null $prefix 作用域(前缀)
+ * @return void
+ */
+ public static function set($name, $value = '', $prefix = null)
+ {
+ empty(self::$init) && self::boot();
+
+ $prefix = !is_null($prefix) ? $prefix : self::$prefix;
+ if (strpos($name, '.')) {
+ // 二维数组赋值
+ list($name1, $name2) = explode('.', $name);
+ if ($prefix) {
+ $_SESSION[$prefix][$name1][$name2] = $value;
+ } else {
+ $_SESSION[$name1][$name2] = $value;
+ }
+ } elseif ($prefix) {
+ $_SESSION[$prefix][$name] = $value;
+ } else {
+ $_SESSION[$name] = $value;
+ }
+ }
+
+ /**
+ * session获取
+ * @param string $name session名称
+ * @param string|null $prefix 作用域(前缀)
+ * @return mixed
+ */
+ public static function get($name = '', $prefix = null)
+ {
+ empty(self::$init) && self::boot();
+ $prefix = !is_null($prefix) ? $prefix : self::$prefix;
+ if ('' == $name) {
+ // 获取全部的session
+ $value = $prefix ? (!empty($_SESSION[$prefix]) ? $_SESSION[$prefix] : []) : $_SESSION;
+ } elseif ($prefix) {
+ // 获取session
+ if (strpos($name, '.')) {
+ list($name1, $name2) = explode('.', $name);
+ $value = isset($_SESSION[$prefix][$name1][$name2]) ? $_SESSION[$prefix][$name1][$name2] : null;
+ } else {
+ $value = isset($_SESSION[$prefix][$name]) ? $_SESSION[$prefix][$name] : null;
+ }
+ } else {
+ if (strpos($name, '.')) {
+ list($name1, $name2) = explode('.', $name);
+ $value = isset($_SESSION[$name1][$name2]) ? $_SESSION[$name1][$name2] : null;
+ } else {
+ $value = isset($_SESSION[$name]) ? $_SESSION[$name] : null;
+ }
+ }
+ return $value;
+ }
+
+ /**
+ * session获取并删除
+ * @param string $name session名称
+ * @param string|null $prefix 作用域(前缀)
+ * @return mixed
+ */
+ public static function pull($name, $prefix = null)
+ {
+ $result = self::get($name, $prefix);
+ if ($result) {
+ self::delete($name, $prefix);
+ return $result;
+ } else {
+ return;
+ }
+ }
+
+ /**
+ * session设置 下一次请求有效
+ * @param string $name session名称
+ * @param mixed $value session值
+ * @param string|null $prefix 作用域(前缀)
+ * @return void
+ */
+ public static function flash($name, $value)
+ {
+ self::set($name, $value);
+ if (!self::has('__flash__.__time__')) {
+ self::set('__flash__.__time__', $_SERVER['REQUEST_TIME_FLOAT']);
+ }
+ self::push('__flash__', $name);
+ }
+
+ /**
+ * 清空当前请求的session数据
+ * @return void
+ */
+ public static function flush()
+ {
+ if (self::$init) {
+ $item = self::get('__flash__');
+
+ if (!empty($item)) {
+ $time = $item['__time__'];
+ if ($_SERVER['REQUEST_TIME_FLOAT'] > $time) {
+ unset($item['__time__']);
+ self::delete($item);
+ self::set('__flash__', []);
+ }
+ }
+ }
+ }
+
+ /**
+ * 删除session数据
+ * @param string|array $name session名称
+ * @param string|null $prefix 作用域(前缀)
+ * @return void
+ */
+ public static function delete($name, $prefix = null)
+ {
+ empty(self::$init) && self::boot();
+ $prefix = !is_null($prefix) ? $prefix : self::$prefix;
+ if (is_array($name)) {
+ foreach ($name as $key) {
+ self::delete($key, $prefix);
+ }
+ } elseif (strpos($name, '.')) {
+ list($name1, $name2) = explode('.', $name);
+ if ($prefix) {
+ unset($_SESSION[$prefix][$name1][$name2]);
+ } else {
+ unset($_SESSION[$name1][$name2]);
+ }
+ } else {
+ if ($prefix) {
+ unset($_SESSION[$prefix][$name]);
+ } else {
+ unset($_SESSION[$name]);
+ }
+ }
+ }
+
+ /**
+ * 清空session数据
+ * @param string|null $prefix 作用域(前缀)
+ * @return void
+ */
+ public static function clear($prefix = null)
+ {
+ empty(self::$init) && self::boot();
+ $prefix = !is_null($prefix) ? $prefix : self::$prefix;
+ if ($prefix) {
+ unset($_SESSION[$prefix]);
+ } else {
+ $_SESSION = [];
+ }
+ }
+
+ /**
+ * 判断session数据
+ * @param string $name session名称
+ * @param string|null $prefix
+ * @return bool
+ */
+ public static function has($name, $prefix = null)
+ {
+ empty(self::$init) && self::boot();
+ $prefix = !is_null($prefix) ? $prefix : self::$prefix;
+ if (strpos($name, '.')) {
+ // 支持数组
+ list($name1, $name2) = explode('.', $name);
+ return $prefix ? isset($_SESSION[$prefix][$name1][$name2]) : isset($_SESSION[$name1][$name2]);
+ } else {
+ return $prefix ? isset($_SESSION[$prefix][$name]) : isset($_SESSION[$name]);
+ }
+ }
+
+ /**
+ * 添加数据到一个session数组
+ * @param string $key
+ * @param mixed $value
+ * @return void
+ */
+ public static function push($key, $value)
+ {
+ $array = self::get($key);
+ if (is_null($array)) {
+ $array = [];
+ }
+ $array[] = $value;
+ self::set($key, $array);
+ }
+
+ /**
+ * 启动session
+ * @return void
+ */
+ public static function start()
+ {
+ session_start();
+ self::$init = true;
+ }
+
+ /**
+ * 销毁session
+ * @return void
+ */
+ public static function destroy()
+ {
+ if (!empty($_SESSION)) {
+ $_SESSION = [];
+ }
+ session_unset();
+ session_destroy();
+ self::$init = null;
+ }
+
+ /**
+ * 重新生成session_id
+ * @param bool $delete 是否删除关联会话文件
+ * @return void
+ */
+ private static function regenerate($delete = false)
+ {
+ session_regenerate_id($delete);
+ }
+
+ /**
+ * 暂停session
+ * @return void
+ */
+ public static function pause()
+ {
+ // 暂停session
+ session_write_close();
+ self::$init = false;
+ }
+}
diff --git a/library/think/Url.php b/library/think/Url.php
index 75fffac6..a1bc8d2a 100644
--- a/library/think/Url.php
+++ b/library/think/Url.php
@@ -248,7 +248,7 @@ class Url
$domain .= $rootDomain;
}
break;
- } else if (false !== strpos($key, '*')) {
+ } elseif (false !== strpos($key, '*')) {
if (!empty($rootDomain)) {
$domain .= $rootDomain;
}
diff --git a/library/think/console/command/Lists.php b/library/think/console/command/Lists.php
index ffbee07c..084ddaa2 100644
--- a/library/think/console/command/Lists.php
+++ b/library/think/console/command/Lists.php
@@ -71,4 +71,4 @@ EOF
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list')
]);
}
-}
\ No newline at end of file
+}
diff --git a/library/think/console/command/optimize/Autoload.php b/library/think/console/command/optimize/Autoload.php
index 0481e179..7311aafb 100644
--- a/library/think/console/command/optimize/Autoload.php
+++ b/library/think/console/command/optimize/Autoload.php
@@ -278,4 +278,4 @@ EOF;
return $classes;
}
-}
\ No newline at end of file
+}
diff --git a/library/think/console/output/Ask.php b/library/think/console/output/Ask.php
index 4d360bce..3933eb29 100644
--- a/library/think/console/output/Ask.php
+++ b/library/think/console/output/Ask.php
@@ -337,4 +337,4 @@ class Ask
return self::$stty = $exitcode === 0;
}
-}
\ No newline at end of file
+}
diff --git a/library/think/paginator/Collection.php b/library/think/paginator/Collection.php
index 82e88272..50803ba8 100644
--- a/library/think/paginator/Collection.php
+++ b/library/think/paginator/Collection.php
@@ -71,4 +71,4 @@ class Collection extends \think\Collection
throw new Exception('method not exists:' . __CLASS__ . '->' . $method);
}
}
-}
\ No newline at end of file
+}
diff --git a/library/think/paginator/driver/Bootstrap.php b/library/think/paginator/driver/Bootstrap.php
index 87e1fe48..13b7bccd 100644
--- a/library/think/paginator/driver/Bootstrap.php
+++ b/library/think/paginator/driver/Bootstrap.php
@@ -102,7 +102,6 @@ class Bootstrap extends Paginator
return $html;
}
-
/**
* 渲染分页html
* @return mixed
@@ -127,7 +126,6 @@ class Bootstrap extends Paginator
}
}
-
/**
* 生成一个可点击的按钮
*
@@ -204,4 +202,4 @@ class Bootstrap extends Paginator
return $this->getAvailablePageWrapper($url, $page);
}
-}
\ No newline at end of file
+}
diff --git a/library/think/process/exception/Timeout.php b/library/think/process/exception/Timeout.php
index c085ee8e..d5f1162f 100644
--- a/library/think/process/exception/Timeout.php
+++ b/library/think/process/exception/Timeout.php
@@ -58,4 +58,4 @@ class Timeout extends \RuntimeException
throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
}
}
-}
\ No newline at end of file
+}
diff --git a/library/think/process/pipes/Pipes.php b/library/think/process/pipes/Pipes.php
index 51da44f3..82396b8f 100644
--- a/library/think/process/pipes/Pipes.php
+++ b/library/think/process/pipes/Pipes.php
@@ -53,7 +53,6 @@ abstract class Pipes
*/
abstract public function areOpen();
-
/**
* {@inheritdoc}
*/
@@ -91,4 +90,4 @@ abstract class Pipes
$this->blocked = false;
}
-}
\ No newline at end of file
+}
diff --git a/tests/mock.php b/tests/mock.php
index 28471ee2..0c29e596 100644
--- a/tests/mock.php
+++ b/tests/mock.php
@@ -1,20 +1,20 @@
-
-// +----------------------------------------------------------------------
-
-// 测试入口文件
-$_SERVER['REQUEST_METHOD'] = 'GET';
-// 定义项目测试基础路径
-define('TEST_PATH', __DIR__ . '/');
-// 定义项目路径
-define('APP_PATH', __DIR__ . '/application/');
-// 加载框架基础文件
-require __DIR__ . '/../base.php';
-\think\Loader::addNamespace('tests', TEST_PATH);
+
+// +----------------------------------------------------------------------
+
+// 测试入口文件
+$_SERVER['REQUEST_METHOD'] = 'GET';
+// 定义项目测试基础路径
+define('TEST_PATH', __DIR__ . '/');
+// 定义项目路径
+define('APP_PATH', __DIR__ . '/application/');
+// 加载框架基础文件
+require __DIR__ . '/../base.php';
+\think\Loader::addNamespace('tests', TEST_PATH);
diff --git a/tests/thinkphp/library/think/appTest.php b/tests/thinkphp/library/think/appTest.php
index 366b4f55..016bbf9c 100644
--- a/tests/thinkphp/library/think/appTest.php
+++ b/tests/thinkphp/library/think/appTest.php
@@ -16,7 +16,6 @@
namespace tests\thinkphp\library\think;
-use ReflectionClass;
use think\App;
use think\Config;
use think\Request;
diff --git a/tests/thinkphp/library/think/behavior/One.php b/tests/thinkphp/library/think/behavior/One.php
index ae8fa49d..1ec6e66e 100644
--- a/tests/thinkphp/library/think/behavior/One.php
+++ b/tests/thinkphp/library/think/behavior/One.php
@@ -3,12 +3,12 @@ namespace tests\thinkphp\library\think\behavior;
class One
{
- public function run(&$data){
+ public function run(&$data) {
$data['id'] = 1;
return true;
}
- public function test(&$data){
+ public function test(&$data) {
$data['name'] = 'test';
return false;
}
diff --git a/tests/thinkphp/library/think/behavior/Three.php b/tests/thinkphp/library/think/behavior/Three.php
index 0f2e0495..c98b7aeb 100644
--- a/tests/thinkphp/library/think/behavior/Three.php
+++ b/tests/thinkphp/library/think/behavior/Three.php
@@ -3,7 +3,7 @@ namespace tests\thinkphp\library\think\behavior;
class Three
{
- public function run(&$data){
+ public function run(&$data) {
$data['id'] = 3;
}
}
diff --git a/tests/thinkphp/library/think/behavior/Two.php b/tests/thinkphp/library/think/behavior/Two.php
index 3e194bf5..1e52a2b5 100644
--- a/tests/thinkphp/library/think/behavior/Two.php
+++ b/tests/thinkphp/library/think/behavior/Two.php
@@ -3,7 +3,7 @@ namespace tests\thinkphp\library\think\behavior;
class Two
{
- public function run(&$data){
+ public function run(&$data) {
$data['id'] = 2;
}
}
diff --git a/tests/thinkphp/library/think/cache/driver/cacheTestCase.php b/tests/thinkphp/library/think/cache/driver/cacheTestCase.php
index ec8f9b6b..5b2f2a3e 100644
--- a/tests/thinkphp/library/think/cache/driver/cacheTestCase.php
+++ b/tests/thinkphp/library/think/cache/driver/cacheTestCase.php
@@ -1,207 +1,207 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * 缓存抽象类,提供一些测试
- * @author simon
- */
-
-namespace tests\thinkphp\library\think\cache\driver;
-
-use think\Cache;
-
-abstract class cacheTestCase extends \PHPUnit_Framework_TestCase
-{
-
- /**
- * 获取缓存句柄,子类必须有
- * @access protected
- */
- abstract protected function getCacheInstance();
-
- /**
- * tearDown函数
- */
- protected function tearDown()
- {
- }
-
- /**
- * 设定一组测试值,包括测试字符串、整数、数组和对象
- * @return mixed
- * @access public
- */
- public function prepare()
- {
- $cache = $this->getCacheInstance();
- $cache->clear();
- $cache->set('string_test', 'string_test');
- $cache->set('number_test', 11);
- $cache->set('array_test', ['array_test' => 'array_test']);
- return $cache;
- }
-
- /**
- * 测试缓存设置,包括测试字符串、整数、数组和对象
- * @return mixed
- * @access public
- */
- public function testSet()
- {
- $cache = $this->getCacheInstance();
- $this->assertTrue($cache->set('string_test', 'string_test'));
- $this->assertTrue($cache->set('number_test', 11));
- $this->assertTrue($cache->set('array_test', ['array_test' => 'array_test']));
- }
-
- /**
- * 测试缓存自增
- * @return mixed
- * @access public
- */
- public function testInc()
- {
- $cache = $this->getCacheInstance();
- $this->assertEquals(14, $cache->inc('number_test', 3));
- }
-
- /**
- * 测试缓存自减
- * @return mixed
- * @access public
- */
- public function testDec()
- {
- $cache = $this->getCacheInstance();
- $this->assertEquals(8, $cache->dec('number_test', 6));
- }
-
- /**
- * 测试缓存读取,包括测试字符串、整数、数组和对象
- * @return mixed
- * @access public
- */
- public function testGet()
- {
- $cache = $this->prepare();
- $this->assertEquals('string_test', $cache->get('string_test'));
- $this->assertEquals(11, $cache->get('number_test'));
- $array = $cache->get('array_test');
- $this->assertArrayHasKey('array_test', $array);
- $this->assertEquals('array_test', $array['array_test']);
-
- $result = $cache->set('no_expire', 1, 0);
- $this->assertTrue($result);
- }
-
- /**
- * 测试缓存存在情况,包括测试字符串、整数、数组和对象
- * @return mixed
- * @access public
- */
- public function testExists()
- {
- $cache = $this->prepare();
- $this->assertNotEmpty($cache->has('string_test'));
- $this->assertNotEmpty($cache->has('number_test'));
- $this->assertFalse($cache->has('not_exists'));
- }
-
- /**
- * 测试缓存不存在情况,包括测试字符串、整数、数组和对象
- * @return mixed
- * @access public
- */
- public function testGetNonExistent()
- {
- $cache = $this->getCacheInstance();
- $this->assertFalse($cache->get('non_existent_key', false));
- }
-
- /**
- * 测试特殊值缓存,包括测试字符串、整数、数组和对象
- * @return mixed
- * @access public
- */
- public function testStoreSpecialValues()
- {
- $cache = $this->getCacheInstance();
- $cache->set('null_value', null);
- //清空缓存后,返回null而不是false
- $this->assertTrue(is_null($cache->get('null_value')));
- }
-
- /**
- * 缓存过期测试
- * @return mixed
- * @access public
- */
- public function testExpire()
- {
- $cache = $this->getCacheInstance();
- $this->assertTrue($cache->set('expire_test', 'expire_test', 1));
- usleep(600000);
- $this->assertEquals('expire_test', $cache->get('expire_test'));
- usleep(800000);
- $this->assertFalse($cache->get('expire_test'));
- }
-
- /**
- * 删除缓存测试
- * @return mixed
- * @access public
- */
- public function testDelete()
- {
- $cache = $this->prepare();
- $this->assertNotNull($cache->rm('number_test'));
- $this->assertFalse($cache->get('number_test'));
- }
-
- /**
- * 获取并删除缓存测试
- * @return mixed
- * @access public
- */
- public function testPull()
- {
- $cache = $this->prepare();
- $this->assertEquals(11, $cache->pull('number_test'));
- $this->assertFalse($cache->get('number_test'));
- }
-
- /**
- * 清空缓存测试
- * @return mixed
- * @access public
- */
- public function testClear()
- {
- $cache = $this->prepare();
- $this->assertTrue($cache->clear());
- $this->assertFalse($cache->get('number_test'));
- }
-
- public function testStaticCall()
- {
- $this->assertTrue(Cache::set('a', 1));
- $this->assertEquals(1, Cache::get('a'));
- $this->assertEquals(2, Cache::inc('a'));
- $this->assertEquals(4, Cache::inc('a', 2));
- $this->assertEquals(4, Cache::get('a'));
- $this->assertEquals(3, Cache::dec('a'));
- $this->assertEquals(1, Cache::dec('a', 2));
- $this->assertEquals(1, Cache::get('a'));
- $this->assertNotNull(Cache::rm('a'));
- $this->assertNotNull(Cache::clear());
- }
-
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * 缓存抽象类,提供一些测试
+ * @author simon
+ */
+
+namespace tests\thinkphp\library\think\cache\driver;
+
+use think\Cache;
+
+abstract class cacheTestCase extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * 获取缓存句柄,子类必须有
+ * @access protected
+ */
+ abstract protected function getCacheInstance();
+
+ /**
+ * tearDown函数
+ */
+ protected function tearDown()
+ {
+ }
+
+ /**
+ * 设定一组测试值,包括测试字符串、整数、数组和对象
+ * @return mixed
+ * @access public
+ */
+ public function prepare()
+ {
+ $cache = $this->getCacheInstance();
+ $cache->clear();
+ $cache->set('string_test', 'string_test');
+ $cache->set('number_test', 11);
+ $cache->set('array_test', ['array_test' => 'array_test']);
+ return $cache;
+ }
+
+ /**
+ * 测试缓存设置,包括测试字符串、整数、数组和对象
+ * @return mixed
+ * @access public
+ */
+ public function testSet()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertTrue($cache->set('string_test', 'string_test'));
+ $this->assertTrue($cache->set('number_test', 11));
+ $this->assertTrue($cache->set('array_test', ['array_test' => 'array_test']));
+ }
+
+ /**
+ * 测试缓存自增
+ * @return mixed
+ * @access public
+ */
+ public function testInc()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertEquals(14, $cache->inc('number_test', 3));
+ }
+
+ /**
+ * 测试缓存自减
+ * @return mixed
+ * @access public
+ */
+ public function testDec()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertEquals(8, $cache->dec('number_test', 6));
+ }
+
+ /**
+ * 测试缓存读取,包括测试字符串、整数、数组和对象
+ * @return mixed
+ * @access public
+ */
+ public function testGet()
+ {
+ $cache = $this->prepare();
+ $this->assertEquals('string_test', $cache->get('string_test'));
+ $this->assertEquals(11, $cache->get('number_test'));
+ $array = $cache->get('array_test');
+ $this->assertArrayHasKey('array_test', $array);
+ $this->assertEquals('array_test', $array['array_test']);
+
+ $result = $cache->set('no_expire', 1, 0);
+ $this->assertTrue($result);
+ }
+
+ /**
+ * 测试缓存存在情况,包括测试字符串、整数、数组和对象
+ * @return mixed
+ * @access public
+ */
+ public function testExists()
+ {
+ $cache = $this->prepare();
+ $this->assertNotEmpty($cache->has('string_test'));
+ $this->assertNotEmpty($cache->has('number_test'));
+ $this->assertFalse($cache->has('not_exists'));
+ }
+
+ /**
+ * 测试缓存不存在情况,包括测试字符串、整数、数组和对象
+ * @return mixed
+ * @access public
+ */
+ public function testGetNonExistent()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertFalse($cache->get('non_existent_key', false));
+ }
+
+ /**
+ * 测试特殊值缓存,包括测试字符串、整数、数组和对象
+ * @return mixed
+ * @access public
+ */
+ public function testStoreSpecialValues()
+ {
+ $cache = $this->getCacheInstance();
+ $cache->set('null_value', null);
+ //清空缓存后,返回null而不是false
+ $this->assertTrue(is_null($cache->get('null_value')));
+ }
+
+ /**
+ * 缓存过期测试
+ * @return mixed
+ * @access public
+ */
+ public function testExpire()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertTrue($cache->set('expire_test', 'expire_test', 1));
+ usleep(600000);
+ $this->assertEquals('expire_test', $cache->get('expire_test'));
+ usleep(800000);
+ $this->assertFalse($cache->get('expire_test'));
+ }
+
+ /**
+ * 删除缓存测试
+ * @return mixed
+ * @access public
+ */
+ public function testDelete()
+ {
+ $cache = $this->prepare();
+ $this->assertNotNull($cache->rm('number_test'));
+ $this->assertFalse($cache->get('number_test'));
+ }
+
+ /**
+ * 获取并删除缓存测试
+ * @return mixed
+ * @access public
+ */
+ public function testPull()
+ {
+ $cache = $this->prepare();
+ $this->assertEquals(11, $cache->pull('number_test'));
+ $this->assertFalse($cache->get('number_test'));
+ }
+
+ /**
+ * 清空缓存测试
+ * @return mixed
+ * @access public
+ */
+ public function testClear()
+ {
+ $cache = $this->prepare();
+ $this->assertTrue($cache->clear());
+ $this->assertFalse($cache->get('number_test'));
+ }
+
+ public function testStaticCall()
+ {
+ $this->assertTrue(Cache::set('a', 1));
+ $this->assertEquals(1, Cache::get('a'));
+ $this->assertEquals(2, Cache::inc('a'));
+ $this->assertEquals(4, Cache::inc('a', 2));
+ $this->assertEquals(4, Cache::get('a'));
+ $this->assertEquals(3, Cache::dec('a'));
+ $this->assertEquals(1, Cache::dec('a', 2));
+ $this->assertEquals(1, Cache::get('a'));
+ $this->assertNotNull(Cache::rm('a'));
+ $this->assertNotNull(Cache::clear());
+ }
+
+}
diff --git a/tests/thinkphp/library/think/cache/driver/fileTest.php b/tests/thinkphp/library/think/cache/driver/fileTest.php
index aee0bd46..eb2099ce 100644
--- a/tests/thinkphp/library/think/cache/driver/fileTest.php
+++ b/tests/thinkphp/library/think/cache/driver/fileTest.php
@@ -1,46 +1,46 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * File缓存驱动测试
- * @author 刘志淳
- */
-
-namespace tests\thinkphp\library\think\cache\driver;
-
-class fileTest extends cacheTestCase
-{
- private $_cacheInstance = null;
-
- /**
- * 基境缓存类型
- */
- protected function setUp()
- {
- \think\Cache::connect(['type' => 'File', 'path' => CACHE_PATH]);
- }
-
- /**
- * @return FileCache
- */
- protected function getCacheInstance()
- {
- if (null === $this->_cacheInstance) {
- $this->_cacheInstance = new \think\cache\driver\File();
- }
- return $this->_cacheInstance;
- }
-
- // skip testExpire
- public function testExpire()
- {
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * File缓存驱动测试
+ * @author 刘志淳
+ */
+
+namespace tests\thinkphp\library\think\cache\driver;
+
+class fileTest extends cacheTestCase
+{
+ private $_cacheInstance = null;
+
+ /**
+ * 基境缓存类型
+ */
+ protected function setUp()
+ {
+ \think\Cache::connect(['type' => 'File', 'path' => CACHE_PATH]);
+ }
+
+ /**
+ * @return FileCache
+ */
+ protected function getCacheInstance()
+ {
+ if (null === $this->_cacheInstance) {
+ $this->_cacheInstance = new \think\cache\driver\File();
+ }
+ return $this->_cacheInstance;
+ }
+
+ // skip testExpire
+ public function testExpire()
+ {
+ }
+}
diff --git a/tests/thinkphp/library/think/cache/driver/liteTest.php b/tests/thinkphp/library/think/cache/driver/liteTest.php
index b52bdff9..19cbb9ef 100644
--- a/tests/thinkphp/library/think/cache/driver/liteTest.php
+++ b/tests/thinkphp/library/think/cache/driver/liteTest.php
@@ -1,69 +1,69 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Lite缓存驱动测试
- * @author 刘志淳
- */
-
-namespace tests\thinkphp\library\think\cache\driver;
-
-use think\Cache;
-
-class liteTest extends \PHPUnit_Framework_TestCase
-{
- protected function getCacheInstance()
- {
- return Cache::connect(['type' => 'Lite', 'path' => CACHE_PATH]);
- }
-
- /**
- * 测试缓存读取
- * @return mixed
- * @access public
- */
- public function testGet()
- {
- $cache = $this->getCacheInstance();
- $this->assertFalse($cache->get('test'));
- }
-
- /**
- * 测试缓存设置
- * @return mixed
- * @access public
- */
- public function testSet()
- {
- $cache = $this->getCacheInstance();
- $this->assertNotEmpty($cache->set('test', 'test'));
- }
-
- /**
- * 删除缓存测试
- * @return mixed
- * @access public
- */
- public function testRm()
- {
- $cache = $this->getCacheInstance();
- $this->assertTrue($cache->rm('test'));
- }
-
- /**
- * 清空缓存测试
- * @return mixed
- * @access public
- */
- public function testClear()
- {
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Lite缓存驱动测试
+ * @author 刘志淳
+ */
+
+namespace tests\thinkphp\library\think\cache\driver;
+
+use think\Cache;
+
+class liteTest extends \PHPUnit_Framework_TestCase
+{
+ protected function getCacheInstance()
+ {
+ return Cache::connect(['type' => 'Lite', 'path' => CACHE_PATH]);
+ }
+
+ /**
+ * 测试缓存读取
+ * @return mixed
+ * @access public
+ */
+ public function testGet()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertFalse($cache->get('test'));
+ }
+
+ /**
+ * 测试缓存设置
+ * @return mixed
+ * @access public
+ */
+ public function testSet()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertNotEmpty($cache->set('test', 'test'));
+ }
+
+ /**
+ * 删除缓存测试
+ * @return mixed
+ * @access public
+ */
+ public function testRm()
+ {
+ $cache = $this->getCacheInstance();
+ $this->assertTrue($cache->rm('test'));
+ }
+
+ /**
+ * 清空缓存测试
+ * @return mixed
+ * @access public
+ */
+ public function testClear()
+ {
+ }
+}
diff --git a/tests/thinkphp/library/think/cache/driver/memcacheTest.php b/tests/thinkphp/library/think/cache/driver/memcacheTest.php
index 15dfaa5a..8975fa20 100644
--- a/tests/thinkphp/library/think/cache/driver/memcacheTest.php
+++ b/tests/thinkphp/library/think/cache/driver/memcacheTest.php
@@ -1,49 +1,49 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Memcache缓存驱动测试
- * @author 刘志淳
- */
-
-namespace tests\thinkphp\library\think\cache\driver;
-
-class memcacheTest extends cacheTestCase
-{
- private $_cacheInstance = null;
-
- /**
- * 基境缓存类型
- */
- protected function setUp()
- {
- if (!extension_loaded('memcache')) {
- $this->markTestSkipped("Memcache没有安装,已跳过测试!");
- }
- \think\Cache::connect(['type' => 'memcache', 'expire' => 2]);
- }
-
- /**
- * @return ApcCache
- */
- protected function getCacheInstance()
- {
- if (null === $this->_cacheInstance) {
- $this->_cacheInstance = new \think\cache\driver\Memcache(['length' => 3]);
- }
- return $this->_cacheInstance;
- }
-
- // skip testExpire
- public function testExpire()
- {
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Memcache缓存驱动测试
+ * @author 刘志淳
+ */
+
+namespace tests\thinkphp\library\think\cache\driver;
+
+class memcacheTest extends cacheTestCase
+{
+ private $_cacheInstance = null;
+
+ /**
+ * 基境缓存类型
+ */
+ protected function setUp()
+ {
+ if (!extension_loaded('memcache')) {
+ $this->markTestSkipped("Memcache没有安装,已跳过测试!");
+ }
+ \think\Cache::connect(['type' => 'memcache', 'expire' => 2]);
+ }
+
+ /**
+ * @return ApcCache
+ */
+ protected function getCacheInstance()
+ {
+ if (null === $this->_cacheInstance) {
+ $this->_cacheInstance = new \think\cache\driver\Memcache(['length' => 3]);
+ }
+ return $this->_cacheInstance;
+ }
+
+ // skip testExpire
+ public function testExpire()
+ {
+ }
+}
diff --git a/tests/thinkphp/library/think/cache/driver/memcachedTest.php b/tests/thinkphp/library/think/cache/driver/memcachedTest.php
index 58bcbd88..d528dd22 100644
--- a/tests/thinkphp/library/think/cache/driver/memcachedTest.php
+++ b/tests/thinkphp/library/think/cache/driver/memcachedTest.php
@@ -1,72 +1,72 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Memcached缓存驱动测试
- * @author 7IN0SAN9
- */
-
-namespace tests\thinkphp\library\think\cache\driver;
-
-class memcachedTest extends cacheTestCase
-{
- private $_cacheInstance = null;
- /**
- * 基境缓存类型
- */
- protected function setUp()
- {
- if (!extension_loaded("memcached") && !extension_loaded('memcache')) {
- $this->markTestSkipped("Memcached或Memcache没有安装,已跳过测试!");
- }
- \think\Cache::connect(array('type' => 'memcached', 'expire' => 2));
- }
- /**
- * @return ApcCache
- */
- protected function getCacheInstance()
- {
- if (null === $this->_cacheInstance) {
- $this->_cacheInstance = new \think\cache\driver\Memcached(['length' => 3]);
- }
- return $this->_cacheInstance;
- }
- /**
- * 缓存过期测试《提出来测试,因为目前看通不过缓存过期测试,所以还需研究》
- * @return mixed
- * @access public
- */
- public function testExpire()
- {
- }
-
- public function testStaticCall()
- {
- }
-
- /**
- * 测试缓存自增
- * @return mixed
- * @access public
- */
- public function testInc()
- {
- }
-
- /**
- * 测试缓存自减
- * @return mixed
- * @access public
- */
- public function testDec()
- {
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Memcached缓存驱动测试
+ * @author 7IN0SAN9
+ */
+
+namespace tests\thinkphp\library\think\cache\driver;
+
+class memcachedTest extends cacheTestCase
+{
+ private $_cacheInstance = null;
+ /**
+ * 基境缓存类型
+ */
+ protected function setUp()
+ {
+ if (!extension_loaded("memcached") && !extension_loaded('memcache')) {
+ $this->markTestSkipped("Memcached或Memcache没有安装,已跳过测试!");
+ }
+ \think\Cache::connect(array('type' => 'memcached', 'expire' => 2));
+ }
+ /**
+ * @return ApcCache
+ */
+ protected function getCacheInstance()
+ {
+ if (null === $this->_cacheInstance) {
+ $this->_cacheInstance = new \think\cache\driver\Memcached(['length' => 3]);
+ }
+ return $this->_cacheInstance;
+ }
+ /**
+ * 缓存过期测试《提出来测试,因为目前看通不过缓存过期测试,所以还需研究》
+ * @return mixed
+ * @access public
+ */
+ public function testExpire()
+ {
+ }
+
+ public function testStaticCall()
+ {
+ }
+
+ /**
+ * 测试缓存自增
+ * @return mixed
+ * @access public
+ */
+ public function testInc()
+ {
+ }
+
+ /**
+ * 测试缓存自减
+ * @return mixed
+ * @access public
+ */
+ public function testDec()
+ {
+ }
+}
diff --git a/tests/thinkphp/library/think/controllerTest.php b/tests/thinkphp/library/think/controllerTest.php
index ce5f49a0..fba8d6c5 100644
--- a/tests/thinkphp/library/think/controllerTest.php
+++ b/tests/thinkphp/library/think/controllerTest.php
@@ -40,13 +40,13 @@ class Foo extends Controller
public function fetchTest()
{
- $template = dirname(__FILE__) . '/display.html';
- return $this->fetch($template, ['name' => 'ThinkPHP']);
+ $template = dirname(__FILE__) . '/display.html';
+ return $this->fetch($template, ['name' => 'ThinkPHP']);
}
public function displayTest()
{
- $template = dirname(__FILE__) . '/display.html';
+ $template = dirname(__FILE__) . '/display.html';
return $this->display($template, ['name' => 'ThinkPHP']);
}
public function test()
@@ -71,7 +71,7 @@ class Foo extends Controller
['sex', 'in:0,1', '性别只能为为男或女'],
['age', 'between:1,80', '年龄只能在10-80之间'],
];
- return $this->validate($data, $validate);
+ return $this->validate($data, $validate);
}
}
diff --git a/tests/thinkphp/library/think/dbTest.php b/tests/thinkphp/library/think/dbTest.php
index f44b6b6c..4d3d16d5 100644
--- a/tests/thinkphp/library/think/dbTest.php
+++ b/tests/thinkphp/library/think/dbTest.php
@@ -16,7 +16,7 @@
namespace tests\thinkphp\library\think;
-use \think\Db;
+use think\Db;
class dbTest extends \PHPUnit_Framework_TestCase
{
@@ -349,5 +349,4 @@ EOF;
$this->assertNotEquals($cache, $updateCache);
}
-
}
diff --git a/tests/thinkphp/library/think/debugTest.php b/tests/thinkphp/library/think/debugTest.php
index 12ff815f..d6424a3d 100644
--- a/tests/thinkphp/library/think/debugTest.php
+++ b/tests/thinkphp/library/think/debugTest.php
@@ -1,179 +1,179 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Debug测试
- * @author 大漠
- */
-
-namespace tests\thinkphp\library\think;
-
-use think\Debug;
-
-class debugTest extends \PHPUnit_Framework_TestCase
-{
-
- /**
- *
- * @var Debug
- */
- protected $object;
-
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp()
- {
- $this->object = new Debug();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown()
- {}
-
- /**
- * @covers think\Debug::remark
- * @todo Implement testRemark().
- */
- public function testRemark()
- {
- $name = "testremarkkey";
- Debug::remark($name);
- }
-
- /**
- * @covers think\Debug::getRangeTime
- * @todo Implement testGetRangeTime().
- */
- public function testGetRangeTime()
- {
- $start = "testGetRangeTimeStart";
- $end = "testGetRangeTimeEnd";
- Debug::remark($start);
- usleep(20000);
- // \think\Debug::remark($end);
-
- $time = Debug::getRangeTime($start, $end);
- $this->assertLessThan(0.03, $time);
- //$this->assertEquals(0.03, ceil($time));
- }
-
- /**
- * @covers think\Debug::getUseTime
- * @todo Implement testGetUseTime().
- */
- public function testGetUseTime()
- {
- $time = Debug::getUseTime();
- $this->assertLessThan(20, $time);
- }
-
- /**
- * @covers think\Debug::getThroughputRate
- * @todo Implement testGetThroughputRate().
- */
- public function testGetThroughputRate()
- {
- usleep(100000);
- $throughputRate = Debug::getThroughputRate();
- $this->assertLessThan(10, $throughputRate);
- }
-
- /**
- * @covers think\Debug::getRangeMem
- * @todo Implement testGetRangeMem().
- */
- public function testGetRangeMem()
- {
- $start = "testGetRangeMemStart";
- $end = "testGetRangeMemEnd";
- Debug::remark($start);
- $str = "";
- for ($i = 0; $i < 10000; $i++) {
- $str .= "mem";
- }
-
- $rangeMem = Debug::getRangeMem($start, $end);
-
- $this->assertLessThan(33, explode(" ", $rangeMem)[0]);
- }
-
- /**
- * @covers think\Debug::getUseMem
- * @todo Implement testGetUseMem().
- */
- public function testGetUseMem()
- {
- $useMem = Debug::getUseMem();
-
- $this->assertLessThan(30, explode(" ", $useMem)[0]);
- }
-
- /**
- * @covers think\Debug::getMemPeak
- * @todo Implement testGetMemPeak().
- */
- public function testGetMemPeak()
- {
- $start = "testGetMemPeakStart";
- $end = "testGetMemPeakEnd";
- Debug::remark($start);
- $str = "";
- for ($i = 0; $i < 100000; $i++) {
- $str .= "mem";
- }
- $memPeak = Debug::getMemPeak($start, $end);
- $this->assertLessThan(500, explode(" ", $memPeak)[0]);
- }
-
- /**
- * @covers think\Debug::getFile
- * @todo Implement testGetFile().
- */
- public function testGetFile()
- {
- $count = Debug::getFile();
-
- $this->assertEquals(count(get_included_files()), $count);
-
- $info = Debug::getFile(true);
- $this->assertEquals(count(get_included_files()), count($info));
-
- $this->assertContains("KB", $info[0]);
- }
-
- /**
- * @covers think\Debug::dump
- * @todo Implement testDump().
- */
- public function testDump()
- {
- if (strstr(PHP_VERSION, 'hhvm')) {
- return ;
- }
-
- $var = [];
- $var["key"] = "val";
- $output = Debug::dump($var, false, $label = "label");
- $array = explode("array", json_encode($output));
- if (IS_WIN) {
- $this->assertEquals("(1) {\\n [\\\"key\\\"] => string(3) \\\"val\\\"\\n}\\n\\r\\n\"", end($array));
- } else if (strstr(PHP_OS, 'Darwin')) {
- $this->assertEquals("(1) {\\n [\\\"key\\\"] => string(3) \\\"val\\\"\\n}\\n\\n\"", end($array));
- } else {
- $this->assertEquals("(1) {\\n 'key' =>\\n string(3) \\\"val\\\"\\n}\\n\\n\"", end($array));
- }
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Debug测试
+ * @author 大漠
+ */
+
+namespace tests\thinkphp\library\think;
+
+use think\Debug;
+
+class debugTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ *
+ * @var Debug
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->object = new Debug();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {}
+
+ /**
+ * @covers think\Debug::remark
+ * @todo Implement testRemark().
+ */
+ public function testRemark()
+ {
+ $name = "testremarkkey";
+ Debug::remark($name);
+ }
+
+ /**
+ * @covers think\Debug::getRangeTime
+ * @todo Implement testGetRangeTime().
+ */
+ public function testGetRangeTime()
+ {
+ $start = "testGetRangeTimeStart";
+ $end = "testGetRangeTimeEnd";
+ Debug::remark($start);
+ usleep(20000);
+ // \think\Debug::remark($end);
+
+ $time = Debug::getRangeTime($start, $end);
+ $this->assertLessThan(0.03, $time);
+ //$this->assertEquals(0.03, ceil($time));
+ }
+
+ /**
+ * @covers think\Debug::getUseTime
+ * @todo Implement testGetUseTime().
+ */
+ public function testGetUseTime()
+ {
+ $time = Debug::getUseTime();
+ $this->assertLessThan(20, $time);
+ }
+
+ /**
+ * @covers think\Debug::getThroughputRate
+ * @todo Implement testGetThroughputRate().
+ */
+ public function testGetThroughputRate()
+ {
+ usleep(100000);
+ $throughputRate = Debug::getThroughputRate();
+ $this->assertLessThan(10, $throughputRate);
+ }
+
+ /**
+ * @covers think\Debug::getRangeMem
+ * @todo Implement testGetRangeMem().
+ */
+ public function testGetRangeMem()
+ {
+ $start = "testGetRangeMemStart";
+ $end = "testGetRangeMemEnd";
+ Debug::remark($start);
+ $str = "";
+ for ($i = 0; $i < 10000; $i++) {
+ $str .= "mem";
+ }
+
+ $rangeMem = Debug::getRangeMem($start, $end);
+
+ $this->assertLessThan(33, explode(" ", $rangeMem)[0]);
+ }
+
+ /**
+ * @covers think\Debug::getUseMem
+ * @todo Implement testGetUseMem().
+ */
+ public function testGetUseMem()
+ {
+ $useMem = Debug::getUseMem();
+
+ $this->assertLessThan(30, explode(" ", $useMem)[0]);
+ }
+
+ /**
+ * @covers think\Debug::getMemPeak
+ * @todo Implement testGetMemPeak().
+ */
+ public function testGetMemPeak()
+ {
+ $start = "testGetMemPeakStart";
+ $end = "testGetMemPeakEnd";
+ Debug::remark($start);
+ $str = "";
+ for ($i = 0; $i < 100000; $i++) {
+ $str .= "mem";
+ }
+ $memPeak = Debug::getMemPeak($start, $end);
+ $this->assertLessThan(500, explode(" ", $memPeak)[0]);
+ }
+
+ /**
+ * @covers think\Debug::getFile
+ * @todo Implement testGetFile().
+ */
+ public function testGetFile()
+ {
+ $count = Debug::getFile();
+
+ $this->assertEquals(count(get_included_files()), $count);
+
+ $info = Debug::getFile(true);
+ $this->assertEquals(count(get_included_files()), count($info));
+
+ $this->assertContains("KB", $info[0]);
+ }
+
+ /**
+ * @covers think\Debug::dump
+ * @todo Implement testDump().
+ */
+ public function testDump()
+ {
+ if (strstr(PHP_VERSION, 'hhvm')) {
+ return ;
+ }
+
+ $var = [];
+ $var["key"] = "val";
+ $output = Debug::dump($var, false, $label = "label");
+ $array = explode("array", json_encode($output));
+ if (IS_WIN) {
+ $this->assertEquals("(1) {\\n [\\\"key\\\"] => string(3) \\\"val\\\"\\n}\\n\\r\\n\"", end($array));
+ } elseif (strstr(PHP_OS, 'Darwin')) {
+ $this->assertEquals("(1) {\\n [\\\"key\\\"] => string(3) \\\"val\\\"\\n}\\n\\n\"", end($array));
+ } else {
+ $this->assertEquals("(1) {\\n 'key' =>\\n string(3) \\\"val\\\"\\n}\\n\\n\"", end($array));
+ }
+ }
+}
diff --git a/tests/thinkphp/library/think/lang/lang.php b/tests/thinkphp/library/think/lang/lang.php
index 044b171b..96880b15 100644
--- a/tests/thinkphp/library/think/lang/lang.php
+++ b/tests/thinkphp/library/think/lang/lang.php
@@ -1,4 +1,4 @@
'加载',
-];
\ No newline at end of file
+];
diff --git a/tests/thinkphp/library/think/log/driver/fileTest.php b/tests/thinkphp/library/think/log/driver/fileTest.php
index 3453c09b..3352e144 100644
--- a/tests/thinkphp/library/think/log/driver/fileTest.php
+++ b/tests/thinkphp/library/think/log/driver/fileTest.php
@@ -1,34 +1,34 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Test File Log
- */
-namespace tests\thinkphp\library\think\log\driver;
-
-use think\Log;
-
-class fileTest extends \PHPUnit_Framework_TestCase
-{
- protected function setUp()
- {
- Log::init(['type' => 'file']);
- }
-
- public function testRecord()
- {
- $record_msg = 'record';
- Log::record($record_msg, 'notice');
- $logs = Log::getLog();
-
- $this->assertNotFalse(array_search($record_msg, $logs['notice']));
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Test File Log
+ */
+namespace tests\thinkphp\library\think\log\driver;
+
+use think\Log;
+
+class fileTest extends \PHPUnit_Framework_TestCase
+{
+ protected function setUp()
+ {
+ Log::init(['type' => 'file']);
+ }
+
+ public function testRecord()
+ {
+ $record_msg = 'record';
+ Log::record($record_msg, 'notice');
+ $logs = Log::getLog();
+
+ $this->assertNotFalse(array_search($record_msg, $logs['notice']));
+ }
+}
diff --git a/tests/thinkphp/library/think/paginateTest.php b/tests/thinkphp/library/think/paginateTest.php
index 5bbcc961..8cd45507 100644
--- a/tests/thinkphp/library/think/paginateTest.php
+++ b/tests/thinkphp/library/think/paginateTest.php
@@ -11,7 +11,6 @@
namespace tests\thinkphp\library\think;
-
use think\paginator\driver\Bootstrap;
class paginateTest extends \PHPUnit_Framework_TestCase
@@ -38,7 +37,4 @@ class paginateTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($render, $p->render());
}
-
-
-
-}
\ No newline at end of file
+}
diff --git a/tests/thinkphp/library/think/responseTest.php b/tests/thinkphp/library/think/responseTest.php
index aa21a4b6..62d15747 100644
--- a/tests/thinkphp/library/think/responseTest.php
+++ b/tests/thinkphp/library/think/responseTest.php
@@ -1,95 +1,95 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Response测试
- * @author 大漠
- */
-
-namespace tests\thinkphp\library\think;
-
-use think\Config;
-use think\Request;
-use think\Response;
-
-class responseTest extends \PHPUnit_Framework_TestCase
-{
-
- /**
- *
- * @var \think\Response
- */
- protected $object;
-
- protected $default_return_type;
-
- protected $default_ajax_return;
-
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp()
- {
- // 1.
- // restore_error_handler();
- // Warning: Cannot modify header information - headers already sent by (output started at PHPUnit\Util\Printer.php:173)
- // more see in https://www.analysisandsolutions.com/blog/html/writing-phpunit-tests-for-wordpress-plugins-wp-redirect-and-continuing-after-php-errors.htm
-
- // 2.
- // the Symfony used the HeaderMock.php
-
- // 3.
- // not run the eclipse will held, and travis-ci.org Searching for coverage reports
- // **> Python coverage not found
- // **> No coverage report found.
- // add the
- // /**
- // * @runInSeparateProcess
- // */
- if (!$this->default_return_type) {
- $this->default_return_type = Config::get('default_return_type');
- }
- if (!$this->default_ajax_return) {
- $this->default_ajax_return = Config::get('default_ajax_return');
- }
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown()
- {
- Config::set('default_ajax_return', $this->default_ajax_return);
- Config::set('default_return_type', $this->default_return_type);
- }
-
- /**
- * @covers think\Response::send
- * @todo Implement testSend().
- */
- public function testSend()
- {
- $dataArr = [];
- $dataArr["key"] = "value";
-
- $response = Response::create($dataArr, 'json');
- $result = $response->getContent();
- $this->assertEquals('{"key":"value"}', $result);
- $request = Request::instance();
- $request->get(['callback' => 'callback']);
- $response = Response::create($dataArr, 'jsonp');
- $result = $response->getContent();
- $this->assertEquals('callback({"key":"value"});', $result);
- }
-
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Response测试
+ * @author 大漠
+ */
+
+namespace tests\thinkphp\library\think;
+
+use think\Config;
+use think\Request;
+use think\Response;
+
+class responseTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ *
+ * @var \think\Response
+ */
+ protected $object;
+
+ protected $default_return_type;
+
+ protected $default_ajax_return;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ // 1.
+ // restore_error_handler();
+ // Warning: Cannot modify header information - headers already sent by (output started at PHPUnit\Util\Printer.php:173)
+ // more see in https://www.analysisandsolutions.com/blog/html/writing-phpunit-tests-for-wordpress-plugins-wp-redirect-and-continuing-after-php-errors.htm
+
+ // 2.
+ // the Symfony used the HeaderMock.php
+
+ // 3.
+ // not run the eclipse will held, and travis-ci.org Searching for coverage reports
+ // **> Python coverage not found
+ // **> No coverage report found.
+ // add the
+ // /**
+ // * @runInSeparateProcess
+ // */
+ if (!$this->default_return_type) {
+ $this->default_return_type = Config::get('default_return_type');
+ }
+ if (!$this->default_ajax_return) {
+ $this->default_ajax_return = Config::get('default_ajax_return');
+ }
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ Config::set('default_ajax_return', $this->default_ajax_return);
+ Config::set('default_return_type', $this->default_return_type);
+ }
+
+ /**
+ * @covers think\Response::send
+ * @todo Implement testSend().
+ */
+ public function testSend()
+ {
+ $dataArr = [];
+ $dataArr["key"] = "value";
+
+ $response = Response::create($dataArr, 'json');
+ $result = $response->getContent();
+ $this->assertEquals('{"key":"value"}', $result);
+ $request = Request::instance();
+ $request->get(['callback' => 'callback']);
+ $response = Response::create($dataArr, 'jsonp');
+ $result = $response->getContent();
+ $this->assertEquals('callback({"key":"value"});', $result);
+ }
+
+}
diff --git a/tests/thinkphp/library/think/sessionTest.php b/tests/thinkphp/library/think/sessionTest.php
index ab3e64f4..5fd95f10 100644
--- a/tests/thinkphp/library/think/sessionTest.php
+++ b/tests/thinkphp/library/think/sessionTest.php
@@ -1,319 +1,319 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * Session测试
- * @author 大漠
- */
-
-namespace tests\thinkphp\library\think;
-
-use think\Session;
-
-class sessionTest extends \PHPUnit_Framework_TestCase
-{
-
- /**
- *
- * @var \think\Session
- */
- protected $object;
-
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- */
- protected function setUp()
- {
- // $this->object = new Session ();
- // register_shutdown_function ( function () {
- // } ); // 此功能无法取消,需要回调函数配合。
- set_exception_handler(function () {});
- set_error_handler(function () {});
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown()
- {
- register_shutdown_function('think\Error::appShutdown');
- set_error_handler('think\Error::appError');
- set_exception_handler('think\Error::appException');
- }
-
- /**
- * @covers think\Session::prefix
- *
- * @todo Implement testPrefix().
- */
- public function testPrefix()
- {
- Session::prefix(null);
- Session::prefix('think_');
-
- $this->assertEquals('think_', Session::prefix());
- }
-
- /**
- * @covers think\Session::init
- *
- * @todo Implement testInit().
- */
- public function testInit()
- {
- Session::prefix(null);
- $config = [
- // cookie 名称前缀
- 'prefix' => 'think_',
- // cookie 保存时间
- 'expire' => 60,
- // cookie 保存路径
- 'path' => '/path/to/test/session/',
- // cookie 有效域名
- 'domain' => '.thinkphp.cn',
- 'var_session_id' => 'sessionidtest',
- 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1',
- 'name' => 'session_name',
- 'use_trans_sid' => '1',
- 'use_cookies' => '1',
- 'cache_limiter' => '60',
- 'cache_expire' => '60',
- 'type' => '', // memcache
- 'namespace' => '\\think\\session\\driver\\', // ?
- 'auto_start' => '1',
- ];
-
- $_REQUEST[$config['var_session_id']] = $config['id'];
- Session::init($config);
-
- // 开始断言
- $this->assertEquals($config['prefix'], Session::prefix());
- $this->assertEquals($config['id'], $_REQUEST[$config['var_session_id']]);
- $this->assertEquals($config['name'], session_name());
-
- $this->assertEquals($config['path'], session_save_path());
- $this->assertEquals($config['use_cookies'], ini_get('session.use_cookies'));
- $this->assertEquals($config['domain'], ini_get('session.cookie_domain'));
- $this->assertEquals($config['expire'], ini_get('session.gc_maxlifetime'));
- $this->assertEquals($config['expire'], ini_get('session.cookie_lifetime'));
-
- $this->assertEquals($config['cache_limiter'], session_cache_limiter($config['cache_limiter']));
- $this->assertEquals($config['cache_expire'], session_cache_expire($config['cache_expire']));
-
- // 检测分支
- $_REQUEST[$config['var_session_id']] = null;
- session_write_close();
- session_destroy();
-
- Session::init($config);
-
- // 测试auto_start
- // PHP_SESSION_DISABLED
- // PHP_SESSION_NONE
- // PHP_SESSION_ACTIVE
- // session_status()
- if (strstr(PHP_VERSION, 'hhvm')) {
- $this->assertEquals('', ini_get('session.auto_start'));
- } else {
- $this->assertEquals(0, ini_get('session.auto_start'));
- }
-
- $this->assertEquals($config['use_trans_sid'], ini_get('session.use_trans_sid'));
-
- Session::init($config);
- $this->assertEquals($config['id'], session_id());
- }
-
- /**
- * 单独重现异常
- * @expectedException \think\Exception
- */
- public function testException()
- {
- $config = [
- // cookie 名称前缀
- 'prefix' => 'think_',
- // cookie 保存时间
- 'expire' => 0,
- // cookie 保存路径
- 'path' => '/path/to/test/session/',
- // cookie 有效域名
- 'domain' => '.thinkphp.cn',
- 'var_session_id' => 'sessionidtest',
- 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1',
- 'name' => 'session_name',
- 'use_trans_sid' => '1',
- 'use_cookies' => '1',
- 'cache_limiter' => '60',
- 'cache_expire' => '60',
- 'type' => '\\think\\session\\driver\\Memcache', //
- 'auto_start' => '1',
- ];
-
- // 测试session驱动是否存在
- // @expectedException 异常类名
- $this->setExpectedException('\think\exception\ClassNotFoundException', 'error session handler');
-
- Session::init($config);
- }
-
- /**
- * @covers think\Session::set
- *
- * @todo Implement testSet().
- */
- public function testSet()
- {
- Session::prefix(null);
- Session::set('sessionname', 'sessionvalue');
- $this->assertEquals('sessionvalue', $_SESSION['sessionname']);
-
- Session::set('sessionnamearr.subname', 'sessionvalue');
- $this->assertEquals('sessionvalue', $_SESSION['sessionnamearr']['subname']);
-
- Session::set('sessionnameper', 'sessionvalue', 'think_');
- $this->assertEquals('sessionvalue', $_SESSION['think_']['sessionnameper']);
-
- Session::set('sessionnamearrper.subname', 'sessionvalue', 'think_');
- $this->assertEquals('sessionvalue', $_SESSION['think_']['sessionnamearrper']['subname']);
- }
-
- /**
- * @covers think\Session::get
- *
- * @todo Implement testGet().
- */
- public function testGet()
- {
- Session::prefix(null);
-
- Session::set('sessionnameget', 'sessionvalue');
- $this->assertEquals(Session::get('sessionnameget'), $_SESSION['sessionnameget']);
-
- Session::set('sessionnamegetarr.subname', 'sessionvalue');
- $this->assertEquals(Session::get('sessionnamegetarr.subname'), $_SESSION['sessionnamegetarr']['subname']);
-
- Session::set('sessionnamegetarrperall', 'sessionvalue', 'think_');
- $this->assertEquals(Session::get('', 'think_')['sessionnamegetarrperall'], $_SESSION['think_']['sessionnamegetarrperall']);
-
- Session::set('sessionnamegetper', 'sessionvalue', 'think_');
- $this->assertEquals(Session::get('sessionnamegetper', 'think_'), $_SESSION['think_']['sessionnamegetper']);
-
- Session::set('sessionnamegetarrper.subname', 'sessionvalue', 'think_');
- $this->assertEquals(Session::get('sessionnamegetarrper.subname', 'think_'), $_SESSION['think_']['sessionnamegetarrper']['subname']);
- }
-
- public function testPull()
- {
- Session::prefix(null);
- Session::set('sessionnamedel', 'sessionvalue');
- $this->assertEquals('sessionvalue', Session::pull('sessionnameget'));
- $this->assertNull(Session::get('sessionnameget'));
- }
-
- /**
- * @covers think\Session::delete
- *
- * @todo Implement testDelete().
- */
- public function testDelete()
- {
- Session::prefix(null);
- Session::set('sessionnamedel', 'sessionvalue');
- Session::delete('sessionnamedel');
- $this->assertEmpty($_SESSION['sessionnamedel']);
-
- Session::set('sessionnamedelarr.subname', 'sessionvalue');
- Session::delete('sessionnamedelarr.subname');
- $this->assertEmpty($_SESSION['sessionnamedelarr']['subname']);
-
- Session::set('sessionnamedelper', 'sessionvalue', 'think_');
- Session::delete('sessionnamedelper', 'think_');
- $this->assertEmpty($_SESSION['think_']['sessionnamedelper']);
-
- Session::set('sessionnamedelperarr.subname', 'sessionvalue', 'think_');
- Session::delete('sessionnamedelperarr.subname', 'think_');
- $this->assertEmpty($_SESSION['think_']['sessionnamedelperarr']['subname']);
- }
-
- /**
- * @covers think\Session::clear
- *
- * @todo Implement testClear().
- */
- public function testClear()
- {
- Session::prefix(null);
-
- Session::set('sessionnameclsper', 'sessionvalue1', 'think_');
- Session::clear('think_');
- $this->assertNull($_SESSION['think_']);
-
- Session::set('sessionnameclsper', 'sessionvalue1', 'think_');
- Session::clear();
- $this->assertEmpty($_SESSION);
- }
-
- /**
- * @covers think\Session::has
- *
- * @todo Implement testHas().
- */
- public function testHas()
- {
- Session::prefix(null);
- Session::set('sessionnamehas', 'sessionvalue');
- $this->assertTrue(Session::has('sessionnamehas'));
-
- Session::set('sessionnamehasarr.subname', 'sessionvalue');
- $this->assertTrue(Session::has('sessionnamehasarr.subname'));
-
- Session::set('sessionnamehasper', 'sessionvalue', 'think_');
- $this->assertTrue(Session::has('sessionnamehasper', 'think_'));
-
- Session::set('sessionnamehasarrper.subname', 'sessionvalue', 'think_');
- $this->assertTrue(Session::has('sessionnamehasarrper.subname', 'think_'));
- }
-
- /**
- * @covers think\Session::pause
- *
- * @todo Implement testPause().
- */
- public function testPause()
- {
- Session::pause();
- }
-
- /**
- * @covers think\Session::start
- *
- * @todo Implement testStart().
- */
- public function testStart()
- {
- Session::start();
- }
-
- /**
- * @covers think\Session::destroy
- *
- * @todo Implement testDestroy().
- */
- public function testDestroy()
- {
- Session::set('sessionnamedestroy', 'sessionvalue');
- Session::destroy();
- $this->assertEmpty($_SESSION['sessionnamedestroy']);
- }
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * Session测试
+ * @author 大漠
+ */
+
+namespace tests\thinkphp\library\think;
+
+use think\Session;
+
+class sessionTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ *
+ * @var \think\Session
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ // $this->object = new Session ();
+ // register_shutdown_function ( function () {
+ // } ); // 此功能无法取消,需要回调函数配合。
+ set_exception_handler(function () {});
+ set_error_handler(function () {});
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ register_shutdown_function('think\Error::appShutdown');
+ set_error_handler('think\Error::appError');
+ set_exception_handler('think\Error::appException');
+ }
+
+ /**
+ * @covers think\Session::prefix
+ *
+ * @todo Implement testPrefix().
+ */
+ public function testPrefix()
+ {
+ Session::prefix(null);
+ Session::prefix('think_');
+
+ $this->assertEquals('think_', Session::prefix());
+ }
+
+ /**
+ * @covers think\Session::init
+ *
+ * @todo Implement testInit().
+ */
+ public function testInit()
+ {
+ Session::prefix(null);
+ $config = [
+ // cookie 名称前缀
+ 'prefix' => 'think_',
+ // cookie 保存时间
+ 'expire' => 60,
+ // cookie 保存路径
+ 'path' => '/path/to/test/session/',
+ // cookie 有效域名
+ 'domain' => '.thinkphp.cn',
+ 'var_session_id' => 'sessionidtest',
+ 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1',
+ 'name' => 'session_name',
+ 'use_trans_sid' => '1',
+ 'use_cookies' => '1',
+ 'cache_limiter' => '60',
+ 'cache_expire' => '60',
+ 'type' => '', // memcache
+ 'namespace' => '\\think\\session\\driver\\', // ?
+ 'auto_start' => '1',
+ ];
+
+ $_REQUEST[$config['var_session_id']] = $config['id'];
+ Session::init($config);
+
+ // 开始断言
+ $this->assertEquals($config['prefix'], Session::prefix());
+ $this->assertEquals($config['id'], $_REQUEST[$config['var_session_id']]);
+ $this->assertEquals($config['name'], session_name());
+
+ $this->assertEquals($config['path'], session_save_path());
+ $this->assertEquals($config['use_cookies'], ini_get('session.use_cookies'));
+ $this->assertEquals($config['domain'], ini_get('session.cookie_domain'));
+ $this->assertEquals($config['expire'], ini_get('session.gc_maxlifetime'));
+ $this->assertEquals($config['expire'], ini_get('session.cookie_lifetime'));
+
+ $this->assertEquals($config['cache_limiter'], session_cache_limiter($config['cache_limiter']));
+ $this->assertEquals($config['cache_expire'], session_cache_expire($config['cache_expire']));
+
+ // 检测分支
+ $_REQUEST[$config['var_session_id']] = null;
+ session_write_close();
+ session_destroy();
+
+ Session::init($config);
+
+ // 测试auto_start
+ // PHP_SESSION_DISABLED
+ // PHP_SESSION_NONE
+ // PHP_SESSION_ACTIVE
+ // session_status()
+ if (strstr(PHP_VERSION, 'hhvm')) {
+ $this->assertEquals('', ini_get('session.auto_start'));
+ } else {
+ $this->assertEquals(0, ini_get('session.auto_start'));
+ }
+
+ $this->assertEquals($config['use_trans_sid'], ini_get('session.use_trans_sid'));
+
+ Session::init($config);
+ $this->assertEquals($config['id'], session_id());
+ }
+
+ /**
+ * 单独重现异常
+ * @expectedException \think\Exception
+ */
+ public function testException()
+ {
+ $config = [
+ // cookie 名称前缀
+ 'prefix' => 'think_',
+ // cookie 保存时间
+ 'expire' => 0,
+ // cookie 保存路径
+ 'path' => '/path/to/test/session/',
+ // cookie 有效域名
+ 'domain' => '.thinkphp.cn',
+ 'var_session_id' => 'sessionidtest',
+ 'id' => 'sess_8fhgkjuakhatbeg2fa14lo84q1',
+ 'name' => 'session_name',
+ 'use_trans_sid' => '1',
+ 'use_cookies' => '1',
+ 'cache_limiter' => '60',
+ 'cache_expire' => '60',
+ 'type' => '\\think\\session\\driver\\Memcache', //
+ 'auto_start' => '1',
+ ];
+
+ // 测试session驱动是否存在
+ // @expectedException 异常类名
+ $this->setExpectedException('\think\exception\ClassNotFoundException', 'error session handler');
+
+ Session::init($config);
+ }
+
+ /**
+ * @covers think\Session::set
+ *
+ * @todo Implement testSet().
+ */
+ public function testSet()
+ {
+ Session::prefix(null);
+ Session::set('sessionname', 'sessionvalue');
+ $this->assertEquals('sessionvalue', $_SESSION['sessionname']);
+
+ Session::set('sessionnamearr.subname', 'sessionvalue');
+ $this->assertEquals('sessionvalue', $_SESSION['sessionnamearr']['subname']);
+
+ Session::set('sessionnameper', 'sessionvalue', 'think_');
+ $this->assertEquals('sessionvalue', $_SESSION['think_']['sessionnameper']);
+
+ Session::set('sessionnamearrper.subname', 'sessionvalue', 'think_');
+ $this->assertEquals('sessionvalue', $_SESSION['think_']['sessionnamearrper']['subname']);
+ }
+
+ /**
+ * @covers think\Session::get
+ *
+ * @todo Implement testGet().
+ */
+ public function testGet()
+ {
+ Session::prefix(null);
+
+ Session::set('sessionnameget', 'sessionvalue');
+ $this->assertEquals(Session::get('sessionnameget'), $_SESSION['sessionnameget']);
+
+ Session::set('sessionnamegetarr.subname', 'sessionvalue');
+ $this->assertEquals(Session::get('sessionnamegetarr.subname'), $_SESSION['sessionnamegetarr']['subname']);
+
+ Session::set('sessionnamegetarrperall', 'sessionvalue', 'think_');
+ $this->assertEquals(Session::get('', 'think_')['sessionnamegetarrperall'], $_SESSION['think_']['sessionnamegetarrperall']);
+
+ Session::set('sessionnamegetper', 'sessionvalue', 'think_');
+ $this->assertEquals(Session::get('sessionnamegetper', 'think_'), $_SESSION['think_']['sessionnamegetper']);
+
+ Session::set('sessionnamegetarrper.subname', 'sessionvalue', 'think_');
+ $this->assertEquals(Session::get('sessionnamegetarrper.subname', 'think_'), $_SESSION['think_']['sessionnamegetarrper']['subname']);
+ }
+
+ public function testPull()
+ {
+ Session::prefix(null);
+ Session::set('sessionnamedel', 'sessionvalue');
+ $this->assertEquals('sessionvalue', Session::pull('sessionnameget'));
+ $this->assertNull(Session::get('sessionnameget'));
+ }
+
+ /**
+ * @covers think\Session::delete
+ *
+ * @todo Implement testDelete().
+ */
+ public function testDelete()
+ {
+ Session::prefix(null);
+ Session::set('sessionnamedel', 'sessionvalue');
+ Session::delete('sessionnamedel');
+ $this->assertEmpty($_SESSION['sessionnamedel']);
+
+ Session::set('sessionnamedelarr.subname', 'sessionvalue');
+ Session::delete('sessionnamedelarr.subname');
+ $this->assertEmpty($_SESSION['sessionnamedelarr']['subname']);
+
+ Session::set('sessionnamedelper', 'sessionvalue', 'think_');
+ Session::delete('sessionnamedelper', 'think_');
+ $this->assertEmpty($_SESSION['think_']['sessionnamedelper']);
+
+ Session::set('sessionnamedelperarr.subname', 'sessionvalue', 'think_');
+ Session::delete('sessionnamedelperarr.subname', 'think_');
+ $this->assertEmpty($_SESSION['think_']['sessionnamedelperarr']['subname']);
+ }
+
+ /**
+ * @covers think\Session::clear
+ *
+ * @todo Implement testClear().
+ */
+ public function testClear()
+ {
+ Session::prefix(null);
+
+ Session::set('sessionnameclsper', 'sessionvalue1', 'think_');
+ Session::clear('think_');
+ $this->assertNull($_SESSION['think_']);
+
+ Session::set('sessionnameclsper', 'sessionvalue1', 'think_');
+ Session::clear();
+ $this->assertEmpty($_SESSION);
+ }
+
+ /**
+ * @covers think\Session::has
+ *
+ * @todo Implement testHas().
+ */
+ public function testHas()
+ {
+ Session::prefix(null);
+ Session::set('sessionnamehas', 'sessionvalue');
+ $this->assertTrue(Session::has('sessionnamehas'));
+
+ Session::set('sessionnamehasarr.subname', 'sessionvalue');
+ $this->assertTrue(Session::has('sessionnamehasarr.subname'));
+
+ Session::set('sessionnamehasper', 'sessionvalue', 'think_');
+ $this->assertTrue(Session::has('sessionnamehasper', 'think_'));
+
+ Session::set('sessionnamehasarrper.subname', 'sessionvalue', 'think_');
+ $this->assertTrue(Session::has('sessionnamehasarrper.subname', 'think_'));
+ }
+
+ /**
+ * @covers think\Session::pause
+ *
+ * @todo Implement testPause().
+ */
+ public function testPause()
+ {
+ Session::pause();
+ }
+
+ /**
+ * @covers think\Session::start
+ *
+ * @todo Implement testStart().
+ */
+ public function testStart()
+ {
+ Session::start();
+ }
+
+ /**
+ * @covers think\Session::destroy
+ *
+ * @todo Implement testDestroy().
+ */
+ public function testDestroy()
+ {
+ Session::set('sessionnamedestroy', 'sessionvalue');
+ Session::destroy();
+ $this->assertEmpty($_SESSION['sessionnamedestroy']);
+ }
+}
diff --git a/tests/thinkphp/library/think/template/taglib/cxTest.php b/tests/thinkphp/library/think/template/taglib/cxTest.php
index a77824b6..c1c67413 100644
--- a/tests/thinkphp/library/think/template/taglib/cxTest.php
+++ b/tests/thinkphp/library/think/template/taglib/cxTest.php
@@ -19,7 +19,7 @@ namespace tests\thinkphp\library\think\tempplate\taglib;
use think\Template;
use think\template\taglib\Cx;
-class templateTest extends \PHPUnit_Framework_TestCase
+class cxTest extends \PHPUnit_Framework_TestCase
{
public function testPhp()
{
diff --git a/tests/thinkphp/library/think/viewTest.php b/tests/thinkphp/library/think/viewTest.php
index 56804798..5bb7de16 100644
--- a/tests/thinkphp/library/think/viewTest.php
+++ b/tests/thinkphp/library/think/viewTest.php
@@ -1,76 +1,76 @@
-
-// +----------------------------------------------------------------------
-
-/**
- * view测试
- * @author mahuan
- */
-
-namespace tests\thinkphp\library\think;
-
-class viewTest extends \PHPUnit_Framework_TestCase
-{
-
- /**
- * 句柄测试
- * @return mixed
- * @access public
- */
- public function testGetInstance()
- {
- \think\Cookie::get('a');
- $view_instance = \think\View::instance();
- $this->assertInstanceOf('\think\view', $view_instance, 'instance方法返回错误');
- }
-
- /**
- * 测试变量赋值
- * @return mixed
- * @access public
- */
- public function testAssign()
- {
- $view_instance = \think\View::instance();
- $view_instance->key = 'value';
- $this->assertTrue(isset($view_instance->key));
- $this->assertEquals('value', $view_instance->key);
- $data = $view_instance->assign(array('key' => 'value'));
- $data = $view_instance->assign('key2', 'value2');
- //测试私有属性
- $expect_data = array('key' => 'value', 'key2' => 'value2');
- $this->assertAttributeEquals($expect_data, 'data', $view_instance);
- }
-
- /**
- * 测试引擎设置
- * @return mixed
- * @access public
- */
- public function testEngine()
- {
- $view_instance = \think\View::instance();
- $data = $view_instance->engine('php');
- $data = $view_instance->engine(['type' => 'php', 'view_path' => '', 'view_suffix' => '.php', 'view_depr' => DS]);
- $php_engine = new \think\view\driver\Php(['view_path' => '', 'view_suffix' => '.php', 'view_depr' => DS]);
- $this->assertAttributeEquals($php_engine, 'engine', $view_instance);
- //测试模板引擎驱动
- $data = $view_instance->engine(['type' => 'think', 'view_path' => '', 'view_suffix' => '.html', 'view_depr' => DS]);
- $think_engine = new \think\view\driver\Think(['view_path' => '', 'view_suffix' => '.html', 'view_depr' => DS]);
- $this->assertAttributeEquals($think_engine, 'engine', $view_instance);
- }
-
- public function testReplace()
- {
- $view_instance = \think\View::instance();
- $view_instance->replace('string', 'replace')->display('string');
- }
-
-}
+
+// +----------------------------------------------------------------------
+
+/**
+ * view测试
+ * @author mahuan
+ */
+
+namespace tests\thinkphp\library\think;
+
+class viewTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * 句柄测试
+ * @return mixed
+ * @access public
+ */
+ public function testGetInstance()
+ {
+ \think\Cookie::get('a');
+ $view_instance = \think\View::instance();
+ $this->assertInstanceOf('\think\view', $view_instance, 'instance方法返回错误');
+ }
+
+ /**
+ * 测试变量赋值
+ * @return mixed
+ * @access public
+ */
+ public function testAssign()
+ {
+ $view_instance = \think\View::instance();
+ $view_instance->key = 'value';
+ $this->assertTrue(isset($view_instance->key));
+ $this->assertEquals('value', $view_instance->key);
+ $data = $view_instance->assign(array('key' => 'value'));
+ $data = $view_instance->assign('key2', 'value2');
+ //测试私有属性
+ $expect_data = array('key' => 'value', 'key2' => 'value2');
+ $this->assertAttributeEquals($expect_data, 'data', $view_instance);
+ }
+
+ /**
+ * 测试引擎设置
+ * @return mixed
+ * @access public
+ */
+ public function testEngine()
+ {
+ $view_instance = \think\View::instance();
+ $data = $view_instance->engine('php');
+ $data = $view_instance->engine(['type' => 'php', 'view_path' => '', 'view_suffix' => '.php', 'view_depr' => DS]);
+ $php_engine = new \think\view\driver\Php(['view_path' => '', 'view_suffix' => '.php', 'view_depr' => DS]);
+ $this->assertAttributeEquals($php_engine, 'engine', $view_instance);
+ //测试模板引擎驱动
+ $data = $view_instance->engine(['type' => 'think', 'view_path' => '', 'view_suffix' => '.html', 'view_depr' => DS]);
+ $think_engine = new \think\view\driver\Think(['view_path' => '', 'view_suffix' => '.html', 'view_depr' => DS]);
+ $this->assertAttributeEquals($think_engine, 'engine', $view_instance);
+ }
+
+ public function testReplace()
+ {
+ $view_instance = \think\View::instance();
+ $view_instance->replace('string', 'replace')->display('string');
+ }
+
+}