mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-10 19:15:21 +02:00
Adds support for PHP8.0, dropping support for PHP7.0 and below. Backwards incompatible changes: - Dropped support for php asp tags in templates (removed from php since php7.0) - Dropped deprecated API calls that where only accessible through SmartyBC - Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is. - Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required - Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants - Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods - Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead. - $smarty->registerResource() no longer accepts an array of callback functions See the changelog for more details. Switched CI from Travis to Github CI.
94 lines
2.6 KiB
PHP
94 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Smarty PHPunit tests for cache resource memcache
|
|
*
|
|
* @package PHPunit
|
|
* @author Uwe Tews
|
|
*/
|
|
|
|
include_once dirname(__FILE__) . '/../_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(): void
|
|
{
|
|
if (!class_exists('Memcache')) {
|
|
$this->markTestSkipped('Memcache not available');
|
|
}
|
|
$this->setUpSmarty(dirname(__FILE__));
|
|
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 . '#helloworld_tpl##';
|
|
$this->assertEquals($sha1, $tpl->cached->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');
|
|
$tpl->loadCached();
|
|
$sha1 = $tpl->source->uid . '#helloworld_tpl#foo|bar#';
|
|
$this->assertEquals($sha1, $tpl->cached->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');
|
|
$tpl->loadCached();
|
|
$sha1 = $tpl->source->uid . '#helloworld_tpl##blar';
|
|
$this->assertEquals($sha1, $tpl->cached->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');
|
|
$tpl->loadCached();
|
|
$sha1 = $tpl->source->uid . '#helloworld_tpl#foo|bar#blar';
|
|
$this->assertEquals($sha1, $tpl->cached->filepath);
|
|
}
|
|
}
|