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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 52 - (hide annotations)
Mon Jun 5 14:08:58 2006 UTC (17 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1350 byte(s)
fix test
1 dpavlin 46 #!/usr/bin/perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the ReturnCode model.
8    
9     =cut
10    
11     use Jifty::Test tests => 11;
12    
13 dpavlin 52 my $nr = 4;
14    
15 dpavlin 46 # Make sure we can load the model
16     use_ok('Transports::Model::ReturnCode');
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::ReturnCode->new(current_user => $system_user);
24 dpavlin 52 my ($id) = $o->create( name => 'foo' );
25 dpavlin 46 ok($id, "ReturnCode create returned success");
26     ok($o->id, "New ReturnCode has valid id set");
27     is($o->id, $id, "Create returned the right id");
28    
29     # And another
30 dpavlin 52 $o->create( name => 'bar' );
31 dpavlin 46 ok($o->id, "ReturnCode create returned another value");
32     isnt($o->id, $id, "And it is different from the previous one");
33    
34     # Searches in general
35     my $collection = Transports::Model::ReturnCodeCollection->new(current_user => $system_user);
36     $collection->unlimit;
37 dpavlin 52 is($collection->count, $nr + 2, "Finds two records");
38 dpavlin 46
39     # Searches in specific
40     $collection->limit(column => 'id', value => $o->id);
41     is($collection->count, 1, "Finds one record with specific id");
42    
43     # Delete one of them
44     $o->delete;
45     $collection->redo_search;
46     is($collection->count, 0, "Deleted row is gone");
47    
48     # And the other one is still there
49     $collection->unlimit;
50 dpavlin 52 is($collection->count, $nr + 1, "Still one left");
51 dpavlin 46

  ViewVC Help
Powered by ViewVC 1.1.26