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

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

revision 3 by dpavlin, Thu Nov 29 00:40:32 2007 UTC revision 22 by dpavlin, Fri Nov 30 20:13:06 2007 UTC
# Line 8  A basic test harness for the UnitMateria Line 8  A basic test harness for the UnitMateria
8    
9  =cut  =cut
10    
11  use Jifty::Test tests => 11;  use Jifty::Test tests => 20;
12    
13  # Make sure we can load the model  # Make sure we can load the model
14  use_ok('Arh::Model::UnitMaterial');  use_ok('Arh::Model::UnitMaterial');
# Line 17  use_ok('Arh::Model::UnitMaterial'); Line 17  use_ok('Arh::Model::UnitMaterial');
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    ok(my $place = Arh::Model::Place->new, 'Place' );
21    ok($place->create(
22            name => 'mjesto iskapanja',
23    ), 'create' );
24    
25    ok(my $campaign = Arh::Model::Campaign->new, 'Campaign' );
26    ok($campaign->create(
27            place => $place,
28            name => 'prvo iskapanje',
29            date_from => '2007-11-28',
30            date_to => '2008-03-15',
31    ), 'create' );
32    
33    ok( my $unit = Arh::Model::Unit->new, 'Unit' );
34    ok( $unit->create(
35            name => 'test unit',
36            number => 42,
37            campaign => $campaign,
38    ), 'create' );
39    
40    ok( my $material = Arh::Model::Material->new, 'Material' );
41    ok( $material->create(
42            name => 'test material',
43    ), 'create' );
44    
45  # Try testing a create  # Try testing a create
46  my $o = Arh::Model::UnitMaterial->new(current_user => $system_user);  my $o = Arh::Model::UnitMaterial->new(current_user => $system_user);
47  my ($id) = $o->create();  my ($id) = $o->create(
48            unit => $unit,
49            material => $material,
50    );
51  ok($id, "UnitMaterial create returned success");  ok($id, "UnitMaterial create returned success");
52  ok($o->id, "New UnitMaterial has valid id set");  ok($o->id, "New UnitMaterial has valid id set");
53  is($o->id, $id, "Create returned the right id");  is($o->id, $id, "Create returned the right id");
54    
55    ok( $material->create( name => 'another' ), 'another material' );
56    
57  # And another  # And another
58  $o->create();  $o->create(
59            unit => $unit,
60            material => $material,
61    );
62  ok($o->id, "UnitMaterial create returned another value");  ok($o->id, "UnitMaterial create returned another value");
63  isnt($o->id, $id, "And it is different from the previous one");  isnt($o->id, $id, "And it is different from the previous one");
64    
65  # Searches in general  # Searches in general
66  my $collection =  Arh::Model::UnitMaterialCollection->new(current_user => $system_user);  my $collection =  Arh::Model::UnitMaterialCollection->new(current_user => $system_user);
67  $collection->unlimit;  $collection->unlimit;
68  is($collection->count, 2, "Finds two records");  is($collection->count, 5, "Finds 5 records");
69    
70  # Searches in specific  # Searches in specific
71  $collection->limit(column => 'id', value => $o->id);  $collection->limit(column => 'id', value => $o->id);
# Line 45  is($collection->count, 0, "Deleted row i Line 78  is($collection->count, 0, "Deleted row i
78    
79  # And the other one is still there  # And the other one is still there
80  $collection->unlimit;  $collection->unlimit;
81  is($collection->count, 1, "Still one left");  is($collection->count, 4, "Still 4 left");
82    

Legend:
Removed from v.3  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26