Commit | Line | Data |
9985827d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
fa194d25 |
6 | use Test::More tests => 6; |
9985827d |
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"); |
fa194d25 |
38 | } "can check for non existent feature"; |
9985827d |
39 | |
fa194d25 |
40 | #dies_ok { |
41 | # $o->supports(qw/bad_key subfeature/) |
42 | #} "but can't traverse into one"; |
9985827d |
43 | |
44 | |