TimeTrex Community Edition v16.2.0

This commit is contained in:
2022-12-13 07:10:06 +01:00
commit 472f000c1b
6810 changed files with 2636142 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
--TEST--
Cache_Lite::Cache_Lite_File (classical)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_file_base.inc';
$master = tmpDir() . '/' . 'foobar.masterfile';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'masterFile' => $master
);
$f = fopen($master, 'w');
fwrite($f, 'foobar');
fclose($f);
sleep(1);
$Cache_Lite = new Cache_Lite_File($options);
multipleCallCache('string');
multipleCallCache3_1('string');
echo "==> We touch masterFile\n";
touch($master);
sleep(1);
clearstatcache();
echo "\nDone !\n\n";
$Cache_Lite = new Cache_Lite_File($options);
sleep(1);
multipleCallCache3_2('string');
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> #6 call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #7 call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We touch masterFile
Done !
==> #8 call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,102 @@
--TEST--
Cache_Lite::Cache_Lite_Function (classical)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_function_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60
);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_to_bench', 23, 66);
echo($data);
$data = $cache->call('function_to_bench', 23, 66);
echo($data);
$cache->call('function_to_bench', 23, 66);
$object = new bench();
$object->test = 666;
$data = $cache->call('object->method_to_bench', 23, 66);
echo($data);
$data = $cache->call('object->method_to_bench', 23, 66);
echo($data);
$cache->call('object->method_to_bench', 23, 66);
$data = $cache->call('bench::static_method_to_bench', 23, 66);
echo($data);
$data = $cache->call('bench::static_method_to_bench', 23, 66);
echo($data);
$cache->call('bench::static_method_to_bench', 23, 66);
$object = new test($options);
$cache->clean();
function function_to_bench($arg1, $arg2)
{
echo "This is the output of the function function_to_bench($arg1, $arg2) !\n";
return "This is the result of the function function_to_bench($arg1, $arg2) !\n";
}
class bench
{
var $test;
function method_to_bench($arg1, $arg2)
{
echo "\$obj->test = $this->test and this is the output of the method \$obj->method_to_bench($arg1, $arg2) !\n";
return "\$obj->test = $this->test and this is the result of the method \$obj->method_to_bench($arg1, $arg2) !\n";
}
static function static_method_to_bench($arg1, $arg2) {
echo "This is the output of the function static_method_to_bench($arg1, $arg2) !\n";
return "This is the result of the function static_method_to_bench($arg1, $arg2) !\n";
}
}
class test
{
function __construct($options) {
$this->foo = 'bar';
$cache = new Cache_Lite_Function($options);
echo($cache->call(array($this, 'method_to_bench'), 'foo', 'bar'));
}
function method_to_bench($arg1, $arg2)
{
echo "output : *** $arg1 *** $arg2 *** " . $this->foo . " ***\n";
return "result : *** $arg1 *** $arg2 *** " . $this->foo . " ***\n";
}
}
?>
--GET--
--POST--
--EXPECT--
This is the output of the function function_to_bench(23, 66) !
This is the result of the function function_to_bench(23, 66) !
This is the output of the function function_to_bench(23, 66) !
This is the result of the function function_to_bench(23, 66) !
This is the output of the function function_to_bench(23, 66) !
$obj->test = 666 and this is the output of the method $obj->method_to_bench(23, 66) !
$obj->test = 666 and this is the result of the method $obj->method_to_bench(23, 66) !
$obj->test = 666 and this is the output of the method $obj->method_to_bench(23, 66) !
$obj->test = 666 and this is the result of the method $obj->method_to_bench(23, 66) !
$obj->test = 666 and this is the output of the method $obj->method_to_bench(23, 66) !
This is the output of the function static_method_to_bench(23, 66) !
This is the result of the function static_method_to_bench(23, 66) !
This is the output of the function static_method_to_bench(23, 66) !
This is the result of the function static_method_to_bench(23, 66) !
This is the output of the function static_method_to_bench(23, 66) !
output : *** foo *** bar *** bar ***
result : *** foo *** bar *** bar ***

View File

@@ -0,0 +1,130 @@
--TEST--
Cache_Lite::Cache_Lite_Function (dont cache)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_function_base.inc';
// Classical
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'debugCacheLiteFunction' => true
);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_test', 23, 66);
echo($data);
$data = $cache->call('function_test', 23, 66);
echo($data);
$cache->clean();
// Don't Cache if output contains NOCACHE
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'debugCacheLiteFunction' => true,
'dontCacheWhenTheOutputContainsNOCACHE' => true
);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_test2', 23, 66);
echo($data);
$data = $cache->call('function_test2', 23, 66);
echo($data);
$data = $cache->call('function_test2', 0, 66);
echo($data);
$data = $cache->call('function_test2', 0, 66);
echo($data);
$cache->clean();
// Don't cache if result if false
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'debugCacheLiteFunction' => true,
'dontCacheWhenTheResultIsFalse' => true
);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_test', 23, 66);
echo($data);
$data = $cache->call('function_test', 23, 66);
echo($data);
$data = $cache->call('function_test', 0, 66);
echo($data);
$data = $cache->call('function_test', 0, 66);
echo($data);
$cache->clean();
// Don't cache if result if null
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'debugCacheLiteFunction' => true,
'dontCacheWhenTheResultIsNull' => true
);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_test', 23, 66);
echo($data);
$data = $cache->call('function_test', 23, 66);
echo($data);
$data = $cache->call('function_test', 1, 66);
echo($data);
$data = $cache->call('function_test', 1, 66);
echo($data);
$cache->clean();
function function_test($arg1, $arg2)
{
echo "This is the output of the function function_test($arg1, $arg2) !\n";
if ($arg1==0) {
return false;
}
if ($arg1==1) {
return null;
}
return '';
}
function function_test2($arg1, $arg2)
{
if ($arg1==0) {
echo "NOCACHE";
}
return "This is the result of the function function_test2($arg1, $arg2) !\n";
}
?>
--GET--
--POST--
--EXPECT--
Cache missed !
This is the output of the function function_test(23, 66) !
Cache hit !
This is the output of the function function_test(23, 66) !
Cache missed !
This is the result of the function function_test2(23, 66) !
Cache hit !
This is the result of the function function_test2(23, 66) !
Cache missed !
This is the result of the function function_test2(0, 66) !
Cache missed !
This is the result of the function function_test2(0, 66) !
Cache missed !
This is the output of the function function_test(23, 66) !
Cache hit !
This is the output of the function function_test(23, 66) !
Cache missed !
This is the output of the function function_test(0, 66) !
Cache missed !
This is the output of the function function_test(0, 66) !
Cache missed !
This is the output of the function function_test(23, 66) !
Cache hit !
This is the output of the function function_test(23, 66) !
Cache missed !
This is the output of the function function_test(1, 66) !
Cache missed !
This is the output of the function function_test(1, 66) !

View File

@@ -0,0 +1,50 @@
--TEST--
Cache_Lite::Cache_Lite_Function (drop() method)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_function_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60
);
$foo = 10;
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_to_bench', 23, 66);
echo($data."\n");
$data = $cache->call('function_to_bench', 23, 66);
echo($data."\n");
$cache->drop('function_to_bench', 23, 66);
$data = $cache->call('function_to_bench', 23, 66);
echo($data."\n");
$data = $cache->call('function_to_bench', 23, 66);
echo($data."\n");
$cache->clean();
function function_to_bench($arg1, $arg2)
{
global $foo;
$foo = $foo + 1;
echo "hello !\n";
return($foo + $arg1 + $arg2);
}
?>
--GET--
--POST--
--EXPECT--
hello !
100
hello !
100
hello !
101
hello !
101

View File

@@ -0,0 +1,53 @@
--TEST--
Cache_Lite::Cache_Lite_Output (classical)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_output_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60
);
$Cache_Lite_Output = new Cache_Lite_Output($options);
multipleCallCache2();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache Missed !
Done !
==> Second call (cache should be hit)
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache Hit !
Done !
==> Third call (cache should be hit)
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache Hit !
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache Missed !
Done !
==> #5 Call with another id (cache should be missed)
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache Missed !
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,57 @@
--TEST--
Cache_Lite::Cache_Lite (automaticCleaning)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 2,
'automaticCleaningFactor' => 1
);
$Cache_Lite = new Cache_Lite($options);
callCache('31415926');
echo("\n");
callCache('31415926');
echo("\n");
callCache('31415926bis');
echo("\n");
callCache('31415926bis');
echo("\n");
sleep(4);
callCache('31415926'); // '31415926bis' will be cleaned
echo "\n";
$dh = opendir(tmpDir());
while ($file = readdir($dh)) {
if (($file != '.') && ($file != '..')) {
if (substr($file, 0, 6)=='cache_') {
echo "$file\n";
}
}
}
$Cache_Lite->remove('31415926');
$Cache_Lite->remove('31415926bis');
?>
--GET--
--POST--
--EXPECT--
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277

View File

@@ -0,0 +1,53 @@
--TEST--
Cache_Lite::Cache_Lite (classical)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,64 @@
--TEST--
Cache_Lite::Cache_Lite (error)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '31451992gjhgjh'. '/', # I hope there will be no directory with that silly name
'lifeTime' => 60
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Error when saving cache !
Done !
==> Second call (cache should be hit)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Error when saving cache !
Done !
==> Third call (cache should be hit)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Error when saving cache !
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Error when saving cache !
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Error when saving cache !
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,66 @@
--TEST--
Cache_Lite::Cache_Lite (error2)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$tmpdir = tmpDir() . '31451992gjhgjh'. '/'; # I hope there will be no directory with that silly name
$options = array(
'cacheDir' => $tmpdir,
'lifeTime' => 60,
'errorHandlingAPIBreak' => true
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> Second call (cache should be hit)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> Third call (cache should be hit)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_07eeaa82211be6c3335603523dbea0a3 (#-1)
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,53 @@
--TEST--
Cache_Lite::Cache_Lite (eternal)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => null
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,57 @@
--TEST--
Cache_Lite::Cache_Lite (fatest, no control, no lock)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'fileLocking' => false,
'writeControl' => false,
'readControl' => false,
'fileNameProtection' => false
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,98 @@
--TEST--
Cache_Lite::Cache_Lite (hashed level 2)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'hashedDirectoryLevel' => 2
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
// Hack to clean cache directory structure
/**
* rm() -- Vigorously erase files and directories.
*
* @param $fileglob mixed If string, must be a file name (foo.txt), glob pattern (*.txt), or directory name.
* If array, must be an array of file names, glob patterns, or directories.
*/
function rm($fileglob)
{
if (is_string($fileglob)) {
if (is_file($fileglob)) {
return unlink($fileglob);
} else if (is_dir($fileglob)) {
$ok = rm("$fileglob/*");
if (! $ok) {
return false;
}
return rmdir($fileglob);
} else {
$matching = glob($fileglob);
if ($matching === false) {
trigger_error(sprintf('No files match supplied glob %s', $fileglob), E_USER_WARNING);
return false;
}
$rcs = array_map('rm', $matching);
if (in_array(false, $rcs)) {
return false;
}
}
} else if (is_array($fileglob)) {
$rcs = array_map('rm', $fileglob);
if (in_array(false, $rcs)) {
return false;
}
} else {
trigger_error('Param #1 must be filename or glob pattern, or array of filenames or glob patterns', E_USER_ERROR);
return false;
}
return true;
}
rm(tmpDir() . '/cache_*');
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,42 @@
--TEST--
Cache_Lite::Cache_Lite (lifetime)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 2
);
$Cache_Lite = new Cache_Lite($options);
callCache('31415926');
echo("\n");
callCache('31415926');
echo("\n");
sleep(4);
callCache('31415926');
echo("\n");
sleep(4);
$Cache_Lite->extendLife();
callCache('31415926');
echo("\n");
$Cache_Lite->remove('31415926');
?>
--GET--
--POST--
--EXPECT--
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789

View File

@@ -0,0 +1,54 @@
--TEST--
Cache_Lite::Cache_Lite (memory cache on)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'memoryCaching' => false
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,54 @@
--TEST--
Cache_Lite::Cache_Lite (automatic serialization on)
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'automaticSerialization' => true
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache('array');
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
a:4:{i:0;a:2:{i:0;s:3:"foo";i:1;s:3:"bar";}i:1;i:1;i:2;s:3:"foo";i:3;s:3:"bar";}
Done !
==> Second call (cache should be hit)
Cache Hit !
a:4:{i:0;a:2:{i:0;s:3:"foo";i:1;s:3:"bar";}i:1;i:1;i:2;s:3:"foo";i:3;s:3:"bar";}
Done !
==> Third call (cache should be hit)
Cache Hit !
a:4:{i:0;a:2:{i:0;s:3:"foo";i:1;s:3:"bar";}i:1;i:1;i:2;s:3:"foo";i:3;s:3:"bar";}
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
a:4:{i:0;a:2:{i:0;s:3:"foo";i:1;s:3:"bar";}i:1;i:1;i:2;s:3:"foo";i:3;s:3:"bar";}
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
a:4:{i:0;a:2:{i:0;s:3:"foo";i:1;s:3:"bar";}i:1;i:1;i:2;s:3:"foo";i:3;s:3:"bar";}
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,30 @@
<?php
/**
* Test for CACHE_LITE_ERROR_DIE
*
* @package Cache_Lite
* @category Caching
* @version $Id$
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/tmpdir.inc';
class ErrorDieTest extends PHPUnit_Framework_TestCase
{
public function testErrorDie()
{
exec('/usr/bin/env php ' . __DIR__ . DIRECTORY_SEPARATOR . 'errordie.php', $out);
$message = join(PHP_EOL, $out);
$message = str_replace(tmpDir(), '<cachedir>/', $message); // Remove system specific cache dir
$expected = join(PHP_EOL, array(
'==> First call (cache should be missed)',
'Cache Missed !',
'0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277',
));
$this->assertEquals($message, $expected);
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* Test for Cache_Lite_NestedOutput
*
* @package Cache_Lite
* @category Caching
* @version $Id$
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/../Cache/Lite/NestedOutput.php';
class NestedOutputTest extends PHPUnit_Framework_TestCase
{
/**
* "Test" used for documenting the nested output buffering feature of php
*/
public function testPhpObNesting()
{
$outsideText = "This is the outside";
$insideText = "This is the inside";
ob_start();
echo $outsideText;
ob_start();
echo $insideText;
$innerContents = ob_get_contents();
ob_end_clean();
$outerContents = ob_get_contents();
ob_end_clean();
$this->assertEquals( $insideText, $innerContents );
$this->assertEquals( $outsideText, $outerContents );
}
/**
* Test for Cache_Lite_NestedOutput
*/
public function testCacheLiteOutputNesting()
{
$outsideText = "This is the outside";
$insideText = "This is the inside";
$options = array(
'caching' => true,
'cacheDir' => '/tmp/',
'lifeTime' => 10
);
$cache = new Cache_Lite_NestedOutput($options);
$this->assertFalse($cache->start('foo', 'a'));
echo $outsideText;
$this->assertFalse($cache->start('bar', 'b'));
echo $insideText;
$inside = $cache->end();
$outside = $cache->end();
$this->assertEquals($outsideText, $outside, 'Validate outside');
$this->assertEquals($insideText, $inside, 'Validate inside');
$cache = new Cache_Lite_NestedOutput($options);
$this->assertEquals($outsideText, $cache->start('foo', 'a'), 'Validate outside');
$this->assertEquals($insideText, $cache->start('bar', 'b'), 'Validate inside');
}
}

27
vendor/pear/cache_lite/tests/bench.php vendored Normal file
View File

@@ -0,0 +1,27 @@
<?php
// Bench script of Cache_Lite
// $Id$
require_once __DIR__ . '/../Cache/Lite.php';
$options = array(
'caching' => true,
'cacheDir' => '/tmp/',
'lifeTime' => 10
);
$Cache_Lite = new Cache_Lite($options);
if ($data = $Cache_Lite->get('123')) {
echo($data);
} else {
$data = '';
for($i=0;$i<1000;$i++) {
$data .= '0123456789';
}
echo($data);
$Cache_Lite->save($data);
}
?>

24
vendor/pear/cache_lite/tests/bench2.php vendored Normal file
View File

@@ -0,0 +1,24 @@
<?php
// Bench script of Cache_Lite_Output
// $Id$
require_once __DIR__ . '/../Cache/Lite/Output.php';
$options = array(
'caching' => true,
'cacheDir' => '/tmp/',
'lifeTime' => 10
);
$cache = new Cache_Lite_Output($options);
if (!($cache->start('123'))) {
// Cache missed...
for($i=0;$i<1000;$i++) { // Making of the page...
echo('0123456789');
}
$cache->end();
}
?>

60
vendor/pear/cache_lite/tests/bench3.php vendored Normal file
View File

@@ -0,0 +1,60 @@
<?php
// Bench script of Cache_Lite_Function
// $Id$
require_once __DIR__ . '/../Cache/Lite/Function.php';
$options = array(
'caching' => true,
'cacheDir' => '/tmp/',
'lifeTime' => 10
);
$cache = new Cache_Lite_Function($options);
$data = $cache->call('function_to_bench', 23, 66);
echo($data);
$object = new bench();
$object->test = 666;
$data = $cache->call('object->method_to_bench', 23, 66);
echo($data);
$data = $cache->call('bench::static_method_to_bench', 23, 66);
echo($data);
function function_to_bench($arg1, $arg2)
{
for($i=0;$i<10000;$i++) {
$tmp = md5(md5(md5('Loosing time...')));
}
echo "This is the output of the function function_to_bench($arg1, $arg2) !<br>";
return "This is the result of the function function_to_bench($arg1, $arg2) !<br>";
}
class bench
{
var $test;
function method_to_bench($arg1, $arg2)
{
for($i=0;$i<10000;$i++) {
$tmp = md5(md5(md5('Loosing time...')));
}
echo "\$obj->test = $this->test and this is the output of the method \$obj->method_to_bench($arg1, $arg2) !<br>";
return "\$obj->test = $this->test and this is the result of the method \$obj->method_to_bench($arg1, $arg2) !<br>";
}
function static_method_to_bench($arg1, $arg2)
{
for($i=0;$i<10000;$i++) {
$tmp = md5(md5(md5('Loosing time...')));
}
echo "This is the output of the function static_method_to_bench($arg1, $arg2) !<br>";
return "This is the result of the function static_method_to_bench($arg1, $arg2) !<br>";
}
}
?>

View File

@@ -0,0 +1,7 @@
<?php
if (version_compare(PHP_VERSION, '5.4', '>=')) {
error_reporting(E_ALL ^ E_STRICT);
} else if (version_compare(PHP_VERSION, '5.3', '>=')) {
error_reporting(E_ALL & ~E_STRICT);
}

View File

@@ -0,0 +1,3 @@
<?php
require_once('Cache/Lite.php');
?>

View File

@@ -0,0 +1,3 @@
<?php
require_once('Cache/Lite/File.php');
?>

View File

@@ -0,0 +1,3 @@
<?php
require_once('Cache/Lite/Function.php');
?>

View File

@@ -0,0 +1,3 @@
<?php
require_once 'Cache/Lite/Output.php';
?>

View File

@@ -0,0 +1,151 @@
<?php
function callCache($id, $type = 'string') {
global $Cache_Lite;
if ($data = $Cache_Lite->get($id)) {
echo("Cache Hit !\n");
if ($type=='string') {
echo($data);
}
if ($type=='array') {
echo(serialize($data));
}
} else {
echo("Cache Missed !\n");
if ($type=='string') {
$data = '';
for($i=0;$i<10;$i++) {
$data .= '0123456789';
}
echo($data);
}
if ($type=='array') {
$data = array(array('foo', 'bar'), 1, 'foo', 'bar');
echo(serialize($data));
}
$res = $Cache_Lite->save($data);
if (is_object($res)) {
$message = $res->getMessage();
$message = str_replace(tmpDir(), '<cachedir>/', $message); // Remove system specific cache dir
echo "\nPEAR_ERROR : " . $message . " (#" . $res->getCode() . ")\n";
} else {
if (!($res)) {
echo "\nError when saving cache !\n";
}
}
}
}
function multipleCallCache($type = 'string') {
global $Cache_Lite;
echo "==> First call (cache should be missed)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
echo "==> Second call (cache should be hit)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
echo "==> Third call (cache should be hit)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
echo "==> We remove cache\n";
$Cache_Lite->remove('31415926');
echo "Done !\n\n";
echo "==> Fourth call (cache should be missed)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
echo "==> #5 Call with another id (cache should be missed)\n";
callCache('3141592653', $type);
echo "\nDone !\n\n";
echo "==> We remove cache\n";
$Cache_Lite->remove('31415926');
$Cache_Lite->remove('3141592653');
echo "Done !\n";
}
function callCache2($id, $type = 'string') {
global $Cache_Lite_Output;
if (!($Cache_Lite_Output->start($id))) {
if ($type=='string') {
$data = '';
for($i=0;$i<10;$i++) {
$data .= '0123456789';
}
echo($data);
}
if ($type=='array') {
$data = array(array('foo', 'bar'), 1, 'foo', 'bar');
echo(serialize($data));
}
$Cache_Lite_Output->end();
echo("Cache Missed !\n");
} else {
echo("Cache Hit !\n");
}
}
function multipleCallCache2($type = 'string') {
global $Cache_Lite_Output;
echo "==> First call (cache should be missed)\n";
callCache2('31415926', $type);
echo "\nDone !\n\n";
echo "==> Second call (cache should be hit)\n";
callCache2('31415926', $type);
echo "\nDone !\n\n";
echo "==> Third call (cache should be hit)\n";
callCache2('31415926', $type);
echo "\nDone !\n\n";
echo "==> We remove cache\n";
$Cache_Lite_Output->remove('31415926');
echo "Done !\n\n";
echo "==> Fourth call (cache should be missed)\n";
callCache2('31415926', $type);
echo "\nDone !\n\n";
echo "==> #5 Call with another id (cache should be missed)\n";
callCache2('3141592653', $type);
echo "\nDone !\n\n";
echo "==> We remove cache\n";
$Cache_Lite_Output->remove('31415926');
$Cache_Lite_Output->remove('3141592653');
echo "Done !\n";
}
function multipleCallCache3_1($type = 'string') {
global $Cache_Lite;
echo "==> #6 call (cache should be missed)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
echo "==> #7 call (cache should be hit)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
}
function multipleCallCache3_2($type = 'string') {
global $Cache_Lite;
echo "==> #8 call (cache should be missed)\n";
callCache('31415926', $type);
echo "\nDone !\n\n";
echo "==> We remove cache\n";
$Cache_Lite->remove('31415926');
echo "Done !\n";
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Executed by ErrorDieTest
*
* @package Cache_Lite
* @category Caching
* @version $Id$
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
error_reporting(0);
$options = array(
'cacheDir' => tmpDir() . '31451992gjhgjh'. '/', # I hope there will be no directory with that silly name
'lifeTime' => 60,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();

View File

@@ -0,0 +1,33 @@
--TEST--
pearbug13693
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/../Cache/Lite.php';
// Create temp dir
$dir = dirname( __FILE__ ) . '/' . uniqid();
mkdir($dir);
$options = array(
'cacheDir' => $dir,
'lifeTime' => 60,
);
$id = '#13693';
$cache = new Cache_Lite($options);
$cache->save('stuff', $id);
// Must be true
echo $cache->remove($id) === true ? "OK\n" : "ERROR\n";
// Will return a PEAR Error
echo $cache->remove($id) instanceof PEAR_Error ? "OK\n" : "ERROR\n";
// Will return true
echo $cache->remove($id, 'default', true) === true ? "OK\n" : "ERROR\n";
// Remove temp dir
rmdir($dir);
--EXPECT--
OK
OK
OK

View File

@@ -0,0 +1,17 @@
<?php
/**
* Process for test pearbug18192
*
* @see https://pear.php.net/bugs/bug.php?id=18192
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/../Cache/Lite.php';
$c = new Cache_Lite(array('cacheDir' => '.', 'lifeTime' => 60));
$id = '#18192';
for ($i = 0; $i < 100000; $i++) {
$str = uniqid('some-string', true);
if (!$c->save($str, $id)) fputs(STDERR, "Error saving.\n");
if ($c->get($id) !== $str) fputs(STDERR, "Wrong data.\n");
}

View File

@@ -0,0 +1,25 @@
--TEST--
Cache_Lite::Cache_Lite (PEAR bug #18328)
--INI--
track_errors=Off
--FILE--
<?php
/**
* Process for test pearbug18328
*
* @see https://pear.php.net/bugs/bug.php?id=18328
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/../Cache/Lite.php';
$c = new Cache_Lite(array('cacheDir' => '.', 'lifeTime' => 60,));
var_dump($c->_cacheDir === '.');
$c = new Cache_Lite(array('lifeTime' => 60));
var_dump($c->_cacheDir === (function_exists('sys_get_temp_dir') ? sys_get_temp_dir() . DIRECTORY_SEPARATOR : '/tmp/'));
--GET--
--POST--
--EXPECT--
bool(true)
bool(true)

View File

@@ -0,0 +1,133 @@
--TEST--
Cache_Lite::Cache_Lite (PEAR bug #19422)
--INI--
track_errors=Off
--FILE--
<?php
/**
* Test for Pear Bug #19422
*
* @see https://pear.php.net/bugs/bug.php?id=19422
* @see https://bugs.php.net/bug.php?id=30936
*
* @package Cache_Lite
* @category Caching
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/../Cache/Lite.php';
define('FsStreamWrapper_CACHE_DIR', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'cachelite-streamwrapper' . DIRECTORY_SEPARATOR);
class FsStreamWrapper
{
const SCHEME = 'public';
private $fp;
public function __construct()
{
if (!is_dir(FsStreamWrapper_CACHE_DIR)) mkdir(FsStreamWrapper_CACHE_DIR);
}
public function url_stat($path, $flags)
{
$localpath = $this->scheme2file($path);
if (!is_file($localpath)) return 0;
return stat($localpath);
}
private function scheme2file($path)
{
return str_replace(self::SCHEME . '://', FsStreamWrapper_CACHE_DIR, $path);
}
public function stream_open($path, $mode, $options, &$opath)
{
$this->fp = fopen($this->scheme2file($path), $mode);
return true;
}
public function stream_write($data)
{
return fwrite($this->fp, $data);
}
public function stream_close()
{
return fclose($this->fp);
}
public function stream_lock($operation)
{
return flock($this->fp, $operation);
}
public function unlink($path)
{
return unlink($this->scheme2file($path));
}
public function stream_read($count)
{
return fread($this->fp, $count);
}
public function stream_eof()
{
return feof($this->fp);
}
public function stream_seek($offset, $whence)
{
return !fseek($this->fp, $offset, $whence);
}
public function stream_flush()
{
return fflush($this->fp);
}
public function stream_tell()
{
return ftell($this->fp);
}
public function rename($from_uri, $to_uri)
{
return rename($this->scheme2file($from_uri), $this->scheme2file($to_uri));
}
}
$xml = array();
$cacheOpt = array();
$cacheOpt['cacheDir'] = 'public://';
$cacheOpt['cache_time'] = 3600;
$Cache_Lite = new Cache_Lite($cacheOpt);
$Cache_Lite->setToDebug();
stream_wrapper_register(FsStreamWrapper::SCHEME, 'FsStreamWrapper');
$fp = fopen('/dev/urandom', 'r');
$data = fread($fp, 32 * 1024);
fclose($fp);
$Cache_Lite->save($data, 'largechache');
$verify = $Cache_Lite->get('largechache');
var_dump(strlen($data) === strlen($verify));
var_dump($data === $verify);
?>
--CLEAN--
<?php
define('FsStreamWrapper_CACHE_DIR', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'cachelite-streamwrapper' . DIRECTORY_SEPARATOR);
foreach(glob(FsStreamWrapper_CACHE_DIR . 'cache*') as $file) {
unlink($file);
}
@rmdir(FsStreamWrapper_CACHE_DIR);
?>
--GET--
--POST--
--EXPECT--
bool(true)
bool(true)

View File

@@ -0,0 +1,38 @@
--TEST--
Cache_Lite::Cache_Lite (PEAR bug #19711)
--INI--
track_errors=Off
--FILE--
<?php
/**
* Test for Pear Bug #19711
*
* @see https://pear.php.net/bugs/bug.php?id=19711
*
* @package Cache_Lite
* @category Caching
* @author Markus Tacker <tacker@php.net>
*/
require_once __DIR__ . '/../Cache/Lite.php';
require_once __DIR__ . '/tmpdir.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'automaticSerialization' => true
);
$Cache_Lite = new Cache_Lite($options);
$data = array('apples', 'oranges');
$Cache_Lite->save($data, 'array_cached');
$fetched_data = $Cache_Lite->get('array_cached');
var_dump($data === $fetched_data);
?>
--GET--
--POST--
--EXPECT--
bool(true)

View File

@@ -0,0 +1,54 @@
--TEST--
pearbug513
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'automaticSerialization' => true
);
$Cache_Lite = new Cache_Lite($options);
multipleCallCache();
?>
--GET--
--POST--
--EXPECT--
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Second call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> Third call (cache should be hit)
Cache Hit !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Done !
==> We remove cache
Done !

View File

@@ -0,0 +1,41 @@
--TEST--
pearbug7618
--INI--
track_errors=Off
--FILE--
<?php
require_once __DIR__ . '/callcache.inc';
require_once __DIR__ . '/tmpdir.inc';
require_once __DIR__ . '/cache_lite_base.inc';
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
'automaticSerialization' => true
);
$cache = new Cache_Lite($options);
$cacheid = "testid";
$tmpar = array();
for ($i=0; $i<2; $i++) {
$ar[] = 'foo';
if ($cache->save($ar,$cacheid)) {
echo "TRUE\n";
} else {
echo "FALSE\n";
}
if ($data = $cache->get($cacheid)) {
echo($data[0] . "\n");
} else {
echo "FALSE\n";
}
}
$cache->remove('testid');
?>
--EXPECT--
TRUE
foo
TRUE
foo

17
vendor/pear/cache_lite/tests/readme vendored Normal file
View File

@@ -0,0 +1,17 @@
Cache_Lite is perfs oriented. So before commiting, please bench your patch !
To bench Cache_Lite, I use the tool 'ab' (distributed with apache).
(for example)
/usr/sbin/ab -c 10 -n 1000 http://127.0.0.1/ [...] /Cache_Lite/tests/bench.php
In the output of 'ab', most important things are :
- Failed requests: (must be 0 ! If not, don't commit !)
- Requests per second: XXX [#/sec] (mean)
For testing if the cache is ok or not, you can use the script 'test.php', it
will write if the cache has been hit or missed...
Fabien (fab@php.net)

40
vendor/pear/cache_lite/tests/tmpdir.inc vendored Normal file
View File

@@ -0,0 +1,40 @@
<?php
/**
* @author Markus Tacker <tacker@php.net>
*/
/**
* @const String Temp dir for cache files
*/
define('TEST_TMP_DIR_DEFAULT', __DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR);
/**
* Returns a directory to use for temp files.
*
* The dir is now hard coded to a local dir to make the tests runnable
* under jenkins where there is no write access to the system temp dir.
*
* The reason for this solution is, that with phpt files a given
* --bootstrap file is ignored.
*
* @author Markus Tacker <tacker@php.net>*
* @static
* @access public
* @return string The system tmp directory
*/
function tmpDir()
{
if (defined('TEST_TMP_DIR')) return TEST_TMP_DIR;
return TEST_TMP_DIR_DEFAULT;
}
// Create directory if not exists
if (!is_dir(tmpDir())) mkdir(tmpDir());
// Clean up afterwards
register_shutdown_function(function()
{
exec('rm -rf ' . tmpDir());
});