General fixes, docs, love (C::P::Cache)
[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 = (
18 cache => {
19 profiles => {
20 foo => {
21 bah => "foo",
22 },
aed484da 23 bar => bless( {}, "SomeClass" ),
2e4bde89 24 },
25 },
26 );
27 sub config { \%config };
28
aed484da 29 package SomeClass;
30 sub get {}
31 sub set {}
32 sub remove {}
2e4bde89 33}
34
35MockApp->setup;
36my $c = bless {}, "MockApp";
37
aed484da 38MockApp->register_cache_backend( default => bless({}, "SomeClass") );
2e4bde89 39
40can_ok( $c, "curry_cache" );
41can_ok( $c, "get_preset_curried" );
42
43isa_ok( $c->cache, "Catalyst::Plugin::Cache::Curried" );
44
45is( refaddr($c->cache), refaddr($c->cache), "default cache is memoized, so it is ==");
46
47isa_ok( $c->cache("foo"), "Catalyst::Plugin::Cache::Curried", "cache('foo')" );
48
5a00a29b 49cmp_deeply( { @{ $c->cache("foo")->meta } }, superhashof({ bah => "foo" }), "meta is in place" );
2e4bde89 50
51is( refaddr( $c->cache("bar") ), refaddr( $c->cache("bar") ), "since bar is hard coded as an object it's always the same" );
52