This commit is contained in:
Uwe Tews
2015-07-01 03:13:32 +02:00
parent 441ac8e100
commit 5f8f92d75b
11 changed files with 36 additions and 22 deletions

View File

@@ -398,7 +398,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
} }
$tpl = $this->smarty->createTemplate('cacheresource.tpl', $this->smarty); $tpl = $this->smarty->createTemplate('cacheresource.tpl', $this->smarty);
if ($update) { if ($update) {
$this->assertEquals($t,$tpl->source->timestamp, $testName . ' - source touch'); $this->assertEquals($t,$tpl->source->getTimeStamp(), $testName . ' - source touch');
} }
if ($lockTime) { if ($lockTime) {
$tpl->cached->handler->acquireLock($this->smarty, $tpl->cached); $tpl->cached->handler->acquireLock($this->smarty, $tpl->cached);

View File

@@ -52,7 +52,7 @@ class EvalResourceTest extends PHPUnit_Smarty
public function testGetTemplateTimestamp() public function testGetTemplateTimestamp()
{ {
$tpl = $this->smarty->createTemplate('eval:hello world'); $tpl = $this->smarty->createTemplate('eval:hello world');
$this->assertFalse($tpl->source->timestamp); $this->assertFalse($tpl->source->getTimeStamp());
} }
/** /**
@@ -115,7 +115,7 @@ class EvalResourceTest extends PHPUnit_Smarty
public function testGetCompiledTimestamp() public function testGetCompiledTimestamp()
{ {
$tpl = $this->smarty->createTemplate('eval:hello world'); $tpl = $this->smarty->createTemplate('eval:hello world');
$this->assertFalse($tpl->compiled->timestamp); $this->assertFalse($tpl->compiled->getTimeStamp());
} }
/** /**

View File

@@ -77,8 +77,8 @@ class FileResourceTest extends PHPUnit_Smarty
public function testGetTemplateTimestamp() public function testGetTemplateTimestamp()
{ {
$tpl = $this->smarty->createTemplate('helloworld.tpl'); $tpl = $this->smarty->createTemplate('helloworld.tpl');
$this->assertTrue(is_integer($tpl->source->timestamp)); $this->assertTrue(is_integer($tpl->source->getTimeStamp()));
$this->assertEquals(10, strlen($tpl->source->timestamp)); $this->assertEquals(10, strlen($tpl->source->getTimeStamp()));
} }
public function testGetTemplateSource() public function testGetTemplateSource()
@@ -112,7 +112,7 @@ class FileResourceTest extends PHPUnit_Smarty
$tpl = $this->smarty->createTemplate('helloworld.tpl'); $tpl = $this->smarty->createTemplate('helloworld.tpl');
// create dummy compiled file // create dummy compiled file
file_put_contents($tpl->compiled->filepath, '<?php ?>'); file_put_contents($tpl->compiled->filepath, '<?php ?>');
touch($tpl->compiled->filepath, $tpl->source->timestamp); touch($tpl->compiled->filepath, $tpl->source->getTimeStamp());
} }
/** /**
@@ -121,9 +121,9 @@ class FileResourceTest extends PHPUnit_Smarty
public function testGetCompiledTimestamp() public function testGetCompiledTimestamp()
{ {
$tpl = $this->smarty->createTemplate('helloworld.tpl'); $tpl = $this->smarty->createTemplate('helloworld.tpl');
$this->assertTrue(is_integer($tpl->compiled->timestamp)); $this->assertTrue(is_integer($tpl->compiled->getTimeStamp()));
$this->assertEquals(10, strlen($tpl->compiled->timestamp)); $this->assertEquals(10, strlen($tpl->compiled->getTimeStamp()));
$this->assertEquals($tpl->compiled->timestamp, $tpl->source->timestamp); $this->assertEquals($tpl->compiled->getTimeStamp(), $tpl->source->getTimeStamp());
} }
public function testMustCompileExisting() public function testMustCompileExisting()
@@ -378,7 +378,7 @@ class FileResourceTest extends PHPUnit_Smarty
$this->_relativeMap($map); $this->_relativeMap($map);
$this->smarty->setTemplateDir(array( $this->smarty->setTemplateDir(array(
'templates/relativity/theory/', './templates/relativity/theory/',
)); ));
$map = array( $map = array(

View File

@@ -45,8 +45,8 @@ class PhpResourceTest extends PHPUnit_Smarty
public function testGetTemplateTimestamp() public function testGetTemplateTimestamp()
{ {
$tpl = $this->smarty->createTemplate('php:phphelloworld.php'); $tpl = $this->smarty->createTemplate('php:phphelloworld.php');
$this->assertTrue(is_integer($tpl->source->timestamp)); $this->assertTrue(is_integer($tpl->source->getTimeStamp()));
$this->assertEquals(10, strlen($tpl->source->timestamp)); $this->assertEquals(10, strlen($tpl->source->getTimeStamp()));
} }
/** /**
@@ -90,7 +90,7 @@ class PhpResourceTest extends PHPUnit_Smarty
public function testGetCompiledTimestamp() public function testGetCompiledTimestamp()
{ {
$tpl = $this->smarty->createTemplate('php:phphelloworld.php'); $tpl = $this->smarty->createTemplate('php:phphelloworld.php');
$this->assertFalse($tpl->compiled->timestamp); $this->assertFalse($tpl->compiled->getTimeStamp());
} }
/** /**

View File

@@ -47,8 +47,8 @@ class RegisteredResourceTest extends PHPUnit_Smarty
public function testResourcePluginTimestamp() public function testResourcePluginTimestamp()
{ {
$tpl = $this->smarty->createTemplate('rr:test'); $tpl = $this->smarty->createTemplate('rr:test');
$this->assertTrue(is_integer($tpl->source->timestamp)); $this->assertTrue(is_integer($tpl->source->getTimeStamp()));
$this->assertEquals(10, strlen($tpl->source->timestamp)); $this->assertEquals(10, strlen($tpl->source->getTimeStamp()));
} }
/** /**

View File

@@ -77,8 +77,8 @@ class ResourcePluginTest extends PHPUnit_Smarty
{ {
$this->smarty->addPluginsDir("./PHPunitplugins/"); $this->smarty->addPluginsDir("./PHPunitplugins/");
$tpl = $this->smarty->createTemplate('db:test'); $tpl = $this->smarty->createTemplate('db:test');
$this->assertTrue(is_integer($tpl->source->timestamp)); $this->assertTrue(is_integer($tpl->source->getTimeStamp()));
$this->assertEquals(10, strlen($tpl->source->timestamp)); $this->assertEquals(10, strlen($tpl->source->getTimeStamp()));
} }
} }

View File

@@ -51,7 +51,7 @@ class StreamResourceTest extends PHPUnit_Smarty
public function testGetTemplateTimestamp() public function testGetTemplateTimestamp()
{ {
$tpl = $this->smarty->createTemplate('global:mytest'); $tpl = $this->smarty->createTemplate('global:mytest');
$this->assertFalse($tpl->source->timestamp); $this->assertFalse($tpl->source->getTimeStamp());
} }
/** /**
@@ -105,7 +105,7 @@ class StreamResourceTest extends PHPUnit_Smarty
public function testGetCompiledTimestamp() public function testGetCompiledTimestamp()
{ {
$tpl = $this->smarty->createTemplate('global:mytest'); $tpl = $this->smarty->createTemplate('global:mytest');
$this->assertFalse($tpl->compiled->timestamp); $this->assertFalse($tpl->compiled->getTimeStamp());
} }
/** /**

View File

@@ -63,7 +63,7 @@ class StringResourceTest extends PHPUnit_Smarty
public function testGetTemplateTimestamp() public function testGetTemplateTimestamp()
{ {
$tpl = $this->smarty->createTemplate('string:hello world'); $tpl = $this->smarty->createTemplate('string:hello world');
$this->assertEquals(0, $tpl->source->timestamp); $this->assertEquals(0, $tpl->source->getTimeStamp());
} }
/** /**
@@ -117,7 +117,7 @@ class StringResourceTest extends PHPUnit_Smarty
public function testGetCompiledTimestamp() public function testGetCompiledTimestamp()
{ {
$tpl = $this->smarty->createTemplate('string:hello world'); $tpl = $this->smarty->createTemplate('string:hello world');
$this->assertFalse($tpl->compiled->timestamp); $this->assertFalse($tpl->compiled->getTimeStamp());
} }
/** /**

View File

@@ -32,7 +32,19 @@ class CompileIncludePhpTest extends PHPUnit_Smarty
public function testIncludePhpStringFileName() public function testIncludePhpStringFileName()
{ {
$this->smartyBC->disableSecurity(); $this->smartyBC->disableSecurity();
$tpl = $this->smartyBC->createTemplate("eval:start {include_php file='scripts/test_include_php.php'} end"); $tpl = $this->smartyBC->createTemplate('include_php.tpl');
$result = $this->smartyBC->fetch($tpl);
$this->assertContains("test include php", $result);
}
/**
* test include_php from trusted dir
*/
public function testIncludePhpTrusted()
{
$this->smartyBC->enableSecurity();
$this->smartyBC->security_policy->trusted_dir = '.\\scripts\\';
$tpl = $this->smartyBC->createTemplate('include_php_trusted.tpl');
$result = $this->smartyBC->fetch($tpl); $result = $this->smartyBC->fetch($tpl);
$this->assertContains("test include php", $result); $this->assertContains("test include php", $result);
} }

View File

@@ -0,0 +1 @@
start {include_php file='scripts/test_include_php.php'} end

View File

@@ -0,0 +1 @@
start {include_php file='test_include_php.php' once=false} end