File: 06_user.t

package info (click to toggle)
libcatalyst-plugin-authentication-perl 0.10023-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 604 kB
  • ctags: 307
  • sloc: perl: 3,672; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use strict;
use warnings;

use Test::More;
use Test::Exception;

my $m; BEGIN { use_ok($m = "Catalyst::Authentication::User") }

{
    package SomeBaseUser;
    sub other_method { 'FNAR' };
}

{
    package SomeUser;
    use base $m;

    sub new { bless {}, shift };

    sub supported_features {
        {
            feature => {
                subfeature => 1,
                unsupported_subfeature => 0,
            },
            top_level => 1,
        }
    }
    sub get_object {
        bless {}, 'SomeBaseUser';
    }
}

my $o = SomeUser->new;

can_ok( $m, "supports" );

ok( $o->supports("top_level"), "simple top level feature check");
ok( $o->supports(qw/feature subfeature/), "traversal");
ok( !$o->supports(qw/feature unsupported_subfeature/), "traversal terminating in false");

lives_ok {
    $o->supports("bad_key");
} "can check for non existent feature";

#dies_ok {
#    $o->supports(qw/bad_key subfeature/)
#} "but can't traverse into one";

lives_ok {
    is $o->other_method, 'FNAR', 'Delegation onto user object works';
} 'Delegation lives';

done_testing;