diff --git a/library/think/app.php b/library/think/app.php index de6519f3..039e6a04 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -110,12 +110,10 @@ class App } // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); - // 返回数据 - if (IN_UNIT_TEST) { - return $data; - } else { - Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); - } + // 单元测试模式下返回数据 + if (IN_UNIT_TEST) { return $data; } + // 输出数据 + Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); @@ -127,12 +125,10 @@ class App $data = $method->invokeArgs($instance, [$action, '']); // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); - // 返回数据 - if (IN_UNIT_TEST) { - return $data; - } else { - Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); - } + // 单元测试模式下返回数据 + if (IN_UNIT_TEST) { return $data; } + // 输出数据 + Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); } else { throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002); }