11 |
use Jifty::Test tests => 11; |
use Jifty::Test tests => 11; |
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 $id; |
21 |
my $o = CAdmin::Model::User->new(current_user => $system_user); |
|
22 |
my ($id) = $o->create( |
=for later |
23 |
sn => 'Foo', |
my $organization = A3C::Model::Organization->new(current_user => $system_user); |
24 |
givenName => 'Bar', |
($id) = $organization->create( |
|
hrEduPersonUniqueNumber => 42, |
|
|
hrEduPersonAffiliation => 'suradnik', |
|
25 |
o => 'CARNet', |
o => 'CARNet', |
26 |
hrEduPersonHomeOrg => 'skole.hr', |
hrEduPersonHomeOrg => 'skole.hr', |
27 |
postalAddress => 'Pere Perica b.b.', |
postalAddress => 'Pere Perica b.b.', |
28 |
l => 'Zagreb', |
l => 'Zagreb', |
29 |
); |
); |
30 |
|
ok($id, "Organization create returned success"); |
31 |
|
=cut |
32 |
|
|
33 |
|
# Try testing a create |
34 |
|
my $o = A3C::Model::User->new(current_user => $system_user); |
35 |
|
($id) = $o->create( |
36 |
|
uid => 42, |
37 |
|
hrEduPersonUniqueID => 42, |
38 |
|
hrEduPersonExpireDate => '2042-12-30', |
39 |
|
givenName => 'Foo', |
40 |
|
sn => 'Bar', |
41 |
|
cn => 'Foo Bar', |
42 |
|
hrEduPersonUniqueNumber => 42, |
43 |
|
hrEduPersonAffiliation => 'suradnik', |
44 |
|
hrEduPersonHomeOrg => 'skole.hr', |
45 |
|
# organization => $organization, |
46 |
|
); |
47 |
ok($id, "User create returned success"); |
ok($id, "User create returned success"); |
48 |
ok($o->id, "New User has valid id set"); |
ok($o->id, "New User has valid id set"); |
49 |
is($o->id, $id, "Create returned the right id"); |
is($o->id, $id, "Create returned the right id"); |
50 |
|
|
51 |
# And another |
# And another |
52 |
$o->create( |
$o->create( |
53 |
sn => 'Fooby', |
uid => 1001, |
54 |
|
hrEduPersonUniqueID => 1001, |
55 |
|
hrEduPersonExpireDate => '1999-01-01', |
56 |
givenName => 'Bary', |
givenName => 'Bary', |
57 |
|
sn => 'Fooby', |
58 |
|
cn => 'Bary Fooby', |
59 |
hrEduPersonUniqueNumber => 1001, |
hrEduPersonUniqueNumber => 1001, |
60 |
hrEduPersonAffiliation => 'gost', |
hrEduPersonAffiliation => 'gost', |
|
o => 'CARNet', |
|
61 |
hrEduPersonHomeOrg => 'skole.hr', |
hrEduPersonHomeOrg => 'skole.hr', |
62 |
postalAddress => 'Pere Perica b.b.', |
# organization => $organization, |
|
l => 'Zagreb', |
|
63 |
); |
); |
64 |
ok($o->id, "User create returned another value"); |
ok($o->id, "User create returned another value"); |
65 |
isnt($o->id, $id, "And it is different from the previous one"); |
isnt($o->id, $id, "And it is different from the previous one"); |
66 |
|
|
67 |
# Searches in general |
# Searches in general |
68 |
my $collection = CAdmin::Model::UserCollection->new(current_user => $system_user); |
my $collection = A3C::Model::UserCollection->new(current_user => $system_user); |
69 |
$collection->unlimit; |
$collection->unlimit; |
70 |
is($collection->count, 2, "Finds two records"); |
is($collection->count, 2, "Finds two records"); |
71 |
|
|