summaryrefslogtreecommitdiff
path: root/tests/UnitTests/CacheResourceTests/PDOgzip
diff options
context:
space:
mode:
Diffstat (limited to 'tests/UnitTests/CacheResourceTests/PDOgzip')
-rw-r--r--tests/UnitTests/CacheResourceTests/PDOgzip/CacheResourceCustomPDOGzipTest.php59
-rw-r--r--tests/UnitTests/CacheResourceTests/PDOgzip/cacheresource.pdo_gziptest.php21
2 files changed, 49 insertions, 31 deletions
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/PDOgzip/cacheresource.pdo_gziptest.php b/tests/UnitTests/CacheResourceTests/PDOgzip/cacheresource.pdo_gziptest.php
new file mode 100644
index 00000000..75745d60
--- /dev/null
+++ b/tests/UnitTests/CacheResourceTests/PDOgzip/cacheresource.pdo_gziptest.php
@@ -0,0 +1,21 @@
+<?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, Cached $cached)
+ {
+ if ($this->lockTime) {
+ $this->lockTime--;
+ if (!$this->lockTime) {
+ $this->releaseLock($smarty, $cached);
+ }
+ }
+ return parent::hasLock($smarty, $cached);
+ }
+}