Commit | Line | Data |
7afa5efd |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
c30ad9df |
4 | use Try::Tiny; |
7afa5efd |
5 | use Catalyst::Authentication::Store::DBIx::Class::User; |
6 | |
7 | my $message = 'I exist'; |
8 | |
9 | { |
10 | package My::Test; |
11 | |
12 | sub exists { $message } |
13 | } |
14 | |
c30ad9df |
15 | my $class = 'Catalyst::Authentication::Store::DBIx::Class::User'; |
7afa5efd |
16 | my $o = bless({ |
17 | _user => bless({}, 'My::Test'), |
c30ad9df |
18 | }, $class); |
7afa5efd |
19 | |
20 | is($o->exists, $message, 'AUTOLOAD proxies ok'); |
21 | |
22 | ok(my $meth = $o->can('exists'), 'can returns true'); |
23 | |
7afa5efd |
24 | is($o->$meth, $message, 'can returns right coderef'); |
25 | |
057348d8 |
26 | is($o->can('non_existent_method'), undef, 'can on non existent method returns undef'); |
27 | |
c30ad9df |
28 | is($o->non_existent_method, undef, 'AUTOLOAD traps non existent method'); |
29 | |
30 | try { |
31 | is($class->can('non_existent_method'), undef, "can on non existent class method"); |
32 | } catch { |
33 | my $e = $_; |
34 | fail('can on non existent class method'); |
35 | diag("Got exception: $e"); |
36 | }; |
37 | |
38 | try { |
39 | is($class->non_existent_method, undef, 'AUTOLOAD traps non existent class method'); |
40 | } catch { |
41 | my $e = $_; |
42 | fail('AUTOLOAD traps non existent class method'); |
43 | diag("Got exception: $e"); |
44 | }; |
45 | |
7afa5efd |
46 | done_testing; |