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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 53 - (show annotations)
Mon Jun 5 14:14:19 2006 UTC (17 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1471 byte(s)
tweak tests for bootstrap data and add all values to create calls so that they don't fail
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 my $bootstrap_users = 5;
14
15 # Make sure we can load the model
16 use_ok('Transports::Model::User');
17
18 # Grab a system use
19 my $system_user = Transports::CurrentUser->superuser;
20 ok($system_user, "Found a system user");
21
22 # Try testing a create
23 my $o = Transports::Model::User->new(current_user => $system_user);
24 my ($id) = $o->create(
25 name => 'Foo Bar',
26 email => 'foo.bar@example.com',
27 password => 'foo123',
28 );
29 ok($id, "User create returned success");
30 ok($o->id, "New User has valid id set");
31 is($o->id, $id, "Create returned the right id");
32
33 # And another
34 $o->create(
35 name => 'Baz Bar',
36 email => 'baz.bar@example.com',
37 password => 'baz123',
38 );
39 ok($o->id, "User create returned another value");
40 isnt($o->id, $id, "And it is different from the previous one");
41
42 # Searches in general
43 my $collection = Transports::Model::UserCollection->new(current_user => $system_user);
44 $collection->unlimit;
45 is($collection->count, $bootstrap_users + 2, "Finds two records");
46
47 # Searches in specific
48 $collection->limit(column => 'id', value => $o->id);
49 is($collection->count, 1, "Finds one record with specific id");
50
51 # Delete one of them
52 $o->delete;
53 $collection->redo_search;
54 is($collection->count, 0, "Deleted row is gone");
55
56 # And the other one is still there
57 $collection->unlimit;
58 is($collection->count, $bootstrap_users + 1, "Still one left");
59

  ViewVC Help
Powered by ViewVC 1.1.26