--- t/10-ldap.t 2008/03/30 00:02:18 36 +++ t/10-ldap.t 2008/05/14 16:50:49 112 @@ -8,22 +8,47 @@ =cut -use Jifty::Test tests => 5; +use Jifty::Test tests => 29; +use Data::Dump qw/dump/; use_ok('A3C::LDAP'); +ok( my $ldap = A3C::LDAP->new, 'new' ); + +isa_ok( $ldap, 'A3C::LDAP' ); + +isa_ok( $ldap->objectClass, 'HASH', 'have objectClass' ); +isa_ok( $ldap->link, 'HASH', 'have link' ); + +diag "objectClass = ",dump( $ldap->objectClass ); +diag "link = ",dump( $ldap->link ); + ok( - my $msg = A3C::LDAP->search( + $ldap->search( base => 'dc=skole,dc=hr', filter => '(objectClass=hrEduOrg)', + sizelimit => 10, ) ), 'search'; -diag 'code: ', $msg->code, ' count: ', $msg->count; +isa_ok( $ldap, 'A3C::LDAP' ); + +cmp_ok( $ldap->count, '==', 10, 'count' ); + +foreach my $i ( 1 .. 10 ) { + ok( my $entry = $ldap->next, "next $i" ); +# $entry->dump; +} -isa_ok( $msg, 'Net::LDAP::Search' ); +my $org_oc = $ldap->objectClass->{organization}; -is( $msg->code, 0, 'code' ); +foreach my $limit ( 3, 7, 14 ) { + ok( my $collection = $ldap->collection( $org_oc, limit => $limit), "collection $org_oc limit = $limit" ); + isa_ok( $collection, "A3C::Model::${org_oc}Collection" ); + is( $collection->count, $limit, 'count' ); +} -cmp_ok( $msg->count, '>', 1000, 'count' ); +my $person_oc = $ldap->objectClass->{person}; +ok( my $coll = $ldap->collection( $person_oc, filter => '(HrEduPersonHomeOrg=aa-test-zz)'), 'collection with filter' ); +is( $coll->count, 0, 'no results' );