mirror of
https://github.com/mrclay/minify.git
synced 2025-08-30 09:09:54 +02:00
Cache/File.php : + file locking option (still need cache stress test)
This commit is contained in:
@@ -5,8 +5,8 @@ require_once 'Minify/Cache/File.php';
|
||||
|
||||
function test_Minify_Cache_File()
|
||||
{
|
||||
$data = str_repeat(md5('testing'), 160);
|
||||
$id = 'Minify_test_cache';
|
||||
$data = str_repeat(md5(time()), 160);
|
||||
$id = 'Minify_test_cache_noLock';
|
||||
$prefix = 'Minify_Cache_File : ';
|
||||
|
||||
$cache = new Minify_Cache_File();
|
||||
@@ -24,7 +24,27 @@ function test_Minify_Cache_File()
|
||||
|
||||
assertTrue($data === $displayed, $prefix . 'display');
|
||||
|
||||
assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
|
||||
assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
|
||||
|
||||
// test with locks
|
||||
|
||||
$id = 'Minify_test_cache_withLock';
|
||||
$cache = new Minify_Cache_File('', true);
|
||||
|
||||
assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock');
|
||||
|
||||
assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
|
||||
|
||||
assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
|
||||
|
||||
ob_start();
|
||||
$cache->display($id);
|
||||
$displayed = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
assertTrue($data === $displayed, $prefix . 'display w/ lock');
|
||||
|
||||
assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock');
|
||||
}
|
||||
|
||||
test_Minify_Cache_File();
|
Reference in New Issue
Block a user