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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (hide annotations)
Fri May 26 21:21:25 2006 UTC (18 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1324 byte(s)
added admin column to users, better bootstrap data
1 dpavlin 1 #!/usr/bin/perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the Source model.
8    
9     =cut
10    
11     use Jifty::Test tests => 11;
12    
13 dpavlin 27 my $nr = 6;
14    
15 dpavlin 1 # Make sure we can load the model
16     use_ok('Transports::Model::Source');
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::Source->new(current_user => $system_user);
24 dpavlin 6 my ($id) = $o->create( name => 'src1' );
25 dpavlin 1 ok($id, "Source create returned success");
26     ok($o->id, "New Source has valid id set");
27     is($o->id, $id, "Create returned the right id");
28    
29     # And another
30 dpavlin 6 $o->create( name => 'src2' );
31 dpavlin 1 ok($o->id, "Source 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::SourceCollection->new(current_user => $system_user);
36     $collection->unlimit;
37 dpavlin 27 is($collection->count, $nr + 2, "Finds two records");
38 dpavlin 1
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 27 is($collection->count, $nr + 1, "Still one left");
51 dpavlin 1

  ViewVC Help
Powered by ViewVC 1.1.26