From b823237d671dd3bcdad5477f3e71b26234a4b90f Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 15 May 2016 11:12:04 +0200 Subject: [PATCH] update unit teste --- .../CacheResourceCustomMemcacheTest.php | 8 ++-- .../ResourceExtendsAllPluginTest.php | 42 ++++++++++++++----- .../ResourceTests/Eval/EvalResourceTest.php | 2 +- .../Stream/StreamResourceTest.php | 2 +- .../String/StringResourceTest.php | 2 +- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php index 6041b7fb..ee6ebc76 100644 --- a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php +++ b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php @@ -52,7 +52,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('helloworld.tpl'); $tpl->loadCached(); - $sha1 = $tpl->source->uid . '#file:helloworld.tpl###'; + $sha1 = $tpl->source->uid . '#helloworld_tpl##'; $this->assertEquals($sha1, $tpl->cached->filepath); } @@ -65,7 +65,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar'); $tpl->loadCached(); - $sha1 = $tpl->source->uid . '#file:helloworld.tpl#foo|bar##'; + $sha1 = $tpl->source->uid . '#helloworld_tpl#foo|bar#'; $this->assertEquals($sha1, $tpl->cached->filepath); } @@ -78,7 +78,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar'); $tpl->loadCached(); - $sha1 = $tpl->source->uid . '#file:helloworld.tpl##blar#'; + $sha1 = $tpl->source->uid . '#helloworld_tpl##blar'; $this->assertEquals($sha1, $tpl->cached->filepath); } @@ -91,7 +91,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon $this->smarty->cache_lifetime = 1000; $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar'); $tpl->loadCached(); - $sha1 = $tpl->source->uid . '#file:helloworld.tpl#foo|bar#blar#'; + $sha1 = $tpl->source->uid . '#helloworld_tpl#foo|bar#blar'; $this->assertEquals($sha1, $tpl->cached->filepath); } } diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php index 8cfb3c44..e89e11bc 100644 --- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php +++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php @@ -10,7 +10,7 @@ * class for demo resource plugin extendsall tests * * @runTestsInSeparateProcess - * @preserveGlobalState disabled + * @preserveGlobalState disabled * @backupStaticAttributes enabled */ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty @@ -27,6 +27,7 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty /** * test extendsall + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -40,9 +41,10 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall.tpl')); } - /** + /** * test extendsall * changed tepmplate_setting + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -66,8 +68,10 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty $expected = "templatestemplates"; $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall2.tpl')); } + /** * test extendsall special application + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -76,22 +80,28 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); $this->smarty->setTemplateDir(array('./templates_2', './templates_1',)); $this->smarty->setDefaultResourceType('extendsall'); - $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); } + /** * test extendsall special application + * * @runInSeparateProcess * @preserveGlobalState disabled */ public function testResourcePluginExtendsallSpecialApplication2() { $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); - $this->smarty->setTemplateDir(array('./templates_3','./templates_2', './templates_1',)); + $this->smarty->setTemplateDir(array('./templates_3', './templates_2', './templates_1',)); $this->smarty->setDefaultResourceType('extendsall'); - $this->assertEquals('

data1 from templates1

data1 from templates3

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + $this->assertEquals('

data1 from templates1

data1 from templates3

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); } + /** * test extendsall special application + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -101,10 +111,13 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); $this->smarty->setTemplateDir(array('./templates_2', './templates_1',)); $this->smarty->setDefaultResourceType('extendsall'); - $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); } + /** * test extendsall special application + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -114,10 +127,13 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); $this->smarty->setTemplateDir(array('./templates_2', './templates_1',)); $this->smarty->setDefaultResourceType('extendsall'); - $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + $this->assertEquals('

data1 from templates1

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); } + /** * test extendsall special application + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -125,12 +141,15 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty { $this->smarty->setMergeCompiledIncludes(true); $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); - $this->smarty->setTemplateDir(array('./templates_3','./templates_2', './templates_1',)); + $this->smarty->setTemplateDir(array('./templates_3', './templates_2', './templates_1',)); $this->smarty->setDefaultResourceType('extendsall'); - $this->assertEquals('

data1 from templates1

data1 from templates3

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + $this->assertEquals('

data1 from templates1

data1 from templates3

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); } + /** * test extendsall special application + * * @runInSeparateProcess * @preserveGlobalState disabled */ @@ -138,8 +157,9 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty { $this->smarty->setMergeCompiledIncludes(true); $this->smarty->addPluginsDir(SMARTY_DIR . "../demo/plugins/"); - $this->smarty->setTemplateDir(array('./templates_3','./templates_2', './templates_1',)); + $this->smarty->setTemplateDir(array('./templates_3', './templates_2', './templates_1',)); $this->smarty->setDefaultResourceType('extendsall'); - $this->assertEquals('

data1 from templates1

data1 from templates3

data1 from templates2

data2 from templates1

', $this->smarty->fetch('template.tpl')); + $this->assertEquals('

data1 from templates1

data1 from templates3

data1 from templates2

data2 from templates1

', + $this->smarty->fetch('template.tpl')); } } diff --git a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php index a3269cbb..27635f02 100644 --- a/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php +++ b/tests/UnitTests/ResourceTests/Eval/EvalResourceTest.php @@ -54,7 +54,7 @@ class EvalResourceTest extends PHPUnit_Smarty public function testGetTemplateTimestamp() { $tpl = $this->smarty->createTemplate('eval:hello world'); - $this->assertFalse($tpl->source->getTimeStamp()); + $this->assertTrue($tpl->source->getTimeStamp()); } /** diff --git a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php index 122a8b22..a2a1525f 100644 --- a/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php +++ b/tests/UnitTests/ResourceTests/Stream/StreamResourceTest.php @@ -53,7 +53,7 @@ class StreamResourceTest extends PHPUnit_Smarty public function testGetTemplateTimestamp() { $tpl = $this->smarty->createTemplate('global:mytest'); - $this->assertFalse($tpl->source->getTimeStamp()); + $this->assertTrue($tpl->source->getTimeStamp()); } /** diff --git a/tests/UnitTests/ResourceTests/String/StringResourceTest.php b/tests/UnitTests/ResourceTests/String/StringResourceTest.php index 83e5d30f..efee37c0 100644 --- a/tests/UnitTests/ResourceTests/String/StringResourceTest.php +++ b/tests/UnitTests/ResourceTests/String/StringResourceTest.php @@ -65,7 +65,7 @@ class StringResourceTest extends PHPUnit_Smarty public function testGetTemplateTimestamp() { $tpl = $this->smarty->createTemplate('string:hello world'); - $this->assertEquals(0, $tpl->source->getTimeStamp()); + $this->assertTrue($tpl->source->getTimeStamp()); } /**