xref: /dokuwiki/_test/tests/inc/cache_stalecheck.test.php (revision b8faabb62f51d6a99c5a49b03d969db5f53d594a)
1<?php
2
3class cache_stalecheck_test extends DokuWikiTest {
4	function test_staleness() {
5		global $ID;
6
7		$ID = 'stale';
8		$file = wikiFN($ID);
9
10		# Prepare test page
11		saveWikiText($ID, 'Fresh', 'Created');
12
13		# Create stale cache
14		$cache = new cache_renderer($ID, $file, 'xhtml');
15		$cache->storeCache('Stale');
16		$stale = $cache->retrieveCache();
17
18		# Prepare stale cache for testing
19		$time = filemtime($file);
20		touch($cache->cache, $time);
21
22		# Make the test
23		$fresh = p_cached_output($file, 'xhtml', $ID);
24		$this->assertNotEquals($fresh, $stale, 'Stale cache failed to expire');
25	}
26}
27
28