Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 41; |
20 |
use Test::More tests => 43; |
21 |
use Test::Warn; |
21 |
use Test::Warn; |
22 |
|
22 |
|
23 |
my $destructorcount = 0; |
23 |
my $destructorcount = 0; |
Lines 25-30
my $destructorcount = 0;
Link Here
|
25 |
BEGIN { |
25 |
BEGIN { |
26 |
use_ok('Koha::Cache'); |
26 |
use_ok('Koha::Cache'); |
27 |
use_ok('Koha::Cache::Object'); |
27 |
use_ok('Koha::Cache::Object'); |
|
|
28 |
use_ok('Koha::Cache::Memory::Lite'); |
28 |
use_ok('C4::Context'); |
29 |
use_ok('C4::Context'); |
29 |
} |
30 |
} |
30 |
|
31 |
|
Lines 221-226
SKIP: {
Link Here
|
221 |
is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { another => 'hashref' }, 'A hash will not be deep copied if the unsafe flag is set'); |
222 |
is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { another => 'hashref' }, 'A hash will not be deep copied if the unsafe flag is set'); |
222 |
} |
223 |
} |
223 |
|
224 |
|
|
|
225 |
subtest 'Koha::Cache::Memory::Lite' => sub { |
226 |
plan tests => 6; |
227 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
228 |
|
229 |
# test fetching an item that isnt in the cache |
230 |
is( $memory_cache->get_from_cache("not in here"), |
231 |
undef, "fetching item NOT in cache" ); |
232 |
|
233 |
# test fetching a valid item from cache |
234 |
$memory_cache->set_in_cache( "clear_me", "I AM MORE DATA" ); |
235 |
$memory_cache->set_in_cache( "dont_clear_me", "I AM MORE DATA22" ); |
236 |
; # overly large expiry time, clear below |
237 |
is( |
238 |
$memory_cache->get_from_cache("clear_me"), |
239 |
"I AM MORE DATA", |
240 |
"fetching valid item from cache" |
241 |
); |
242 |
|
243 |
# test clearing from cache |
244 |
$memory_cache->clear_from_cache("clear_me"); |
245 |
is( $memory_cache->get_from_cache("clear_me"), |
246 |
undef, "fetching cleared item from cache" ); |
247 |
is( |
248 |
$memory_cache->get_from_cache("dont_clear_me"), |
249 |
"I AM MORE DATA22", |
250 |
"fetching valid item from cache (after clearing another item)" |
251 |
); |
252 |
|
253 |
#test flushing from cache |
254 |
$memory_cache->set_in_cache( "flush_me", "testing 1 data" ); |
255 |
$memory_cache->flush; |
256 |
is( $memory_cache->get_from_cache("flush_me"), |
257 |
undef, "fetching flushed item from cache" ); |
258 |
is( $memory_cache->get_from_cache("dont_clear_me"), |
259 |
undef, "fetching flushed item from cache" ); |
260 |
}; |
261 |
|
224 |
END { |
262 |
END { |
225 |
SKIP: { |
263 |
SKIP: { |
226 |
$ENV{ MEMCACHED_NAMESPACE } = 'unit_tests'; |
264 |
$ENV{ MEMCACHED_NAMESPACE } = 'unit_tests'; |
227 |
- |
|
|