/[SQLSession]/trunk/t/00-model-Role.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 /trunk/t/00-model-Role.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103 - (show annotations)
Sat Feb 17 00:09:21 2007 UTC (17 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1341 byte(s)
make tests pass
1 #!/usr/bin/env perl
2 use warnings;
3 use strict;
4
5 use blib;
6
7 =head1 DESCRIPTION
8
9 A basic test harness for the Role model.
10
11 =cut
12
13 use Jifty::Test tests => 11;
14
15 # Make sure we can load the model
16 use_ok('SQLSession::Model::Role');
17
18 # Grab a system user
19 my $system_user = SQLSession::CurrentUser->superuser;
20 ok($system_user, "Found a system user");
21
22 # Try testing a create
23 my $o = SQLSession::Model::Role->new(current_user => $system_user);
24 my ($id) = $o->create(
25 user_id => 1,
26 role => 'student',
27 );
28 ok($id, "Role create returned success");
29 ok($o->id, "New Role has valid id set");
30 is($o->id, $id, "Create returned the right id");
31
32 # And another
33 $o->create(
34 user_id => 2,
35 role => 'student',
36 );
37 ok($o->id, "Role create returned another value");
38 isnt($o->id, $id, "And it is different from the previous one");
39
40 # Searches in general
41 my $collection = SQLSession::Model::RoleCollection->new(current_user => $system_user);
42 $collection->unlimit;
43 is($collection->count, 2, "Finds two records");
44
45 # Searches in specific
46 $collection->limit(column => 'id', value => $o->id);
47 is($collection->count, 1, "Finds one record with specific id");
48
49 # Delete one of them
50 $o->delete;
51 $collection->redo_search;
52 is($collection->count, 0, "Deleted row is gone");
53
54 # And the other one is still there
55 $collection->unlimit;
56 is($collection->count, 1, "Still one left");
57

  ViewVC Help
Powered by ViewVC 1.1.26