diff --git a/library/think/App.php b/library/think/App.php index ea01abaa..6f88a9ab 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -212,11 +212,11 @@ class App // 获取控制器名 $controllerName = strip_tags($result[1] ?: Config::get('default_controller')); - define('CONTROLLER_NAME', Config::get('url_controller_convert') ? strtolower($controllerName) : $controllerName); + defined('CONTROLLER_NAME') or define('CONTROLLER_NAME', Config::get('url_controller_convert') ? strtolower($controllerName) : $controllerName); // 获取操作名 $actionName = strip_tags($result[2] ?: Config::get('default_action')); - define('ACTION_NAME', Config::get('url_action_convert') ? strtolower($actionName) : $actionName); + defined('ACTION_NAME') or define('ACTION_NAME', Config::get('url_action_convert') ? strtolower($actionName) : $actionName); // 执行操作 if (!preg_match('/^[A-Za-z](\/|\.|\w)*$/', CONTROLLER_NAME)) { diff --git a/tests/thinkphp/library/think/appTest.php b/tests/thinkphp/library/think/appTest.php index 490832a8..a38e9d04 100644 --- a/tests/thinkphp/library/think/appTest.php +++ b/tests/thinkphp/library/think/appTest.php @@ -16,12 +16,82 @@ namespace tests\thinkphp\library\think; +use ReflectionClass; +use think\App; +use think\Config; + +function func_trim($value) +{ + return trim($value); +} + +function func_strpos($haystack, $needle) +{ + return strpos($haystack, $needle); +} + +class AppInvokeMethodTestClass +{ + public static function staticRun($string) + { + return $string; + } + + public function run($string) + { + return $string; + } +} + class appTest extends \PHPUnit_Framework_TestCase { public function testRun() { - //\think\App::run(); - //$this->expectOutputString('
欢迎使用 ThinkPHP5!
欢迎使用 ThinkPHP5!