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