summaryrefslogtreecommitdiff
path: root/tests/UnitTests/ResourceTests/Custom
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.uk>2026-05-09 20:22:12 +0100
committerGitHub <noreply@github.com>2026-05-09 20:22:12 +0100
commit83d593730b8cc305da96552307afb1d0c4e58883 (patch)
tree643997400b6beeace5f90cddedbbfb4137c7873a /tests/UnitTests/ResourceTests/Custom
parentdd391e1e8bada3f98c685f5e43289adc28ef684f (diff)
parentc139883770b12f92c9b21f69c35ad600d34f39e8 (diff)
downloadsmarty-83d593730b8cc305da96552307afb1d0c4e58883.tar.gz
smarty-83d593730b8cc305da96552307afb1d0c4e58883.tar.bz2
smarty-83d593730b8cc305da96552307afb1d0c4e58883.zip
Merge pull request #2 from smarty-php/master
Sync with master
Diffstat (limited to 'tests/UnitTests/ResourceTests/Custom')
-rw-r--r--tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php4
-rw-r--r--tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore2
-rw-r--r--tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore2
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php6
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore2
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/resources/resource.extendsall.php66
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore2
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php10
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore2
-rw-r--r--tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore2
10 files changed, 68 insertions, 30 deletions
diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php
index 610d8de3..d5413031 100644
--- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php
+++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/CustomResourceAmbiguousTest.php
@@ -25,10 +25,6 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
// Smarty::$_resource_cache = array();
}
- public function testInit()
- {
- $this->cleanDirs();
- }
protected function relative($path)
{
diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore b/tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore
deleted file mode 100644
index d88cc144..00000000
--- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/cache/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore anything in here, but keep this directory
-*
diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore
deleted file mode 100644
index d88cc144..00000000
--- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/templates_c/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore anything in here, but keep this directory
-*
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php
index 0cbbfce0..2d586922 100644
--- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php
+++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php
@@ -6,7 +6,7 @@
* @author Uwe Tews
*/
-require_once __DIR__ . '/../../../__shared/resources/resource.extendsall.php';
+require_once __DIR__ . '/resources/resource.extendsall.php';
/**
* class for demo resource plugin extendsall tests
@@ -22,10 +22,6 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty
$this->setUpSmarty(__DIR__);
}
- public function testInit()
- {
- $this->cleanDirs();
- }
/**
* test extendsall
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore
deleted file mode 100644
index d88cc144..00000000
--- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/cache/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore anything in here, but keep this directory
-*
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/resources/resource.extendsall.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/resources/resource.extendsall.php
new file mode 100644
index 00000000..14d37908
--- /dev/null
+++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/resources/resource.extendsall.php
@@ -0,0 +1,66 @@
+<?php
+
+use Smarty\Exception;
+use Smarty\Template;
+use Smarty\Template\Source;
+
+/**
+ * Extends All Resource
+ * Resource Implementation modifying the extends-Resource to walk
+ * through the template_dirs and inherit all templates of the same name
+ *
+
+ * @author Rodney Rehm
+ */
+class My_Resource_Extendsall extends \Smarty\Resource\ExtendsPlugin
+{
+ /**
+ * populate Source Object with meta data from Resource
+ *
+ * @param Source $source source object
+ * @param Template $_template template object
+ *
+ * @return void
+ */
+ public function populate(Source $source, ?Template $_template = null)
+ {
+ $uid = '';
+ $sources = array();
+ $timestamp = 0;
+ foreach ($source->getSmarty()->getTemplateDir() as $key => $directory) {
+ try {
+ $s = \Smarty\Template\Source::load(null, $source->getSmarty(),
+ 'file:' . '[' . $key . ']' . $source->name);
+ if (!$s->exists) {
+ continue;
+ }
+ $sources[ $s->uid ] = $s;
+ $uid .= $s->uid;
+ $timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
+ } catch (Exception $e) {
+ }
+ }
+ if (!$sources) {
+ $source->exists = false;
+ return;
+ }
+ $sources = array_reverse($sources, true);
+ reset($sources);
+ $s = current($sources);
+ $source->components = $sources;
+ $source->uid = sha1($uid . $source->getSmarty()->_joined_template_dir);
+ $source->exists = true;
+ $source->timestamp = $timestamp;
+ }
+
+ /**
+ * Disable timestamp checks for extendsall resource.
+ * The individual source components will be checked.
+ *
+ * @return bool false
+ */
+ public function checkTimestamps()
+ {
+ return false;
+ }
+}
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore
deleted file mode 100644
index d88cc144..00000000
--- a/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/templates_c/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore anything in here, but keep this directory
-*
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php
index 16d85489..2c98fae4 100644
--- a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php
+++ b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/ResourceMysqlPluginTest.php
@@ -24,17 +24,9 @@ if (MysqlResourceEnable == true) {
$this->getConnection();
}
$this->setUpSmarty(__DIR__);
- $this->smarty->addPluginsDir("./PHPunitplugins/");
- }
-
- /**
- *
- */
- public function testInit()
- {
- $this->cleanDirs();
$this->initMysqlResource();
PHPUnit_Smarty::$pdo->exec("REPLACE INTO templates (name, source) VALUES ('test.tpl', '{\$x = \'hello world\'}{\$x}')");
+ $this->smarty->addPluginsDir("./PHPunitplugins/");
}
/**
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore
deleted file mode 100644
index d88cc144..00000000
--- a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/cache/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore anything in here, but keep this directory
-*
diff --git a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore b/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore
deleted file mode 100644
index d88cc144..00000000
--- a/tests/UnitTests/ResourceTests/Custom/DemoPluginMysql/templates_c/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Ignore anything in here, but keep this directory
-*