clarify user and user_exists behaviour
[catagits/Catalyst-Plugin-Authentication.git] / t / 06_user.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6
7 my $m; BEGIN { use_ok($m = "Catalyst::Authentication::User") }
8
9 {
10     package SomeBaseUser;
11     sub other_method { 'FNAR' };
12 }
13
14 {
15     package SomeUser;
16     use base $m;
17
18     sub new { bless {}, shift };
19
20     sub supported_features {
21         {
22             feature => {
23                 subfeature => 1,
24                 unsupported_subfeature => 0,
25             },
26             top_level => 1,
27         }
28     }
29     sub get_object {
30         bless {}, 'SomeBaseUser';
31     }
32 }
33
34 my $o = SomeUser->new;
35
36 can_ok( $m, "supports" );
37
38 ok( $o->supports("top_level"), "simple top level feature check");
39 ok( $o->supports(qw/feature subfeature/), "traversal");
40 ok( !$o->supports(qw/feature unsupported_subfeature/), "traversal terminating in false");
41
42 lives_ok {
43     $o->supports("bad_key");
44 } "can check for non existent feature";
45
46 #dies_ok {
47 #    $o->supports(qw/bad_key subfeature/)
48 #} "but can't traverse into one";
49
50 lives_ok {
51     is $o->other_method, 'FNAR', 'Delegation onto user object works';
52 } 'Delegation lives';
53
54 done_testing;
55
56