/[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 28 by dpavlin, Mon Dec 10 14:56:12 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 => 16;
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');
15    use_ok('Arh::Test');
16    
17  # Grab a system user  # Grab a system user
18  my $system_user = Arh::CurrentUser->superuser;  my $system_user = Arh::CurrentUser->superuser;
19  ok($system_user, "Found a system user");  ok($system_user, "Found a system user");
20    
21    ok( my $unit = Arh::Test->Unit, 'Unit' );
22    
23    ok( my $material = Arh::Model::Material->new, 'Material' );
24    ok( $material->create(
25            name => 'test material',
26    ), 'create' );
27    
28  # Try testing a create  # Try testing a create
29  my $o = Arh::Model::UnitMaterial->new(current_user => $system_user);  my $o = Arh::Model::UnitMaterial->new(current_user => $system_user);
30  my ($id) = $o->create();  my ($id) = $o->create(
31            unit => $unit,
32            material => $material,
33    );
34  ok($id, "UnitMaterial create returned success");  ok($id, "UnitMaterial create returned success");
35  ok($o->id, "New UnitMaterial has valid id set");  ok($o->id, "New UnitMaterial has valid id set");
36  is($o->id, $id, "Create returned the right id");  is($o->id, $id, "Create returned the right id");
37    
38    ok( $material->create( name => 'another' ), 'another material' );
39    
40  # And another  # And another
41  $o->create();  $o->create(
42            unit => $unit,
43            material => $material,
44    );
45  ok($o->id, "UnitMaterial create returned another value");  ok($o->id, "UnitMaterial create returned another value");
46  isnt($o->id, $id, "And it is different from the previous one");  isnt($o->id, $id, "And it is different from the previous one");
47    
48  # Searches in general  # Searches in general
49  my $collection =  Arh::Model::UnitMaterialCollection->new(current_user => $system_user);  my $collection =  Arh::Model::UnitMaterialCollection->new(current_user => $system_user);
50  $collection->unlimit;  $collection->unlimit;
51  is($collection->count, 2, "Finds two records");  is($collection->count, 5, "Finds 5 records");
52    
53  # Searches in specific  # Searches in specific
54  $collection->limit(column => 'id', value => $o->id);  $collection->limit(column => 'id', value => $o->id);
# Line 45  is($collection->count, 0, "Deleted row i Line 61  is($collection->count, 0, "Deleted row i
61    
62  # And the other one is still there  # And the other one is still there
63  $collection->unlimit;  $collection->unlimit;
64  is($collection->count, 1, "Still one left");  is($collection->count, 4, "Still 4 left");
65    

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

  ViewVC Help
Powered by ViewVC 1.1.26