Created
February 11, 2010 13:35
-
-
Save cs278/301506 to your computer and use it in GitHub Desktop.
phpBB Cache Tester
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @package phpBB3 | |
* @version $Id$ | |
* @copyright (c) 2009 phpBB Group | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | |
* | |
*/ | |
/** | |
* Test the phpBB cache | |
*/ | |
/** | |
* @ignore | |
*/ | |
define('IN_PHPBB', true); | |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; | |
$phpEx = substr(strrchr(__FILE__, '.'), 1); | |
include($phpbb_root_path . 'common.' . $phpEx); | |
// Start session management | |
$user->session_begin(); | |
$auth->acl($user->data); | |
$user->setup(); | |
function expect($expect, $got) | |
{ | |
if ($expect !== $got) | |
{ | |
$type_expect = gettype($expect); | |
$type_got = gettype($got); | |
//$_expect = var_export($expect, true); | |
//$_got = var_export($got, true); | |
$_expect = serialize($expect); | |
$_got = serialize($got); | |
echo "<pre style=\"color: red;\">Expecting '$_expect' [$type_expect], got '$_got' [$type_got].</pre>"; | |
} | |
else | |
{ | |
echo "<pre style=\"color: green;\">Got '$got'.</pre>"; | |
} | |
} | |
$data = array( | |
'foobar', | |
'1', | |
0, | |
1, | |
1.9, | |
true, | |
array(23, 'foo' => 'bar', 2.4, true, false), | |
); | |
echo '<h2>Local</h2>'; | |
foreach ($data as $key => $var) | |
{ | |
$key = '_test_' . $key; | |
expect(false, $cache->get($key)); | |
$cache->put($key, $var); | |
expect($var, $cache->get($key)); | |
$cache->destroy($key); | |
expect(false, $cache->get($key)); | |
$cache->destroy($key); | |
expect(false, $cache->get($key)); | |
} | |
echo '<h2>Global</h2>'; | |
foreach ($data as $key => $var) | |
{ | |
$key = 'test_' . $key; | |
expect(false, $cache->get($key)); | |
$cache->put($key, $var); | |
expect($var, $cache->get($key)); | |
$cache->destroy($key); | |
expect(false, $cache->get($key)); | |
$cache->destroy($key); | |
expect(false, $cache->get($key)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment