Commit | Line | Data |
9985827d |
1 | use strict; |
2 | use warnings; |
3 | |
4b33bb96 |
4 | use Test::More; |
9985827d |
5 | use Test::Exception; |
6 | |
5c5af345 |
7 | my $m; BEGIN { use_ok($m = "Catalyst::Authentication::User") } |
9985827d |
8 | |
9 | { |
4b33bb96 |
10 | package SomeBaseUser; |
11 | sub other_method { 'FNAR' }; |
12 | } |
13 | |
14 | { |
fb90f091 |
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 | } |
4b33bb96 |
29 | sub get_object { |
30 | bless {}, 'SomeBaseUser'; |
31 | } |
9985827d |
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 { |
fb90f091 |
43 | $o->supports("bad_key"); |
fa194d25 |
44 | } "can check for non existent feature"; |
9985827d |
45 | |
fa194d25 |
46 | #dies_ok { |
fb90f091 |
47 | # $o->supports(qw/bad_key subfeature/) |
fa194d25 |
48 | #} "but can't traverse into one"; |
9985827d |
49 | |
4b33bb96 |
50 | lives_ok { |
51 | is $o->other_method, 'FNAR', 'Delegation onto user object works'; |
52 | } 'Delegation lives'; |
53 | |
54 | done_testing; |
55 | |
9985827d |
56 | |