From c6a60a82ca4132bd0daba74a711615defa3c5ce5 Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 11 Mar 2016 05:49:03 +0100 Subject: [PATCH] enable memcache amd msql --- tests/Config.php | 8 +- .../CacheResourceCustomMemcacheTest.php | 115 ++++++++++++------ 2 files changed, 85 insertions(+), 38 deletions(-) diff --git a/tests/Config.php b/tests/Config.php index c6663cff..3bed716d 100644 --- a/tests/Config.php +++ b/tests/Config.php @@ -7,12 +7,12 @@ * Smarty PHPUnit Config */ define('individualFolders', true); -define('MemCacheEnable', false); +define('MemCacheEnable', true); define('ApcCacheEnable', false); -define('MysqlCacheEnable', false); +define('MysqlCacheEnable', true); define('PdoCacheEnable', false); define('PdoGzipCacheEnable', false); -define('MysqlResourceEnable', false); +define('MysqlResourceEnable', true); define('DB_DSN', "mysql:dbname=test;host=localhost"); -define('DB_USER', "travis"); +define('DB_USER', "smarty"); define('DB_PASSWD', ""); diff --git a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php index 97319cd7..6041b7fb 100644 --- a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php +++ b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php @@ -5,46 +5,93 @@ * @package PHPunit * @author Uwe Tews */ -if (MemCacheEnable == true) { - include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php'; +include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php'; + +/** + * class for cache resource memcache tests + * + * @runTestsInSeparateProcess + * @preserveGlobalState disabled + * @backupStaticAttributes enabled + */ +class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon +{ + /** + * Sets up the fixture + * This method is called before a test is executed. + * + */ + public function setUp() + { + if (MemCacheEnable != true) { + $this->markTestSkipped('Memcache tests are disabled'); + } else { + if (!class_exists('Memcache')) { + $this->markTestSkipped('Memcache not available'); + } + } + $this->setUpSmarty(__DIR__); + parent::setUp(); + $this->smarty->setCachingType('memcachetest'); + } + + public function testInit() + { + $this->cleanDirs(); + } + + protected function doClearCacheAssertion($a, $b) + { + $this->assertEquals(- 1, $b); + } + + public function testGetCachedFilepathSubDirs() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#file:helloworld.tpl###'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } /** - * class for cache resource memcache tests - * - * @runTestsInSeparateProcess - * @preserveGlobalState disabled - * @backupStaticAttributes enabled + * test getCachedFilepath with cache_id */ - class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon + public function testGetCachedFilepathCacheId() { - /** - * Sets up the fixture - * This method is called before a test is executed. - * - */ - public function setUp() - { - if (MemCacheEnable != true) { - $this->markTestSkipped('Memcache tests are disabled'); - } else { - if (!class_exists('Memcache')) { - $this->markTestSkipped('Memcache not available'); - } - } - $this->setUpSmarty(dirname(__FILE__)); - parent::setUp(); - $this->smarty->setCachingType('memcachetest'); - } + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#file:helloworld.tpl#foo|bar##'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } - public function testInit() - { - $this->cleanDirs(); - } + /** + * test getCachedFilepath with compile_id + */ + public function testGetCachedFilepathCompileId() + { + $this->smarty->caching = true; + $this->smarty->cache_lifetime = 1000; + $tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar'); + $tpl->loadCached(); + $sha1 = $tpl->source->uid . '#file:helloworld.tpl##blar#'; + $this->assertEquals($sha1, $tpl->cached->filepath); + } - protected function doClearCacheAssertion($a, $b) - { - $this->assertEquals(- 1, $b); - } + /** + * test getCachedFilepath with cache_id and compile_id + */ + public function testGetCachedFilepathCacheIdCompileId() + { + $this->smarty->caching = true; + $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#'; + $this->assertEquals($sha1, $tpl->cached->filepath); } }