Unit test for Authentication::User
Yuval Kogman [Tue, 8 Nov 2005 15:56:24 +0000 (15:56 +0000)]
t/06_user.t.t [new file with mode: 0644]

diff --git a/t/06_user.t.t b/t/06_user.t.t
new file mode 100644 (file)
index 0000000..f408163
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+use Test::Exception;
+
+my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::User") }
+
+{
+       package SomeUser;
+       use base $m;
+
+       sub new { bless {}, shift };
+
+       sub supported_features {
+               {
+                       feature => {
+                               subfeature => 1,
+                               unsupported_subfeature => 0,
+                       },
+                       top_level => 1,
+               }
+       }
+}
+
+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");
+} "cant check for non existent feature";
+
+dies_ok {
+       $o->supports(qw/bad_key subfeature/)
+} "but can't traverse into one";
+
+