summaryrefslogtreecommitdiff
path: root/tests/UnitTests/CacheResourceTests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/UnitTests/CacheResourceTests')
-rw-r--r--tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php9
-rw-r--r--tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php162
-rw-r--r--tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php28
-rw-r--r--tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php6
-rw-r--r--tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php61
-rw-r--r--tests/UnitTests/CacheResourceTests/PDO/cacheresource.pdotest.php (renamed from tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php)6
-rw-r--r--tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php59
-rw-r--r--tests/UnitTests/CacheResourceTests/PDOgzip/cacheresource.pdo_gziptest.php (renamed from tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php)6
-rw-r--r--tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php6
-rw-r--r--tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php226
-rw-r--r--tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php19
-rw-r--r--tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php4
-rw-r--r--tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php18
-rw-r--r--tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php21
-rw-r--r--tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php18
15 files changed, 309 insertions, 340 deletions
diff --git a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php
index fa3ca2b1..d75382d0 100644
--- a/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php
+++ b/tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php
@@ -2,17 +2,18 @@
/**
* Smarty PHPunit tests for cache resource Apc
*
- * @package PHPunit
+
* @author Uwe Tews
*/
include_once __DIR__ . '/../Memcache/CacheResourceCustomMemcacheTest.php';
+include_once __DIR__ . '/../_shared/PHPunitplugins/cacheresource.apctest.php';
/**
* class for cache resource file tests
*
- * @runTestsInSeparateProcess
+ *
* @preserveGlobalState disabled
- * @backupStaticAttributes enabled
+ *
*/
class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
{
@@ -24,7 +25,7 @@ class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
$this->setUpSmarty(__DIR__);
parent::setUp();
$this->smarty->setCachingType('apc');
- $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
+ $this->smarty->registerCacheResource('apc', new Smarty_CacheResource_Apctest());
}
}
diff --git a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
index 0205edbb..192cc531 100644
--- a/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
+++ b/tests/UnitTests/CacheResourceTests/File/CacheResourceFileTest.php
@@ -2,7 +2,7 @@
/**
* Smarty PHPunit tests for cache resource file
*
- * @package PHPunit
+
* @author Uwe Tews
*/
@@ -10,10 +10,6 @@ include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource file tests
- *
- * @runTestsInSeparateProcess
- * @preserveGlobalState disabled
- * @backupStaticAttributes enabled
*/
class CacheResourceFileTest extends CacheResourceTestCommon
{
@@ -41,8 +37,8 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl');
- $this->assertEquals($this->buildCachedPath($tpl, true, null, null, 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file')
- , $tpl->cached->filepath);
+
+ $this->assertRegExp('/.*\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);
}
/**
@@ -54,8 +50,8 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar');
- $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', null, 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file')
- , $tpl->cached->filepath);
+
+ $this->assertRegExp('/.*\/foo\/bar\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);
}
/**
@@ -67,8 +63,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar');
- $this->assertEquals($this->buildCachedPath($tpl, true, null, 'blar', 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file')
- , $tpl->cached->filepath);
+ $this->assertRegExp('/.*\/blar\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);
}
/**
@@ -80,8 +75,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar');
- $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', 'blar', 'helloworld.tpl', $type = 'file', $this->smarty->getTemplateDir(0), 'file')
- , $tpl->cached->filepath);
+ $this->assertRegExp('/.*\/foo\/bar\/blar\\/([a-f0-9]{2}\/){3}.*.php/', $tpl->getCached()->filepath);
}
/**
@@ -95,7 +89,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl);
- $this->assertTrue(file_exists($tpl->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
$this->assertEquals(1, $this->smarty->clearAllCache());
}
@@ -114,13 +108,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(2, $this->smarty->clearCache(null, 'foo|bar'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertFalse(file_exists($tpl3->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId2()
@@ -135,13 +129,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(2, $this->smarty->clearCache('helloworld.tpl'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId2Sub()
@@ -156,13 +150,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(2, $this->smarty->clearCache('helloworld.tpl'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId3()
@@ -177,13 +171,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId3Sub()
@@ -198,13 +192,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId4()
@@ -219,13 +213,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId4Sub()
@@ -240,13 +234,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId5()
@@ -261,13 +255,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(2, $this->smarty->clearCache(null, null, 'blar'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertFalse(file_exists($tpl3->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheIdCompileId5Sub()
@@ -282,13 +276,13 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl2);
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$this->writeCachedContent($tpl3);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
$this->assertEquals(2, $this->smarty->clearCache(null, null, 'blar'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertFalse(file_exists($tpl3->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl3->getCached()->filepath));
}
public function testClearCacheCacheFile()
@@ -305,15 +299,15 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl3);
$tpl4 = $this->smarty->createTemplate('helloworld2.tpl');
$this->writeCachedContent($tpl4);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
- $this->assertTrue(file_exists($tpl4->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl4->getCached()->filepath));
$this->assertEquals(3, $this->smarty->clearCache('helloworld.tpl'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertFalse(file_exists($tpl3->cached->filepath));
- $this->assertTrue(file_exists($tpl4->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl3->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl4->getCached()->filepath));
}
public function testClearCacheCacheFileSub()
@@ -330,15 +324,15 @@ class CacheResourceFileTest extends CacheResourceTestCommon
$this->writeCachedContent($tpl3);
$tpl4 = $this->smarty->createTemplate('helloworld2.tpl');
$this->writeCachedContent($tpl4);
- $this->assertTrue(file_exists($tpl->cached->filepath));
- $this->assertTrue(file_exists($tpl2->cached->filepath));
- $this->assertTrue(file_exists($tpl3->cached->filepath));
- $this->assertTrue(file_exists($tpl4->cached->filepath));
+ $this->assertTrue(file_exists($tpl->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl2->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl3->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl4->getCached()->filepath));
$this->assertEquals(3, $this->smarty->clearCache('helloworld.tpl'));
- $this->assertFalse(file_exists($tpl->cached->filepath));
- $this->assertFalse(file_exists($tpl2->cached->filepath));
- $this->assertFalse(file_exists($tpl3->cached->filepath));
- $this->assertTrue(file_exists($tpl4->cached->filepath));
+ $this->assertFalse(file_exists($tpl->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl2->getCached()->filepath));
+ $this->assertFalse(file_exists($tpl3->getCached()->filepath));
+ $this->assertTrue(file_exists($tpl4->getCached()->filepath));
}
/**
diff --git a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php
index 434f2fa1..865f427d 100644
--- a/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php
+++ b/tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php
@@ -2,7 +2,7 @@
/**
* Smarty PHPunit tests for cache resource memcache
*
- * @package PHPunit
+
* @author Uwe Tews
*/
@@ -11,9 +11,9 @@ include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
/**
* class for cache resource memcache tests
*
- * @runTestsInSeparateProcess
- * @preserveGlobalState disabled
- * @backupStaticAttributes enabled
+ *
+ *
+ *
*/
class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
{
@@ -47,9 +47,8 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
$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);
+ $sha1 = $tpl->getSource()->uid . '#helloworld_tpl##';
+ $this->assertEquals($sha1, $tpl->getCached()->filepath);
}
/**
@@ -60,9 +59,8 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
$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);
+ $sha1 = $tpl->getSource()->uid . '#helloworld_tpl#foo|bar#';
+ $this->assertEquals($sha1, $tpl->getCached()->filepath);
}
/**
@@ -73,9 +71,8 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
$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);
+ $sha1 = $tpl->getSource()->uid . '#helloworld_tpl##blar';
+ $this->assertEquals($sha1, $tpl->getCached()->filepath);
}
/**
@@ -86,8 +83,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
$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);
+ $sha1 = $tpl->getSource()->uid . '#helloworld_tpl#foo|bar#blar';
+ $this->assertEquals($sha1, $tpl->getCached()->filepath);
}
}
diff --git a/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php b/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php
index 3db8ccd8..c00a0282 100644
--- a/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php
+++ b/tests/UnitTests/CacheResourceTests/Mysql/CacheResourceCustomMysqlTest.php
@@ -2,7 +2,7 @@
/**
* Smarty PHPunit tests for cache resource mysql
*
- * @package PHPunit
+
* @author Uwe Tews
*/
if (MysqlCacheEnable == true) {
@@ -12,9 +12,9 @@ if (MysqlCacheEnable == true) {
/**
* class for cache resource file tests
*
- * @runTestsInSeparateProcess
+ *
* @preserveGlobalState disabled
- * @backupStaticAttributes enabled
+ *
*/
class CacheResourceCustomMysqlTest extends CacheResourceTestCommon
{
diff --git a/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php b/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php
index fc9d0afd..2a372450 100644
--- a/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php
+++ b/tests/UnitTests/CacheResourceTests/PDO/CacheResourceCustomPDOTest.php
@@ -2,46 +2,41 @@
/**
* Smarty PHPunit tests for cache resource Pdo
*
- * @package PHPunit
+
* @author Uwe Tews
*/
-if (PdoCacheEnable == true) {
- include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
+include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
+include_once __DIR__ . '/cacheresource.pdotest.php';
- /**
- * class for cache resource file tests
- *
- * @runTestsInSeparateProcess
- * @preserveGlobalState disabled
- * @backupStaticAttributes enabled
- */
- class CacheResourceCustomPDOTest extends CacheResourceTestCommon
- {
+/**
+ * class for cache resource file tests
+ *
+ *
+ * @preserveGlobalState disabled
+ *
+ */
+class CacheResourceCustomPDOTest extends CacheResourceTestCommon
+{
- public function setUp($dir = null, $clear = true)
- {
- if (PdoCacheEnable != true) {
- $this->markTestSkipped('mysql Pdo tests are disabled');
- }
- if (self::$init) {
- $this->getConnection();
- }
- $this->setUpSmarty(__DIR__);
- parent::setUp();
- $this->smarty->setCachingType('pdo');
- $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
- $this->assertTrue(false !== $this->smarty->loadPlugin('Smarty_CacheResource_Pdotest'),
- 'loadPlugin() could not load PDO cache resource');
- $this->smarty->registerCacheResource('pdo',
- new Smarty_CacheResource_Pdotest($this->getPDO(), 'output_cache'));
+ public function setUp($dir = null, $clear = true): void
+ {
+ if (PdoCacheEnable != true) {
+ $this->markTestSkipped('mysql Pdo tests are disabled');
}
-
- public function testInit()
- {
- $this->cleanDirs();
- $this->initMysqlCache();
+ if (self::$init) {
+ $this->getConnection();
}
+ $this->setUpSmarty(__DIR__);
+ parent::setUp();
+ $this->smarty->registerCacheResource('pdo',
+ new Smarty_CacheResource_Pdotest($this->getPDO(), 'output_cache'));
+ }
+
+ public function testInit()
+ {
+ $this->cleanDirs();
+ $this->initMysqlCache();
}
}
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php b/tests/UnitTests/CacheResourceTests/PDO/cacheresource.pdotest.php
index 4d695983..53ae840a 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdotest.php
+++ b/tests/UnitTests/CacheResourceTests/PDO/cacheresource.pdotest.php
@@ -1,13 +1,15 @@
<?php
-require_once SMARTY_DIR . '../demo/plugins/cacheresource.pdo.php';
+use Smarty\Template\Cached;
+
+require_once __DIR__ . '/../../__shared/cacheresources/cacheresource.pdo.php';
class Smarty_CacheResource_Pdotest extends Smarty_CacheResource_Pdo
{
public $lockTime = 0;
- public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
+ public function hasLock(\Smarty\Smarty $smarty, Cached $cached)
{
if ($this->lockTime) {
$this->lockTime--;
diff --git a/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php b/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php
index 5df30e25..bcd89b8d 100644
--- a/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php
+++ b/tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php
@@ -2,44 +2,41 @@
/**
* Smarty PHPunit tests for cache resource file
*
- * @package PHPunit
+
* @author Uwe Tews
*/
-if (PdoGzipCacheEnable == true) {
- include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
- /**
- * class for cache resource file tests
- *
- * @backupStaticAttributes enabled
- */
- class CacheResourceCustomPDOGzipTest extends CacheResourceTestCommon
- {
+include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
+include_once __DIR__ . '/cacheresource.pdo_gziptest.php';
- public function setUp($dir = null, $clear = true)
- {
- if (PdoGzipCacheEnable != true) {
- $this->markTestSkipped('mysql Pdo Gzip tests are disabled');
- }
- if (self::$init) {
- $this->getConnection();
- }
- $this->setUpSmarty(__DIR__);
- parent::setUp();
- $this->smarty->setCachingType('pdo');
- $this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
- $this->assertTrue(false !== $this->smarty->loadPlugin('Smarty_CacheResource_Pdo_Gziptest'),
- 'loadPlugin() could not load PDOGzip cache resource');
- $this->smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo_Gziptest($this->getPDO(),
- 'output_cache'));
- }
+/**
+ * class for cache resource file tests
+ *
+ *
+ */
+class CacheResourceCustomPDOGzipTest extends CacheResourceTestCommon
+{
- public function testInit()
- {
- $this->cleanDirs();
- $this->initMysqlCache();
+ public function setUp($dir = null, $clear = true): void
+ {
+ if (PdoGzipCacheEnable != true) {
+ $this->markTestSkipped('mysql Pdo Gzip tests are disabled');
+ }
+ if (self::$init) {
+ $this->getConnection();
}
+ $this->setUpSmarty(__DIR__);
+ parent::setUp();
+ $this->smarty->setCachingType('pdo');
+ $this->smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo_Gziptest($this->getPDO(),
+ 'output_cache'));
+ }
+
+ public function testInit()
+ {
+ $this->cleanDirs();
+ $this->initMysqlCache();
}
}
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php b/tests/UnitTests/CacheResourceTests/PDOgzip/cacheresource.pdo_gziptest.php
index e7dfa5f2..75745d60 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.pdo_gziptest.php
+++ b/tests/UnitTests/CacheResourceTests/PDOgzip/cacheresource.pdo_gziptest.php
@@ -1,12 +1,14 @@
<?php
-require_once SMARTY_DIR . '../demo/plugins/cacheresource.pdo_gzip.php';
+use Smarty\Template\Cached;
+
+require_once __DIR__ . '/../../__shared/cacheresources/cacheresource.pdo_gzip.php';
class Smarty_CacheResource_Pdo_Gziptest extends Smarty_CacheResource_Pdo_Gzip
{
public $lockTime = 0;
- public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
+ public function hasLock(\Smarty\Smarty $smarty, Cached $cached)
{
if ($this->lockTime) {
$this->lockTime--;
diff --git a/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php b/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php
index 8bd34941..03acf270 100644
--- a/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php
+++ b/tests/UnitTests/CacheResourceTests/Registered/CacheResourceCustomRegisteredTest.php
@@ -2,7 +2,7 @@
/**
* Smarty PHPunit tests for cache resource registered
*
- * @package PHPunit
+
* @author Uwe Tews
*/
if (MysqlCacheEnable == true) {
@@ -11,9 +11,9 @@ if (MysqlCacheEnable == true) {
/**
* class for cache resource file tests
*
- * @runTestsInSeparateProcess
+ *
* @preserveGlobalState disabled
- * @backupStaticAttributes enabled
+ *
*/
class CacheResourceCustomRegisteredTest extends CacheResourceTestCommon
{
diff --git a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php
index a5361c18..222f1ad2 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php
+++ b/tests/UnitTests/CacheResourceTests/_shared/CacheResourceTestCommon.php
@@ -2,16 +2,18 @@
/**
* Smarty PHPunit tests for cache resource file
*
- * @package PHPunit
+
* @author Uwe Tews
*/
+use Smarty\Template;
+
/**
* class for cache resource file tests
*
- * @backupStaticAttributes enabled
+ *
*/
-class CacheResourceTestCommon extends PHPUnit_Smarty
+abstract class CacheResourceTestCommon extends PHPUnit_Smarty
{
public static $touchResource = null;
@@ -28,7 +30,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->assertEquals($a, $b);
}
- public function compiledPrefilter($text, Smarty_Internal_Template $tpl)
+ public function compiledPrefilter($text, Template $tpl)
{
$replace = $tpl->getTemplateVars('test');
return str_replace('#', $replace ?? '', $text);
@@ -43,7 +45,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->cache_lifetime = 1000;
$this->smarty->setUseSubDirs(true);
$tpl = $this->smarty->createTemplate('helloworld.tpl');
- $this->assertEquals($this->buildCachedPath($tpl), $tpl->cached->filepath);
+ $this->assertEquals($this->buildCachedPath($tpl), $tpl->getCached()->filepath);
}
/**
@@ -54,7 +56,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->caching = true;
$this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar');
- $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar'), $tpl->cached->filepath);
+ $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar'), $tpl->getCached()->filepath);
}
/**
@@ -65,7 +67,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->caching = true;
$this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('helloworld.tpl', null, 'blar');
- $this->assertEquals($this->buildCachedPath($tpl, true, null, 'blar'), $tpl->cached->filepath);
+ $this->assertEquals($this->buildCachedPath($tpl, true, null, 'blar'), $tpl->getCached()->filepath);
}
/**
@@ -76,7 +78,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->caching = true;
$this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar');
- $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', 'blar'), $tpl->cached->filepath);
+ $this->assertEquals($this->buildCachedPath($tpl, true, 'foo|bar', 'blar'), $tpl->getCached()->filepath);
}
/**
@@ -89,7 +91,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->cache_lifetime = 1000;
$tpl = $this->smarty->createTemplate('helloworld.tpl', 'foo|bar', 'blar');
$tpl->writeCachedContent('hello world');
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
// Custom CacheResources may return -1 if they can't tell the number of deleted elements
//$this->assertEquals(-1, $this->smarty->clearAllCache());
}
@@ -110,15 +112,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world 3');
// test cached content
- $this->assertEquals('hello world 1', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world 2', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world 3', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world 1', $tpl->getCachedContent());
+ $this->assertEquals('hello world 2', $tpl2->getCachedContent());
+ $this->assertEquals('hello world 3', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(2, $this->smarty->clearCache(null, 'foo|bar'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world 2', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertEquals('hello world 2', $tpl2->getCachedContent());
+ $this->assertNull($tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId2()
@@ -134,15 +136,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(2, $this->smarty->clearCache('helloworld.tpl'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId2Sub()
@@ -158,15 +160,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(2, $this->smarty->clearCache('helloworld.tpl'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId3()
@@ -182,15 +184,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
// test that caches are deleted properly
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId3Sub()
@@ -206,15 +208,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
// test that caches are deleted properly
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId4()
@@ -230,15 +232,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
// test that caches are deleted properly
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId4Sub()
@@ -254,15 +256,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(1, $this->smarty->clearCache('helloworld.tpl', null, 'blar2'));
// test that caches are deleted properly
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId5()
@@ -278,15 +280,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(2, $this->smarty->clearCache(null, null, 'blar'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertNull($tpl3->getCachedContent());
}
public function testClearCacheCacheIdCompileId5Sub()
@@ -302,15 +304,15 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl3 = $this->smarty->createTemplate('helloworld2.tpl', 'foo|bar', 'blar');
$tpl3->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(2, $this->smarty->clearCache(null, null, 'blar'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertNull($tpl3->getCachedContent());
}
public function testClearCacheCacheFile()
@@ -328,17 +330,17 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl4 = $this->smarty->createTemplate('helloworld2.tpl');
$tpl4->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
+ $this->assertEquals('hello world', $tpl4->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(3, $this->smarty->clearCache('helloworld.tpl'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertNull($tpl3->getCachedContent());
+ $this->assertEquals('hello world', $tpl4->getCachedContent());
}
/**
@@ -351,25 +353,32 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->clearAllCache();
// create and cache templates
$tpl = $this->smarty->createTemplate('helloworld.tpl');
- $tpl->writeCachedContent('hello world');
+ $tpl->writeCachedContent('something else 1');
$tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar');
- $tpl2->writeCachedContent('hello world');
+ $tpl2->writeCachedContent('something else 2');
$tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar');
- $tpl3->writeCachedContent('hello world');
+ $tpl3->writeCachedContent('something else 3');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
- sleep(10);
+ $this->assertEquals('something else 1', $tpl->getCachedContent());
+ $this->assertEquals('something else 2', $tpl2->getCachedContent());
+ $this->assertEquals('something else 3', $tpl3->getCachedContent());
+ sleep(4);
$tpl4 = $this->smarty->createTemplate('helloworld2.tpl');
- $tpl4->writeCachedContent('hello world');
+ $tpl4->writeCachedContent('something else 4');
+
// test number of deleted caches
- $this->doClearCacheAssertion(3,$this->smarty->clearAllCache(5));
+ $this->doClearCacheAssertion(3,$this->smarty->clearAllCache(2));
+
+ $tpl = $this->smarty->createTemplate('helloworld.tpl');
+ $tpl2 = $this->smarty->createTemplate('helloworld.tpl', null, 'bar');
+ $tpl3 = $this->smarty->createTemplate('helloworld.tpl', 'buh|blar');
+ $tpl4 = $this->smarty->createTemplate('helloworld2.tpl');
+
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
+ $this->assertEquals('something else 4', $tpl4->getCachedContent());
}
public function testClearCacheCacheFileSub()
@@ -387,22 +396,20 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$tpl4 = $this->smarty->createTemplate('helloworld2.tpl');
$tpl4->writeCachedContent('hello world');
// test cached content
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl2));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl3));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
+ $this->assertEquals('hello world', $tpl->getCachedContent());
+ $this->assertEquals('hello world', $tpl2->getCachedContent());
+ $this->assertEquals('hello world', $tpl3->getCachedContent());
+ $this->assertEquals('hello world', $tpl4->getCachedContent());
// test number of deleted caches
$this->doClearCacheAssertion(3, $this->smarty->clearCache('helloworld.tpl'));
// test that caches are deleted properly
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl2));
- $this->assertNull($tpl->cached->handler->getCachedContent($tpl3));
- $this->assertEquals('hello world', $tpl->cached->handler->getCachedContent($tpl4));
+ $this->assertNull($tpl->getCachedContent());
+ $this->assertNull($tpl2->getCachedContent());
+ $this->assertNull($tpl3->getCachedContent());
+ $this->assertEquals('hello world', $tpl4->getCachedContent());
}
/**
* Test caching
- * @runInSeparateProcess
- * @preserveGlobalState disabled
* @dataProvider data
* @group slow
*/
@@ -415,7 +422,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->smarty->cache_locking = true;
$this->smarty->locking_timeout = $lockTimeout;
}
- $this->smarty->compile_id = $compile_id;
+ $this->smarty->setCompileId($compile_id);
$this->smarty->cache_id = $cache_id;
$this->smarty->force_compile = $forceCompile;
$this->smarty->force_cache = $forceCache;
@@ -427,12 +434,12 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
}
$tpl = $this->smarty->createTemplate('cacheresource.tpl', $this->smarty);
if ($update) {
- $this->assertEquals($t,$tpl->source->getTimeStamp(), $testName . ' - source touch');
+ $this->assertEquals($t,$tpl->getSource()->getTimeStamp(), $testName . ' - source touch');
}
if ($lockTime) {
- $tpl->cached->handler->acquireLock($this->smarty, $tpl->cached);
- $tpl->cached->handler->lockTime = $lockTime;
- $tpl->cached->is_locked = false;
+ $tpl->getCached()->handler->acquireLock($this->smarty, $tpl->getCached());
+ $tpl->getCached()->handler->lockTime = $lockTime;
+ $tpl->getCached()->is_locked = false;
}
$start = time();
if (isset($isCached)) {
@@ -440,9 +447,9 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
if ($lockTimeout) {
$time = time() - $start;
$this->assertTrue($time >= $tmin && $time <= $tmax, $testName . ' - isCached() - lock time');
- $this->assertEquals(!$isCached, $tpl->cached->handler->hasLock($this->smarty, $tpl->cached), $testName . ' - isCached() - lock status');
+ $this->assertEquals(!$isCached, $tpl->getCached()->handler->hasLock($this->smarty, $tpl->getCached()), $testName . ' - isCached() - lock status');
} else {
- $this->assertFalse($tpl->cached->handler->hasLock($this->smarty, $tpl->cached), $testName . ' - isCached() - unexpected lock');
+ $this->assertFalse($tpl->getCached()->handler->hasLock($this->smarty, $tpl->getCached()), $testName . ' - isCached() - unexpected lock');
}
}
$this->assertEquals("cache resource test:{$testNumber} compiled:{$compileTestNumber} rendered:{$renderTestNumber}", $this->smarty->fetch($tpl), $testName . ' - fetch() failure');
@@ -450,7 +457,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$time = time() - $start;
$this->assertTrue($time >= $tmin && $time <= $tmax, $testName . ' - fetch() - lock time');
}
- $this->assertFalse($tpl->cached->handler->hasLock($this->smarty, $tpl->cached, $testName . ' - lock not removed'));
+ $this->assertFalse($tpl->getCached()->handler->hasLock($this->smarty, $tpl->getCached(), $testName . ' - lock not removed'));
}
public function data(){
@@ -505,12 +512,7 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
array(10, 4, 6, null, false, 2, 10, false, false, false, 32, 32, 32, 'lock timeout - new compiled'),
);
}
- /**
- *
- * @runInSeparateProcess
- * @preserveGlobalState disabled
- *
- */
+
public function testCachingDisabled1()
{
$this->smarty->assign('test', 50);
@@ -518,12 +520,6 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
$this->assertFalse($tpl->isCached(), 'isCached() status');
$this->assertEquals('cache resource test:50 compiled:50 rendered:50', $this->smarty->fetch($tpl), 'fetch()');
}
- /**
- *
- * @runInSeparateProcess
- * @preserveGlobalState disabled
- *
- */
public function testCachingDisabled2()
{
$this->smarty->assign('test', 51);
@@ -534,8 +530,6 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
/**
* Test caching
- * @runInSeparateProcess
- * @preserveGlobalState disabled
* @dataProvider dataDir
*
*/
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php
index a5dddb28..38b061dc 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php
+++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php
@@ -1,12 +1,16 @@
<?php
-require_once SMARTY_DIR . '../demo/plugins/cacheresource.apc.php';
+use Smarty\Smarty;
+use Smarty\Template;
+use Smarty\Template\Cached;
+
+require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.apc.php';
class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc
{
public $lockTime = 0;
- public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
+ public function hasLock(Smarty $smarty, Cached $cached)
{
if ($this->lockTime) {
$this->lockTime--;
@@ -17,7 +21,7 @@ class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc
return parent::hasLock($smarty, $cached);
}
- public function get(Smarty_Internal_Template $_template)
+ public function get(Template $_template)
{
$this->contents = array();
$this->timestamps = array();
@@ -26,13 +30,4 @@ class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc
return $t ? $t : null;
}
- public function __sleep()
- {
- return array();
- }
-
- public function __wakeup()
- {
- $this->__construct();
- }
}
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php
index 369460b7..f97147fa 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php
+++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php
@@ -1,11 +1,11 @@
<?php
-class Smarty_CacheResource_Filetest extends Smarty_Internal_CacheResource_File
+class Smarty_CacheResource_Filetest extends \Smarty\Cacheresource\File
{
public $lockTime = 0;
- public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
+ public function hasLock(\Smarty\Smarty $smarty, \Smarty\Template\Cached $cached)
{
if ($this->lockTime) {
$this->lockTime--;
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php
index 8569ec8a..77f9d5f9 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php
+++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.memcachetest.php
@@ -1,12 +1,15 @@
<?php
-require_once SMARTY_DIR . '../demo/plugins/cacheresource.memcache.php';
+use Smarty\Template;
+use Smarty\Template\Cached;
+
+require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.memcache.php';
class Smarty_CacheResource_Memcachetest extends Smarty_CacheResource_Memcache
{
public $lockTime = 0;
- public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
+ public function hasLock(\Smarty\Smarty $smarty, Cached $cached)
{
if ($this->lockTime) {
$this->lockTime--;
@@ -17,7 +20,7 @@ class Smarty_CacheResource_Memcachetest extends Smarty_CacheResource_Memcache
return parent::hasLock($smarty, $cached);
}
- public function get(Smarty_Internal_Template $_template)
+ public function get(Template $_template)
{
$this->contents = array();
$this->timestamps = array();
@@ -26,13 +29,4 @@ class Smarty_CacheResource_Memcachetest extends Smarty_CacheResource_Memcache
return $t ? $t : null;
}
- public function __sleep()
- {
- return array();
- }
-
- public function __wakeup()
- {
- $this->__construct();
- }
}
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php
index 47c47e45..5bc53bd1 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php
+++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.mysqltest.php
@@ -1,24 +1,19 @@
<?php
-require_once SMARTY_DIR . '../demo/plugins/cacheresource.mysql.php';
+use Smarty\Exception;
+use Smarty\Template\Cached;
+
+require_once __DIR__ . '/../../../__shared/cacheresources/cacheresource.mysql.php';
class Smarty_CacheResource_Mysqltest extends Smarty_CacheResource_Mysql
{
public $lockTime = 0;
- public function __construct() {
- try {
- $this->db = PHPUnit_Smarty::$pdo;
- } catch (PDOException $e) {
- throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
- }
- $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
- $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
- $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
- VALUES (:id, :name, :cache_id, :compile_id, :content)');
- }
+ protected function db(): PDO {
+ return PHPUnit_Smarty::$pdo;
+ }
- public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
+ public function hasLock(\Smarty\Smarty $smarty, Cached $cached)
{
if ($this->lockTime) {
$this->lockTime--;
diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php
index d5676d61..0aa280c4 100644
--- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php
+++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php
@@ -1,19 +1,23 @@
<?php
-class Smarty_Resource_Filetest extends Smarty_Internal_Resource_File
+use Smarty\Resource\FilePlugin;
+use Smarty\Template;
+use Smarty\Template\Source;
+
+class Smarty_Resource_FiletestPlugin extends FilePlugin
{
/**
- * populate Source Object with meta data from Resource
+ * populate Source Object with metadata from Resource
*
- * @param Smarty_Template_Source $source source object
- * @param Smarty_Internal_Template $_template template object
+ * @param Source $source source object
+ * @param Template $_template template object
*/
- public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
+ public function populate(Source $source, Template $_template = null)
{
parent::populate($source, $_template);
if ($source->exists) {
- if (isset(CacheResourceTestCommon::$touchResource[$source->filepath])) {
- $source->timestamp = CacheResourceTestCommon::$touchResource[$source->filepath];
+ if (isset(CacheResourceTestCommon::$touchResource[$source->getResourceName()])) {
+ $source->timestamp = CacheResourceTestCommon::$touchResource[$source->getResourceName()];
}
}
}