View | Details | Raw Unified | Return to bug 16166
Collapse All | Expand All

(-)a/t/Cache.t (-10 / +6 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 40;
20
use Test::More tests => 39;
21
21
22
my $destructorcount = 0;
22
my $destructorcount = 0;
23
23
Lines 33-39 SKIP: { Link Here
33
    $ENV{ MEMCACHED_NAMESPACE } = 'unit_tests';
33
    $ENV{ MEMCACHED_NAMESPACE } = 'unit_tests';
34
    my $cache = Koha::Cache->get_instance();
34
    my $cache = Koha::Cache->get_instance();
35
35
36
    skip "Cache not enabled", 33
36
    skip "Cache not enabled", 35
37
      unless ( $cache->is_cache_active() && defined $cache );
37
      unless ( $cache->is_cache_active() && defined $cache );
38
38
39
    # test fetching an item that isnt in the cache
39
    # test fetching an item that isnt in the cache
Lines 189-195 SKIP: { Link Here
189
189
190
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array', { unsafe => 1 });
190
    $item_from_cache = $cache->get_from_cache('test_deep_copy_array', { unsafe => 1 });
191
    @$item_from_cache = qw( another array ref );
191
    @$item_from_cache = qw( another array ref );
192
    is_deeply( $cache->get_from_cache('test_deep_copy_array'), [ qw ( another array ref ) ], 'An array will not be deep copied if the unsafe flag is set');
192
    is_deeply( $cache->get_from_cache('test_deep_copy_array', { unsafe => 1 }), [ qw ( another array ref ) ], 'An array will not be deep copied if the unsafe flag is set');
193
    # Hash
193
    # Hash
194
    my %item = ( a => 'hashref' );
194
    my %item = ( a => 'hashref' );
195
    $cache->set_in_cache('test_deep_copy_hash', \%item);
195
    $cache->set_in_cache('test_deep_copy_hash', \%item);
Lines 201-213 SKIP: { Link Here
201
    is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { a => 'hashref' }, 'A hash will be deep copied when set in cache');
201
    is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { a => 'hashref' }, 'A hash will be deep copied when set in cache');
202
202
203
    %item = ( a => 'hashref' );
203
    %item = ( a => 'hashref' );
204
    $cache->set_in_cache('test_deep_copy_hash', \%item, { unsafe => 1});
204
    $cache->set_in_cache('test_deep_copy_hash', \%item);
205
    %item = ( a_modified => 'hashref' );
205
    $item_from_cache = $cache->get_from_cache('test_deep_copy_hash', { unsafe => 1 });
206
    is_deeply( $cache->get_from_cache('test_deep_copy_hash'), { a_modified => 'hashref' }, 'A hash will not be deep copied when set in cache if the unsafe flag is set');
207
208
    $item_from_cache = $cache->get_from_cache('test_deep_copy_hash', { unsafe => 1});
209
    %$item_from_cache = ( another => 'hashref' );
206
    %$item_from_cache = ( another => 'hashref' );
210
    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');
207
    is_deeply( $cache->get_from_cache('test_deep_copy_hash', { unsafe => 1 }), { another => 'hashref' }, 'A hash will not be deep copied if the unsafe flag is set');
211
}
208
}
212
209
213
END {
210
END {
214
- 

Return to bug 16166