diff options
author | Urban Müller | 2015-01-08 14:44:40 +0100 |
---|---|---|
committer | Urban Müller | 2015-01-08 14:44:40 +0100 |
commit | 1ca17962a2df0254ac4db0724d167351983c99e4 (patch) | |
tree | f2b9938a2e6c7446810af6ffd1599506f8c1c25f | |
parent | 3d73bfcaf9d8b50daf5e9c234d7889ce23e600e5 (diff) | |
download | itools-1ca17962a2df0254ac4db0724d167351983c99e4.tar.gz itools-1ca17962a2df0254ac4db0724d167351983c99e4.tar.bz2 itools-1ca17962a2df0254ac4db0724d167351983c99e4.zip |
test new it_cache behaviour
-rwxr-xr-x | tests/it_cache.t | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/it_cache.t b/tests/it_cache.t new file mode 100755 index 0000000..cb11297 --- /dev/null +++ b/tests/it_cache.t @@ -0,0 +1,47 @@ +#!/www/server/bin/php +<?php + +# test array_based process cache +it_cache::put('it_cache_t', 1); +ok(it_cache::get('it_cache_t') === 1); + +it_cache::put('it_cache_t', false); +ok(it_cache::get('it_cache_t') === false); + +it_cache::put('it_cache_t', [2]); +ok(it_cache::get('it_cache_t') === [2]); + + +# test non-distributed apc cache +it_cache::put('it_cache_t', 1); +unset($GLOBALS['it_cache_local']); +ok(it_cache::get('it_cache_t') === 1); + +it_cache::put('it_cache_t', false); +unset($GLOBALS['it_cache_local']); +ok(it_cache::get('it_cache_t') === false); + +it_cache::put('it_cache_t', [2]); +unset($GLOBALS['it_cache_local']); +ok(it_cache::get('it_cache_t') === [2]); + +ok(it_cache::get('it_cache_t'.rand(1, 1000)) === null); + + +# test distributed memcache +$GLOBALS['debug_aslive'] = 1; + +it_cache::put('it_cache_d', 1, 'distributed' => 1); +unset($GLOBALS['it_cache_local']); +ok(it_cache::get('it_cache_d', 'distributed' => 1) == '1'); + +it_cache::put('it_cache_d', false, 'distributed' => 1); +unset($GLOBALS['it_cache_local']); +ok(it_cache::get('it_cache_d', 'distributed' => 1) === ''); + +it_cache::put('it_cache_d', [2], 'distributed' => 1); +unset($GLOBALS['it_cache_local']); +ok(it_cache::get('it_cache_d', 'distributed' => 1) === [2]); + +ok(it_cache::get('it_cache_d'.rand(1, 1000), 'distributed' => 1) === null); + |