--- t/00-model-User.t 2008/03/09 22:39:58 2 +++ t/00-model-Person.t 2008/06/03 19:29:36 150 @@ -4,33 +4,68 @@ =head1 DESCRIPTION -A basic test harness for the User model. +A basic test harness for the Person model. =cut use Jifty::Test tests => 11; # Make sure we can load the model -use_ok('CAdmin::Model::User'); +use_ok('A3C::Model::Person'); # Grab a system user -my $system_user = CAdmin::CurrentUser->superuser; +my $system_user = A3C::CurrentUser->superuser; ok($system_user, "Found a system user"); +my $id; + +=for later +my $organization = A3C::Model::Organization->new(current_user => $system_user); +($id) = $organization->create( + o => 'CARNet', + hrEduPersonHomeOrg => 'skole.hr', + postalAddress => 'Pere Perica b.b.', + l => 'Zagreb', +); +ok($id, "Organization create returned success"); +=cut + # Try testing a create -my $o = CAdmin::Model::User->new(current_user => $system_user); -my ($id) = $o->create(); -ok($id, "User create returned success"); -ok($o->id, "New User has valid id set"); +my $o = A3C::Model::Person->new(current_user => $system_user); +($id) = $o->create( + uid => 42, + hrEduPersonUniqueID => 42, + hrEduPersonExpireDate => '2042-12-30', + givenName => 'Foo', + sn => 'Bar', + cn => 'Foo Bar', + hrEduPersonUniqueNumber => 42, + hrEduPersonAffiliation => 'suradnik', + hrEduPersonHomeOrg => 'skole.hr', +# organization => $organization, +); +ok($id, "Person create returned success"); +ok($o->id, "New Person has valid id set"); is($o->id, $id, "Create returned the right id"); # And another -$o->create(); -ok($o->id, "User create returned another value"); +$o->create( + uid => 1001, + hrEduPersonUniqueID => 1001, + hrEduPersonExpireDate => '1999-01-01', + givenName => 'Bary', + sn => 'Fooby', + cn => 'Bary Fooby', + hrEduPersonUniqueNumber => 1001, + hrEduPersonAffiliation => 'gost', + hrEduPersonHomeOrg => 'skole.hr', +# organization => $organization, +); +ok($o->id, "Person create returned another value"); isnt($o->id, $id, "And it is different from the previous one"); # Searches in general -my $collection = CAdmin::Model::UserCollection->new(current_user => $system_user); +my $collection = A3C::Model::PersonCollection->new(current_user => $system_user); $collection->unlimit; is($collection->count, 2, "Finds two records");