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

Contents of /trunk/t/00-model-Transport.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: 1842 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 Transport model.
8
9 =cut
10
11 use Jifty::Test tests => 13;
12
13 my $nr = 7;
14
15 # Make sure we can load the model
16 use_ok('Transports::Model::Transport');
17
18 # Grab a system use
19 my $system_user = Transports::CurrentUser->superuser;
20 ok($system_user, "Found a system user");
21
22 my $s = Transports::Model::Source->new(current_user => $system_user);
23 ok(my $s_id = $s->create( name => 'test source' ), 'test source');
24
25 my $d = Transports::Model::Destination->new(current_user => $system_user);
26 ok(my $d_id = $s->create( name => 'test destination' ), 'test destination');
27
28 # Try testing a create
29 my $o = Transports::Model::Transport->new(current_user => $system_user);
30 my ($id) = $o->create(
31 class => 1,
32 source => $s_id,
33 destination => $d_id,
34 request_nr => 12345,
35 client_dependent => 0,
36 created_by => 1,
37 );
38 ok($id, "Transport create returned success");
39 ok($o->id, "New Transport has valid id set");
40 is($o->id, $id, "Create returned the right id");
41
42 # And another
43 $o->create(
44 class => 2,
45 source => $s_id,
46 destination => $d_id,
47 request_nr => 54321,
48 client_dependent => 1,
49 created_by => 1,
50 );
51 ok($o->id, "Transport create returned another value");
52 isnt($o->id, $id, "And it is different from the previous one");
53
54 # Searches in general
55 my $collection = Transports::Model::TransportCollection->new(current_user => $system_user);
56 $collection->unlimit;
57 is($collection->count, $nr + 2, "Finds two records");
58
59 # Searches in specific
60 $collection->limit(column => 'id', value => $o->id);
61 is($collection->count, 1, "Finds one record with specific id");
62
63 # Delete one of them
64 $o->delete;
65 $collection->redo_search;
66 is($collection->count, 0, "Deleted row is gone");
67
68 # And the other one is still there
69 $collection->unlimit;
70 is($collection->count, $nr + 1, "Still one left");
71

  ViewVC Help
Powered by ViewVC 1.1.26