Unit test for Authentication::User
[catagits/Catalyst-Plugin-Authentication.git] / t / 06_user.t.t
CommitLineData
9985827d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 7;
7use Test::Exception;
8
9my $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
28my $o = SomeUser->new;
29
30can_ok( $m, "supports" );
31
32ok( $o->supports("top_level"), "simple top level feature check");
33ok( $o->supports(qw/feature subfeature/), "traversal");
34ok( !$o->supports(qw/feature unsupported_subfeature/), "traversal terminating in false");
35
36lives_ok {
37 $o->supports("bad_key");
38} "cant check for non existent feature";
39
40dies_ok {
41 $o->supports(qw/bad_key subfeature/)
42} "but can't traverse into one";
43
44