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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51 - (hide annotations)
Mon Jun 5 14:06:58 2006 UTC (17 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1399 byte(s)
added landscapes (collection of source and destination clients) to the mix
instead of specifing users for sources (and destinations which wasn't
implemented anyway)
1 dpavlin 1 #!/usr/bin/perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the Destination model.
8    
9     =cut
10    
11     use Jifty::Test tests => 11;
12    
13 dpavlin 27 my $nr = 3;
14    
15 dpavlin 1 # Make sure we can load the model
16     use_ok('Transports::Model::Destination');
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::Destination->new(current_user => $system_user);
24 dpavlin 51 my ($id) = $o->create(
25     name => 'dest1',
26     landscape => 1,
27     );
28 dpavlin 1 ok($id, "Destination create returned success");
29     ok($o->id, "New Destination has valid id set");
30     is($o->id, $id, "Create returned the right id");
31    
32     # And another
33 dpavlin 51 $o->create(
34     name => 'dest2',
35     landscape => 2,
36     );
37 dpavlin 1 ok($o->id, "Destination 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::DestinationCollection->new(current_user => $system_user);
42     $collection->unlimit;
43 dpavlin 27 is($collection->count, $nr + 2, "Finds two records");
44 dpavlin 1
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 dpavlin 27 is($collection->count, $nr + 1, "Still one left");
57 dpavlin 1

  ViewVC Help
Powered by ViewVC 1.1.26