summaryrefslogtreecommitdiff
path: root/_test/tests/inc/cache_stalecheck.test.php
blob: 93f44a55cc0325875a82242cc44fa1c2ab1432a7 (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
<?php

class cache_stalecheck_test extends DokuWikiTest {
	function test_staleness() {
		global $ID;

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

		# Prepare test page
		saveWikiText($ID, 'Fresh', 'Created');

		# Create stale cache
		$cache = new cache_renderer($ID, $file, 'xhtml');
		$cache->storeCache('Stale');
		$stale = $cache->retrieveCache();

		# Prepare stale cache for testing
		$time = filemtime($file);
		touch($cache->cache, $time);

		# Make the test
		$fresh = p_cached_output($file, 'xhtml', $ID);
		$this->assertNotEquals($fresh, $stale, 'Stale cache failed to expire');
	}
}