summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2014-05-04 19:32:38 +0200
committerAndreas Gohr <andi@splitbrain.org>2014-05-04 19:32:38 +0200
commite17b5b89766fa83993f838e8df9cecd9cf9e86ab (patch)
tree04433256b13dfaf1fe860c0493b28f21d4a3fd7e /_test
parent923b1981147d725b97b4c6500981557fdc3be49b (diff)
parent59b1d9181358f31d8d65c38a64fb43a68c0fadb1 (diff)
downloadrpg-e17b5b89766fa83993f838e8df9cecd9cf9e86ab.tar.gz
rpg-e17b5b89766fa83993f838e8df9cecd9cf9e86ab.tar.bz2
Merge pull request #618 from splitbrain/cache_and_cachetime
Fix longstanding issue with cache class & cachetime setting
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/cache_use.test.php54
1 files changed, 49 insertions, 5 deletions
diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php
index f5349df13..c54a472a3 100644
--- a/_test/tests/inc/cache_use.test.php
+++ b/_test/tests/inc/cache_use.test.php
@@ -10,18 +10,18 @@ class cache_use_test extends DokuWikiTest {
private $cache;
function setUp() {
- global $ID;
+ global $ID, $conf;
parent::setUp();
$ID = 'cached';
$file = wikiFN($ID);
+ $conf['cachetime'] = 0; // ensure the value is not -1, which disables caching
saveWikiText($ID, 'Content', 'Created');
// set the modification time a second in the past in order to ensure that the cache is newer than the page
touch($file, time()-1);
- # Create cache. Note that the metadata cache is used as the xhtml cache triggers metadata rendering
- $this->cache = new cache_renderer($ID, $file, 'metadata');
+ $this->cache = new cache_renderer($ID, $file, 'xhtml');
$this->cache->storeCache('Test');
}
@@ -29,8 +29,52 @@ class cache_use_test extends DokuWikiTest {
$this->assertTrue($this->cache->useCache());
}
-
+ /**
+ * In all the following tests the cache should not be usable
+ * as such, they are meaningless if test_use didn't pass.
+ *
+ * @depends test_use
+ */
function test_purge() {
- $this->assertFalse($this->cache->useCache(array('purge' => true)));
+ /* @var Input $INPUT */
+ global $INPUT;
+ $INPUT->set('purge',1);
+
+ $this->assertFalse($this->cache->useCache());
+ $this->assertNotEmpty($this->cache->depends['purge']);
+ }
+
+ /**
+ * @depends test_use
+ */
+ function test_filedependency() {
+ // give the dependent src file the same mtime as the cache
+ touch($this->cache->file, filemtime($this->cache->cache));
+ $this->assertFalse($this->cache->useCache());
+ }
+
+ /**
+ * @depends test_use
+ */
+ function test_age() {
+ // need to age both our source file & the cache
+ $age = 10;
+ $time = time() - $age - 1; // older than age
+
+ touch($this->cache->file, $time - 1);
+ touch($this->cache->cache, $time);
+
+ $this->assertFalse($this->cache->useCache(array('age' => $age)));
+ }
+
+ /**
+ * @depends test_use
+ */
+ function test_confnocaching() {
+ global $conf;
+ $conf['cachetime'] = -1; // disables renderer caching
+
+ $this->assertFalse($this->cache->useCache());
+ $this->assertNotEmpty($this->cache->_nocache);
}
} \ No newline at end of file