/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18 - (show annotations)
Thu Mar 13 19:26:56 2008 UTC (16 years ago) by dpavlin
Original Path: t/00-model-User.t
File MIME type: application/x-troff
File size: 1819 byte(s)
remove Jifty::Plugin::User::Mixin::Model::User and
implement it ourselfs, with few tweaks for other
mixins (email* accessors)

1 #!/usr/bin/env perl
2 use warnings;
3 use strict;
4
5 =head1 DESCRIPTION
6
7 A basic test harness for the User model.
8
9 =cut
10
11 use Jifty::Test tests => 11;
12
13 # Make sure we can load the model
14 use_ok('A3C::Model::User');
15
16 # Grab a system user
17 my $system_user = A3C::CurrentUser->superuser;
18 ok($system_user, "Found a system user");
19
20 # Try testing a create
21 my $o = A3C::Model::User->new(current_user => $system_user);
22 my ($id) = $o->create(
23 uid => 42,
24 hrEduPersonUniqueID => 42,
25 hrEduPersonExpireDate => '2042-12-30',
26 sn => 'Foo',
27 givenName => 'Bar',
28 hrEduPersonUniqueNumber => 42,
29 hrEduPersonAffiliation => 'suradnik',
30 o => 'CARNet',
31 hrEduPersonHomeOrg => 'skole.hr',
32 postalAddress => 'Pere Perica b.b.',
33 l => 'Zagreb',
34 );
35 ok($id, "User create returned success");
36 ok($o->id, "New User has valid id set");
37 is($o->id, $id, "Create returned the right id");
38
39 # And another
40 $o->create(
41 uid => 1001,
42 hrEduPersonUniqueID => 1001,
43 hrEduPersonExpireDate => '1999-01-01',
44 sn => 'Fooby',
45 givenName => 'Bary',
46 hrEduPersonUniqueNumber => 1001,
47 hrEduPersonAffiliation => 'gost',
48 o => 'CARNet',
49 hrEduPersonHomeOrg => 'skole.hr',
50 postalAddress => 'Pere Perica b.b.',
51 l => 'Zagreb',
52 );
53 ok($o->id, "User create returned another value");
54 isnt($o->id, $id, "And it is different from the previous one");
55
56 # Searches in general
57 my $collection = A3C::Model::UserCollection->new(current_user => $system_user);
58 $collection->unlimit;
59 is($collection->count, 2, "Finds two records");
60
61 # Searches in specific
62 $collection->limit(column => 'id', value => $o->id);
63 is($collection->count, 1, "Finds one record with specific id");
64
65 # Delete one of them
66 $o->delete;
67 $collection->redo_search;
68 is($collection->count, 0, "Deleted row is gone");
69
70 # And the other one is still there
71 $collection->unlimit;
72 is($collection->count, 1, "Still one left");
73

  ViewVC Help
Powered by ViewVC 1.1.26