Change config key in tests
[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';
5a00a29b 7use Test::Deep qw/superhashof cmp_deeply/;
2e4bde89 8
9use Scalar::Util qw/refaddr/;
10
11use ok "Catalyst::Plugin::Cache";
12
13{
14 package MockApp;
15 use base qw/Catalyst::Plugin::Cache/;
16
17 my %config = (
d18c37f3 18 'Plugin::Cache' => {
2e4bde89 19 profiles => {
20 foo => {
21 bah => "foo",
22 },
aed484da 23 bar => bless( {}, "SomeClass" ),
2e4bde89 24 },
e9154310 25 ### as of 0.06, we need a specific backend
26 ### specified
27 backend => {
28 class => 'SomeClass',
29 }
2e4bde89 30 },
31 );
32 sub config { \%config };
33
aed484da 34 package SomeClass;
e9154310 35 ### backend must have a constructor
36 sub new { bless {}, shift };
aed484da 37 sub get {}
38 sub set {}
39 sub remove {}
2e4bde89 40}
41
42MockApp->setup;
43my $c = bless {}, "MockApp";
44
aed484da 45MockApp->register_cache_backend( default => bless({}, "SomeClass") );
2e4bde89 46
47can_ok( $c, "curry_cache" );
48can_ok( $c, "get_preset_curried" );
49
50isa_ok( $c->cache, "Catalyst::Plugin::Cache::Curried" );
51
52is( refaddr($c->cache), refaddr($c->cache), "default cache is memoized, so it is ==");
53
54isa_ok( $c->cache("foo"), "Catalyst::Plugin::Cache::Curried", "cache('foo')" );
55
5a00a29b 56cmp_deeply( { @{ $c->cache("foo")->meta } }, superhashof({ bah => "foo" }), "meta is in place" );
2e4bde89 57
58is( refaddr( $c->cache("bar") ), refaddr( $c->cache("bar") ), "since bar is hard coded as an object it's always the same" );
59