/[A3C]/t/00-model-Person.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /t/00-model-Person.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by dpavlin, Thu Mar 13 12:09:06 2008 UTC revision 32 by dpavlin, Tue Mar 18 19:03:53 2008 UTC
# Line 8  A basic test harness for the User model. Line 8  A basic test harness for the User model.
8    
9  =cut  =cut
10    
11  use Jifty::Test tests => 11;  use Jifty::Test tests => 12;
12    
13  # Make sure we can load the model  # Make sure we can load the model
14  use_ok('CAdmin::Model::User');  use_ok('A3C::Model::User');
15    
16  # Grab a system user  # Grab a system user
17  my $system_user = CAdmin::CurrentUser->superuser;  my $system_user = A3C::CurrentUser->superuser;
18  ok($system_user, "Found a system user");  ok($system_user, "Found a system user");
19    
20  # Try testing a create  my $organization = A3C::Model::Organization->new(current_user => $system_user);
21  my $o = CAdmin::Model::User->new(current_user => $system_user);  my ($id) = $organization->create(
 my ($id) = $o->create(  
         sn => 'Foo',  
         givenName => 'Bar',  
         hrEduPersonUniqueNumber => 42,  
         hrEduPersonAffiliation => 'suradnik',  
22          o => 'CARNet',          o => 'CARNet',
23          hrEduPersonHomeOrg => 'skole.hr',          hrEduPersonHomeOrg => 'skole.hr',
24          postalAddress => 'Pere Perica b.b.',          postalAddress => 'Pere Perica b.b.',
25          l => 'Zagreb',          l => 'Zagreb',
26  );  );
27    ok($id, "Organization create returned success");
28    
29    # Try testing a create
30    my $o = A3C::Model::User->new(current_user => $system_user);
31    ($id) = $o->create(
32            uid => 42,
33            hrEduPersonUniqueID => 42,
34            hrEduPersonExpireDate => '2042-12-30',
35            givenName => 'Foo',
36            sn => 'Bar',
37            cn => 'Foo Bar',
38            hrEduPersonUniqueNumber => 42,
39            hrEduPersonAffiliation => 'suradnik',
40            organization => $organization,
41    );
42  ok($id, "User create returned success");  ok($id, "User create returned success");
43  ok($o->id, "New User has valid id set");  ok($o->id, "New User has valid id set");
44  is($o->id, $id, "Create returned the right id");  is($o->id, $id, "Create returned the right id");
45    
46  # And another  # And another
47  $o->create(  $o->create(
48          sn => 'Fooby',          uid => 1001,
49            hrEduPersonUniqueID => 1001,
50            hrEduPersonExpireDate => '1999-01-01',
51          givenName => 'Bary',          givenName => 'Bary',
52            sn => 'Fooby',
53            cn => 'Bary Fooby',
54          hrEduPersonUniqueNumber => 1001,          hrEduPersonUniqueNumber => 1001,
55          hrEduPersonAffiliation => 'gost',          hrEduPersonAffiliation => 'gost',
56          o => 'CARNet',          organization => $organization,
         hrEduPersonHomeOrg => 'skole.hr',  
         postalAddress => 'Pere Perica b.b.',  
         l => 'Zagreb',  
57  );  );
58  ok($o->id, "User create returned another value");  ok($o->id, "User create returned another value");
59  isnt($o->id, $id, "And it is different from the previous one");  isnt($o->id, $id, "And it is different from the previous one");
60    
61  # Searches in general  # Searches in general
62  my $collection =  CAdmin::Model::UserCollection->new(current_user => $system_user);  my $collection =  A3C::Model::UserCollection->new(current_user => $system_user);
63  $collection->unlimit;  $collection->unlimit;
64  is($collection->count, 2, "Finds two records");  is($collection->count, 2, "Finds two records");
65    

Legend:
Removed from v.6  
changed lines
  Added in v.32

  ViewVC Help
Powered by ViewVC 1.1.26