/[Arh]/t/00-model-Unit.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

Diff of /t/00-model-Unit.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8 by dpavlin, Thu Nov 29 00:40:32 2007 UTC revision 9 by dpavlin, Thu Nov 29 16:40:10 2007 UTC
# Line 17  use_ok('Arh::Model::Unit'); Line 17  use_ok('Arh::Model::Unit');
17  my $system_user = Arh::CurrentUser->superuser;  my $system_user = Arh::CurrentUser->superuser;
18  ok($system_user, "Found a system user");  ok($system_user, "Found a system user");
19    
20    my $place = Arh::Model::Place->new;
21    $place->create(
22            name => 'mjesto iskapanja',
23    );
24    
25    my $campaign = Arh::Model::Campaign->new(current_user => $system_user);
26    $campaign->create(
27            place => $place,
28            name => 'prvo iskapanje',
29            date_from => '2007-11-28',
30            date_to => '2008-03-15',
31    );
32    
33  # Try testing a create  # Try testing a create
34  my $o = Arh::Model::Unit->new(current_user => $system_user);  my $o = Arh::Model::Unit->new(current_user => $system_user);
35  my ($id) = $o->create(  my ($id) = $o->create(
36          name => 'test unit',          name => 'test unit',
37          number => 'TEST42',          number => 'TEST42',
38            campaign => $campaign,
39  );  );
40  ok($id, "Unit create returned success");  ok($id, "Unit create returned success");
41  ok($o->id, "New Unit has valid id set");  ok($o->id, "New Unit has valid id set");
# Line 31  is($o->id, $id, "Create returned the rig Line 45  is($o->id, $id, "Create returned the rig
45  $o->create(  $o->create(
46          name => 'unit 2',          name => 'unit 2',
47          number => 'TEST2',          number => 'TEST2',
48            campaign => $campaign,
49  );  );
50  ok($o->id, "Unit create returned another value");  ok($o->id, "Unit create returned another value");
51  isnt($o->id, $id, "And it is different from the previous one");  isnt($o->id, $id, "And it is different from the previous one");
# Line 38  isnt($o->id, $id, "And it is different f Line 53  isnt($o->id, $id, "And it is different f
53  # Searches in general  # Searches in general
54  my $collection =  Arh::Model::UnitCollection->new(current_user => $system_user);  my $collection =  Arh::Model::UnitCollection->new(current_user => $system_user);
55  $collection->unlimit;  $collection->unlimit;
56  is($collection->count, 2, "Finds two records");  is($collection->count, 3, "Finds 3 records");
57    
58  # Searches in specific  # Searches in specific
59  $collection->limit(column => 'id', value => $o->id);  $collection->limit(column => 'id', value => $o->id);
# Line 51  is($collection->count, 0, "Deleted row i Line 66  is($collection->count, 0, "Deleted row i
66    
67  # And the other one is still there  # And the other one is still there
68  $collection->unlimit;  $collection->unlimit;
69  is($collection->count, 1, "Still one left");  is($collection->count, 2, "Still 2 left");
70    

Legend:
Removed from v.8  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26