From f8eb8952e2118fc1838a3283ead098d855b9a0ba Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 18 Apr 2016 15:41:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/viewTest.php | 52 +---------------------- 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/tests/thinkphp/library/think/viewTest.php b/tests/thinkphp/library/think/viewTest.php index 4c956566..4dce2213 100644 --- a/tests/thinkphp/library/think/viewTest.php +++ b/tests/thinkphp/library/think/viewTest.php @@ -77,60 +77,12 @@ class viewTest extends \PHPUnit_Framework_TestCase { $view_instance = \think\View::instance(); $data = $view_instance->engine('php'); - $this->assertAttributeEquals('php', 'engine', $view_instance); + $php_engine = new \think\view\driver\Php(['view_path' => 'view_path']); + $this->assertAttributeEquals($php_engine, 'engine', $view_instance); //测试模板引擎驱动 $data = $view_instance->engine('think'); $think_engine = new \think\view\driver\Think(['view_path' => 'view_path']); $this->assertAttributeEquals($think_engine, 'engine', $view_instance); } - /** - * 测试引擎设置 - * @return mixed - * @access public - */ - public function testTheme() - { - $view_instance = \think\View::instance(); - $data = $view_instance->theme(true); - //反射类取出私有属性的值 - $reflection = new \ReflectionClass('\think\View'); - $property = $reflection->getProperty('config'); - $property->setAccessible(true); - $config_value = $property->getValue($view_instance); - - $this->assertTrue($config_value['theme_on']); - - //关闭主题测试 - $data = $view_instance->theme(false); - $config_value = $property->getValue($view_instance); - $this->assertFalse($config_value['theme_on']); - - //指定主题测试 - $data = $view_instance->theme('theme_name'); - $config_value = $property->getValue($view_instance); - $this->assertTrue($config_value['theme_on']); - $this->assertAttributeEquals('theme_name', 'theme', $view_instance); - } - - /** - * 测试引擎设置 - * @return mixed - * @access public - */ - public function testParseTemplate() - { - $view_instance = \think\View::instance(); - $view_instance->theme('theme'); - $view_instance->config(['view_path' => __DIR__ . DS . 'view' . DS]); - $method = new \ReflectionMethod('\think\View', 'ParseTemplate'); - $method->setAccessible(true); - if (defined('CONTROLLER_NAME')) { - $expect_data = __DIR__ . DS . 'view' . DS . 'theme' . DS . CONTROLLER_NAME . DS . 'template.html'; - } else { - $expect_data = __DIR__ . DS . 'view' . DS . 'theme' . DS . 'template.html'; - } - $this->assertEquals($expect_data, $method->invoke($view_instance, 'template')); - } - }