From fc15d2281153312d9c7d025143c7ba87b121083f Mon Sep 17 00:00:00 2001 From: 7IN0SAN9 Date: Fri, 18 Dec 2015 01:41:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B5=8B=E8=AF=95=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=20mock.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/app.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/think/app.php b/library/think/app.php index c5803d10..6e8e5b8c 100644 --- a/library/think/app.php +++ b/library/think/app.php @@ -113,7 +113,11 @@ class App // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); // 返回数据 - Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); + if (defined('IN_UNIT_TEST')) { + return $data; + } else { + Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); + } } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); @@ -124,7 +128,11 @@ class App $method = new \ReflectionMethod($instance, '_empty'); $data = $method->invokeArgs($instance, [$action, '']); // 返回数据 - Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); + if (defined('IN_UNIT_TEST')) { + return $data; + } else { + 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); }