summaryrefslogtreecommitdiff
path: root/_test/tests/inc/cache_use.test.php
blob: f5349df1396bbe418065c0babe860901c91902d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

/**
 * Class cache_use_test
 *
 * Tests if caching can actually be used
 */
class cache_use_test extends DokuWikiTest {
    /** @var cache_renderer $cache */
    private $cache;

    function setUp() {
        global $ID;
        parent::setUp();

        $ID = 'cached';
        $file = wikiFN($ID);

        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->storeCache('Test');
    }

    function test_use() {
        $this->assertTrue($this->cache->useCache());
    }


    function test_purge() {
        $this->assertFalse($this->cache->useCache(array('purge' => true)));
    }
}