Live app test, Cache::Store::Memory
[catagits/Catalyst-Plugin-Cache.git] / t / currying_conf.t
CommitLineData
2e4bde89 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More 'no_plan';
7
8use Scalar::Util qw/refaddr/;
9
10use 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
34MockApp->setup;
35my $c = bless {}, "MockApp";
36
aed484da 37MockApp->register_cache_backend( default => bless({}, "SomeClass") );
2e4bde89 38
39can_ok( $c, "curry_cache" );
40can_ok( $c, "get_preset_curried" );
41
42isa_ok( $c->cache, "Catalyst::Plugin::Cache::Curried" );
43
44is( refaddr($c->cache), refaddr($c->cache), "default cache is memoized, so it is ==");
45
46isa_ok( $c->cache("foo"), "Catalyst::Plugin::Cache::Curried", "cache('foo')" );
47
48is_deeply( $c->cache("foo")->meta, [ bah => "foo" ], "meta is in place" );
49
50is( refaddr( $c->cache("bar") ), refaddr( $c->cache("bar") ), "since bar is hard coded as an object it's always the same" );
51