f2bfa8ce01eb4ecce0f7d09b732c969243c61ae6
[catagits/Catalyst-Plugin-Authentication.git] / t / 06_user.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 6;
5 use Test::Exception;
6
7 my $m; BEGIN { use_ok($m = "Catalyst::Authentication::User") }
8
9 {
10         package SomeUser;
11         use base $m;
12
13         sub new { bless {}, shift };
14
15         sub supported_features {
16                 {
17                         feature => {
18                                 subfeature => 1,
19                                 unsupported_subfeature => 0,
20                         },
21                         top_level => 1,
22                 }
23         }
24 }
25
26 my $o = SomeUser->new;
27
28 can_ok( $m, "supports" );
29
30 ok( $o->supports("top_level"), "simple top level feature check");
31 ok( $o->supports(qw/feature subfeature/), "traversal");
32 ok( !$o->supports(qw/feature unsupported_subfeature/), "traversal terminating in false");
33
34 lives_ok {
35         $o->supports("bad_key");
36 } "can check for non existent feature";
37
38 #dies_ok {
39 #       $o->supports(qw/bad_key subfeature/)
40 #} "but can't traverse into one";
41
42