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