From 380ae2802174eb5025cf386186b1ab160216fcdd Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 16 Mar 2016 12:40:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=A8=A1=E6=9D=BF=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Build.php | 8 ++++---- library/think/View.php | 2 +- .../library/think/view/default/index/template.html | 14 ++++++++++++++ tests/thinkphp/library/think/viewTest.php | 8 +++++--- 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 tests/thinkphp/library/think/view/default/index/template.html diff --git a/library/think/Build.php b/library/think/Build.php index 86dd6887..5b7306cf 100644 --- a/library/think/Build.php +++ b/library/think/Build.php @@ -101,13 +101,13 @@ class Build $namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path; $class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : ''); switch ($path) { - case CONTROLLER_LAYER: // 控制器 + case CONTROLLER_LAYER: // 控制器 $content = "config['view_suffix']; + return realpath($path) . DS . $template . $this->config['view_suffix']; } /** diff --git a/tests/thinkphp/library/think/view/default/index/template.html b/tests/thinkphp/library/think/view/default/index/template.html new file mode 100644 index 00000000..5f4548be --- /dev/null +++ b/tests/thinkphp/library/think/view/default/index/template.html @@ -0,0 +1,14 @@ + + + + + + + + + Document + + + + + diff --git a/tests/thinkphp/library/think/viewTest.php b/tests/thinkphp/library/think/viewTest.php index 590b258b..b4b41d59 100644 --- a/tests/thinkphp/library/think/viewTest.php +++ b/tests/thinkphp/library/think/viewTest.php @@ -121,12 +121,14 @@ class viewTest extends \PHPUnit_Framework_TestCase public function testParseTemplate() { $view_instance = \think\View::instance(); - $method = new \ReflectionMethod('\think\View', 'ParseTemplate'); + $view_instance->theme(true); + $view_instance->config(['view_path' => __DIR__ . DS]); + $method = new \ReflectionMethod('\think\View', 'ParseTemplate'); $method->setAccessible(true); if (defined('CONTROLLER_NAME')) { - $expect_data = 'view_path' . 'theme_name' . DS . CONTROLLER_NAME . DS . 'template_name.html'; + $expect_data = __DIR__ . DS . 'default' . DS . CONTROLLER_NAME . DS . 'template.html'; } else { - $expect_data = 'view_path' . 'theme_name' . DS . 'template_name.html'; + $expect_data = __DIR__ . DS . 'default' . DS . 'template.html'; } $this->assertEquals($expect_data, $method->invoke($view_instance, 'template_name')); }