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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide annotations)
Fri May 5 12:36:45 2006 UTC (18 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1755 byte(s)
test transport model
1 dpavlin 1 #!/usr/bin/perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the Transport model.
8    
9     =cut
10    
11 dpavlin 7 use Jifty::Test tests => 13;
12 dpavlin 1
13     # Make sure we can load the model
14     use_ok('Transports::Model::Transport');
15    
16     # Grab a system use
17     my $system_user = Transports::CurrentUser->superuser;
18     ok($system_user, "Found a system user");
19    
20 dpavlin 7 my $s = Transports::Model::Source->new(current_user => $system_user);
21     ok(my $s_id = $s->create( name => 'test source' ), 'test source');
22    
23     my $d = Transports::Model::Destination->new(current_user => $system_user);
24     ok(my $d_id = $s->create( name => 'test destination' ), 'test destination');
25    
26 dpavlin 1 # Try testing a create
27     my $o = Transports::Model::Transport->new(current_user => $system_user);
28 dpavlin 7 my ($id) = $o->create(
29     source => $s_id,
30     destination => $d_id,
31     request_nr => 12345,
32     client_dependent => 0,
33     );
34 dpavlin 1 ok($id, "Transport create returned success");
35     ok($o->id, "New Transport has valid id set");
36     is($o->id, $id, "Create returned the right id");
37    
38     # And another
39 dpavlin 7 $o->create(
40     source => $s_id,
41     destination => $d_id,
42     request_nr => 54321,
43     client_dependent => 1,
44     );
45 dpavlin 1 ok($o->id, "Transport create returned another value");
46     isnt($o->id, $id, "And it is different from the previous one");
47    
48     # Searches in general
49     my $collection = Transports::Model::TransportCollection->new(current_user => $system_user);
50     $collection->unlimit;
51     is($collection->count, 2, "Finds two records");
52    
53     # Searches in specific
54     $collection->limit(column => 'id', value => $o->id);
55     is($collection->count, 1, "Finds one record with specific id");
56    
57     # Delete one of them
58     $o->delete;
59     $collection->redo_search;
60     is($collection->count, 0, "Deleted row is gone");
61    
62     # And the other one is still there
63     $collection->unlimit;
64     is($collection->count, 1, "Still one left");
65    

  ViewVC Help
Powered by ViewVC 1.1.26