mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
修正测试文件
This commit is contained in:
@@ -169,7 +169,7 @@ EOF;
|
|||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
{\$name.a.b|default='test'}
|
{\$name.a.b|default='test'}
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
<?php echo (isset(\$name['a']['b']) && (\$name['a']['b'] !== '')?\$name['a']['b']:'test'); ?>
|
<?php echo (isset(\$name['a']['b']) && (\$name['a']['b'] !== '')?\$name['a']['b']:'test'); ?>
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ EOF;
|
|||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
{\$create_time|date="y-m-d",###}
|
{\$create_time|date="y-m-d",###}
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
<?php echo date("y-m-d",\$create_time); ?>
|
<?php echo date("y-m-d",\$create_time); ?>
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ EOF;
|
|||||||
{\$name}
|
{\$name}
|
||||||
{\$name|trim|substr=0,3}
|
{\$name|trim|substr=0,3}
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
<?php echo \$name; ?>
|
<?php echo \$name; ?>
|
||||||
<?php echo substr(trim(\$name),0,3); ?>
|
<?php echo substr(trim(\$name),0,3); ?>
|
||||||
EOF;
|
EOF;
|
||||||
@@ -209,7 +209,7 @@ EOF;
|
|||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
<#\$info.a??'test'#>
|
<#\$info.a??'test'#>
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
<?php echo (is_array(\$info)?\$info['a']:\$info->a) ? (is_array(\$info)?\$info['a']:\$info->a) : 'test'; ?>
|
<?php echo (is_array(\$info)?\$info['a']:\$info->a) ? (is_array(\$info)?\$info['a']:\$info->a) : 'test'; ?>
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ EOF;
|
|||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
<#\$info.a==\$info.b?='test'#>
|
<#\$info.a==\$info.b?='test'#>
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
<?php if((is_array(\$info)?\$info['a']:\$info->a)==(is_array(\$info)?\$info['b']:\$info->b)) echo 'test'; ?>
|
<?php if((is_array(\$info)?\$info['a']:\$info->a)==(is_array(\$info)?\$info['b']:\$info->b)) echo 'test'; ?>
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
@@ -229,15 +229,15 @@ EOF;
|
|||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
<#\$info.a|default='test'?'yes':'no'#>
|
<#\$info.a|default='test'?'yes':'no'#>
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
<?php echo ((is_array(\$info)?\$info['a']:\$info->a) !== ''?(is_array(\$info)?\$info['a']:\$info->a):'test')?'yes':'no'; ?>
|
<?php echo ((is_array(\$info)?\$info['a']:\$info->a) !== ''?(is_array(\$info)?\$info['a']:\$info->a):'test')?'yes':'no'; ?>
|
||||||
EOF;
|
EOF;
|
||||||
$template->parse($content);
|
$template->parse($content);
|
||||||
$this->assertEquals($data, $content);
|
$this->assertEquals($data, $content);
|
||||||
|
|
||||||
$template2 = new Template();
|
$template2 = new Template();
|
||||||
$template2->tpl_var_identify = 'obj';
|
$template2->tpl_var_identify = 'obj';
|
||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
{\$info2.b|trim?'yes':'no'}
|
{\$info2.b|trim?'yes':'no'}
|
||||||
EOF;
|
EOF;
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
@@ -249,10 +249,10 @@ EOF;
|
|||||||
|
|
||||||
public function testTag()
|
public function testTag()
|
||||||
{
|
{
|
||||||
$config['tpl_path'] = dirname(__FILE__) . '/';
|
$config['view_path'] = dirname(__FILE__) . '/';
|
||||||
$config['tpl_suffix'] = '.html';
|
$config['view_suffix'] = '.html';
|
||||||
$template = new Template($config);
|
$template = new Template($config);
|
||||||
$files = ['extend' => 'extend', 'include' => 'include'];
|
$files = ['extend' => 'extend', 'include' => 'include'];
|
||||||
$template->assign('files', $files);
|
$template->assign('files', $files);
|
||||||
|
|
||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
@@ -291,13 +291,13 @@ EOF;
|
|||||||
public function testThinkVar()
|
public function testThinkVar()
|
||||||
{
|
{
|
||||||
$config['tpl_begin'] = '{';
|
$config['tpl_begin'] = '{';
|
||||||
$config['tpl_end'] = '}';
|
$config['tpl_end'] = '}';
|
||||||
$template = new Template($config);
|
$template = new Template($config);
|
||||||
|
|
||||||
$_SERVER['SERVER_NAME'] = 'server_name';
|
$_SERVER['SERVER_NAME'] = 'server_name';
|
||||||
$_GET['action'] = 'action';
|
$_GET['action'] = 'action';
|
||||||
$_POST['action'] = 'action';
|
$_POST['action'] = 'action';
|
||||||
$_COOKIE['name'] = 'name';
|
$_COOKIE['name'] = 'name';
|
||||||
\think\Session::set('action', ['name' => 'name']);
|
\think\Session::set('action', ['name' => 'name']);
|
||||||
define('SITE_NAME', 'site_name');
|
define('SITE_NAME', 'site_name');
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ EOF;
|
|||||||
$template->assign('name', 'name');
|
$template->assign('name', 'name');
|
||||||
$config = [
|
$config = [
|
||||||
'strip_space' => true,
|
'strip_space' => true,
|
||||||
'tpl_path' => dirname(__FILE__) . '/',
|
'view_path' => dirname(__FILE__) . '/',
|
||||||
];
|
];
|
||||||
$data = ['name' => 'value'];
|
$data = ['name' => 'value'];
|
||||||
$template->display('display', $data, $config);
|
$template->display('display', $data, $config);
|
||||||
@@ -360,10 +360,10 @@ EOF;
|
|||||||
|
|
||||||
public function testFetch()
|
public function testFetch()
|
||||||
{
|
{
|
||||||
$template = new Template();
|
$template = new Template();
|
||||||
$template->tpl_path = dirname(__FILE__) . '/';
|
$template->view_path = dirname(__FILE__) . '/';
|
||||||
$data = ['name' => 'value'];
|
$data = ['name' => 'value'];
|
||||||
$content = <<<EOF
|
$content = <<<EOF
|
||||||
{\$name}
|
{\$name}
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ EOF;
|
|||||||
public function testVarGet()
|
public function testVarGet()
|
||||||
{
|
{
|
||||||
$template = new Template();
|
$template = new Template();
|
||||||
$data = ['a' => 'a', 'b' => 'b'];
|
$data = ['a' => 'a', 'b' => 'b'];
|
||||||
$template->assign($data);
|
$template->assign($data);
|
||||||
$this->assertEquals($data, $template->get());
|
$this->assertEquals($data, $template->get());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user