enable memcache amd msql

This commit is contained in:
uwetews
2016-03-11 05:49:03 +01:00
parent 9a291b8da4
commit c6a60a82ca
2 changed files with 85 additions and 38 deletions

View File

@@ -7,12 +7,12 @@
* Smarty PHPUnit Config * Smarty PHPUnit Config
*/ */
define('individualFolders', true); define('individualFolders', true);
define('MemCacheEnable', false); define('MemCacheEnable', true);
define('ApcCacheEnable', false); define('ApcCacheEnable', false);
define('MysqlCacheEnable', false); define('MysqlCacheEnable', true);
define('PdoCacheEnable', false); define('PdoCacheEnable', false);
define('PdoGzipCacheEnable', false); define('PdoGzipCacheEnable', false);
define('MysqlResourceEnable', false); define('MysqlResourceEnable', true);
define('DB_DSN', "mysql:dbname=test;host=localhost"); define('DB_DSN', "mysql:dbname=test;host=localhost");
define('DB_USER', "travis"); define('DB_USER', "smarty");
define('DB_PASSWD', ""); define('DB_PASSWD', "");

View File

@@ -5,46 +5,93 @@
* @package PHPunit * @package PHPunit
* @author Uwe Tews * @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 * test getCachedFilepath with cache_id
*
* @runTestsInSeparateProcess
* @preserveGlobalState disabled
* @backupStaticAttributes enabled
*/ */
class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon public function testGetCachedFilepathCacheId()
{ {
/** $this->smarty->caching = true;
* Sets up the fixture $this->smarty->cache_lifetime = 1000;
* This method is called before a test is executed. $tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar');
* $tpl->loadCached();
*/ $sha1 = $tpl->source->uid . '#file:helloworld.tpl#foo|bar##';
public function setUp() $this->assertEquals($sha1, $tpl->cached->filepath);
{ }
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');
}
public function testInit() /**
{ * test getCachedFilepath with compile_id
$this->cleanDirs(); */
} 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) /**
{ * test getCachedFilepath with cache_id and compile_id
$this->assertEquals(- 1, $b); */
} 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);
} }
} }