Files

86 lines
2.4 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Smarty PHPunit tests for cache resource memcache
*
2023-08-08 00:04:14 +02:00
* @author Uwe Tews
*/
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource memcache tests
*
2023-08-08 00:04:14 +02:00
*
*
*
*/
class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
{
/**
* Sets up the fixture
* This method is called before a test is executed.
*
*/
2021-10-13 12:15:17 +02:00
public function setUp(): void
{
2021-10-13 12:15:17 +02:00
if (!class_exists('Memcache')) {
$this->markTestSkipped('Memcache not available');
}
$this->setUpSmarty(__DIR__);
parent::setUp();
$this->smarty->setCachingType('memcachetest');
}
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');
2023-08-08 00:04:14 +02:00
$sha1 = $tpl->getSource()->uid . '#helloworld_tpl##';
$this->assertEquals($sha1, $tpl->getCached()->filepath);
}
/**
* test getCachedFilepath with cache_id
*/
public function testGetCachedFilepathCacheId()
{
$this->smarty->caching = true;
$this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar');
2023-08-08 00:04:14 +02:00
$sha1 = $tpl->getSource()->uid . '#helloworld_tpl#foo|bar#';
$this->assertEquals($sha1, $tpl->getCached()->filepath);
}
/**
* 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');
2023-08-08 00:04:14 +02:00
$sha1 = $tpl->getSource()->uid . '#helloworld_tpl##blar';
$this->assertEquals($sha1, $tpl->getCached()->filepath);
}
/**
* 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');
2023-08-08 00:04:14 +02:00
$sha1 = $tpl->getSource()->uid . '#helloworld_tpl#foo|bar#blar';
$this->assertEquals($sha1, $tpl->getCached()->filepath);
}
}