Commit | Line | Data |
2e4bde89 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More 'no_plan'; |
7 | |
8 | use Scalar::Util qw/refaddr/; |
9 | |
10 | use ok "Catalyst::Plugin::Cache"; |
11 | |
12 | { |
13 | package MockApp; |
14 | use base qw/Catalyst::Plugin::Cache/; |
15 | |
16 | my %config = ( |
17 | cache => { |
18 | profiles => { |
19 | foo => { |
20 | bah => "foo", |
21 | }, |
aed484da |
22 | bar => bless( {}, "SomeClass" ), |
2e4bde89 |
23 | }, |
24 | }, |
25 | ); |
26 | sub config { \%config }; |
27 | |
aed484da |
28 | package SomeClass; |
29 | sub get {} |
30 | sub set {} |
31 | sub remove {} |
2e4bde89 |
32 | } |
33 | |
34 | MockApp->setup; |
35 | my $c = bless {}, "MockApp"; |
36 | |
aed484da |
37 | MockApp->register_cache_backend( default => bless({}, "SomeClass") ); |
2e4bde89 |
38 | |
39 | can_ok( $c, "curry_cache" ); |
40 | can_ok( $c, "get_preset_curried" ); |
41 | |
42 | isa_ok( $c->cache, "Catalyst::Plugin::Cache::Curried" ); |
43 | |
44 | is( refaddr($c->cache), refaddr($c->cache), "default cache is memoized, so it is =="); |
45 | |
46 | isa_ok( $c->cache("foo"), "Catalyst::Plugin::Cache::Curried", "cache('foo')" ); |
47 | |
48 | is_deeply( $c->cache("foo")->meta, [ bah => "foo" ], "meta is in place" ); |
49 | |
50 | is( refaddr( $c->cache("bar") ), refaddr( $c->cache("bar") ), "since bar is hard coded as an object it's always the same" ); |
51 | |