Bug 17189: Add the ability to define several memcached namespaces - tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 22 Jun 2016 15:10:23 +0000 (16:10 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Thu, 8 Sep 2016 10:24:46 +0000 (10:24 +0000)
Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
https://bugs.koha-community.org/show_bug.cgi?id=11921

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/Cache.t

index 1a25b77..759e993 100644 (file)
--- a/t/Cache.t
+++ b/t/Cache.t
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 42;
+use Test::More tests => 43;
 use Test::Warn;
 
 my $destructorcount = 0;
@@ -256,6 +256,26 @@ subtest 'Koha::Cache::Memory::Lite' => sub {
         undef, "fetching flushed item from cache" );
 };
 
+subtest 'Koha::Caches' => sub {
+    plan tests => 8;
+    my $default_cache = Koha::Cache->get_instance();
+    my $another_cache = Koha::Cache->get_instance('another_cache');
+    $default_cache->set_in_cache('key_a', 'value_a');
+    $default_cache->set_in_cache('key_b', 'value_b');
+    $another_cache->set_in_cache('key_a', 'another_value_a');
+    $another_cache->set_in_cache('key_b', 'another_value_b');
+    is( $default_cache->get_from_cache('key_a'), 'value_a' );
+    is( $another_cache->get_from_cache('key_a'), 'another_value_a' );
+    is( $default_cache->get_from_cache('key_b'), 'value_b' );
+    is( $another_cache->get_from_cache('key_b'), 'another_value_b' );
+    $another_cache->clear_from_cache('key_b');
+    is( $default_cache->get_from_cache('key_b'), 'value_b' );
+    is( $another_cache->get_from_cache('key_b'), undef );
+    $another_cache->flush_all();
+    is( $default_cache->get_from_cache('key_a'), 'value_a' );
+    is( $another_cache->get_from_cache('key_a'), undef );
+};
+
 END {
   SKIP: {
         $ENV{ MEMCACHED_NAMESPACE } = 'unit_tests';