Use skip_all and done_testing in all tests
[catagits/Catalyst-Authentication-Store-LDAP.git] / t / 03-entry_class.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use Catalyst::Exception;
6
7 use Test::More;
8 use lib 't/lib';
9 use LDAPTest;
10
11 eval "use Catalyst::Model::LDAP";
12 plan skip_all => "Catalyst::Model::LDAP not installed" if $@;
13
14 my $server = LDAPTest::spawn_server();
15
16 use_ok("Catalyst::Authentication::Store::LDAP::Backend");
17
18 my $back = Catalyst::Authentication::Store::LDAP::Backend->new(
19     {   'ldap_server' => LDAPTest::server_host(),
20         'binddn'      => 'anonymous',
21         'bindpw'      => 'dontcarehow',
22         'start_tls'   => 0,
23         'user_basedn' => 'ou=foobar',
24         'user_filter' => '(&(objectClass=person)(uid=%s))',
25         'user_scope'  => 'one',
26         'user_field'  => 'uid',
27         'use_roles'   => 0,
28         'entry_class' => 'EntryClass',
29     }
30 );
31
32 isa_ok( $back, "Catalyst::Authentication::Store::LDAP::Backend" );
33 my $user = $back->find_user( { username => 'somebody' } );
34 isa_ok( $user, "Catalyst::Authentication::Store::LDAP::User" );
35 my $displayname = $user->displayname;
36 cmp_ok( $displayname, 'eq', 'Some Body', 'Should be Some Body' );
37
38 isa_ok( $user->ldap_entry, "EntryClass", "entry_class works" );
39 is( $user->ldap_entry->my_method, 1001, "methods on entry_class works" );
40
41 done_testing;