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

Annotation of /trunk/t/00-model-User.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Fri May 5 12:38:53 2006 UTC (18 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1407 byte(s)
test Model::User
1 dpavlin 1 #!/usr/bin/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('Transports::Model::User');
15    
16     # Grab a system use
17     my $system_user = Transports::CurrentUser->superuser;
18     ok($system_user, "Found a system user");
19    
20     # Try testing a create
21     my $o = Transports::Model::User->new(current_user => $system_user);
22 dpavlin 8 my ($id) = $o->create(
23     name => 'Foo Bar',
24     email => 'foo.bar@example.com',
25     password => 'foo123',
26     );
27 dpavlin 1 ok($id, "User create returned success");
28     ok($o->id, "New User has valid id set");
29     is($o->id, $id, "Create returned the right id");
30    
31     # And another
32 dpavlin 8 $o->create(
33     name => 'Baz Bar',
34     email => 'baz.bar@example.com',
35     password => 'baz123',
36     );
37 dpavlin 1 ok($o->id, "User 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 = Transports::Model::UserCollection->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