xref: /dokuwiki/_test/tests/inc/cache_use.test.php (revision 2549a25a3e31bbf5b00c04831062e05640d7b8c0)
1<?php
2
3/**
4 * Class cache_use_test
5 *
6 * Tests if caching can actually be used
7 */
8class cache_use_test extends DokuWikiTest {
9    /** @var cache_renderer $cache */
10    private $cache;
11
12    function setUp() {
13        global $ID;
14        parent::setUp();
15
16        $ID = 'cached';
17        $file = wikiFN($ID);
18
19        saveWikiText($ID, 'Content', 'Created');
20        // set the modification time a second in the past in order to ensure that the cache is newer than the page
21        touch($file, time()-1);
22
23        # Create cache. Note that the metadata cache is used as the xhtml cache triggers metadata rendering
24        $this->cache = new cache_renderer($ID, $file, 'metadata');
25        $this->cache->storeCache('Test');
26    }
27
28    function test_use() {
29        $this->assertTrue($this->cache->useCache());
30    }
31
32
33    function test_purge() {
34        $this->assertFalse($this->cache->useCache(array('purge' => true)));
35    }
36}