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

Annotation of /t/00-model-UnitMaterial.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (hide annotations)
Mon Dec 10 14:56:12 2007 UTC (16 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1620 byte(s)
added UnitPicture model, first try at user interface for it
1 dpavlin 3 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the UnitMaterial model.
8    
9     =cut
10    
11 dpavlin 27 use Jifty::Test tests => 16;
12 dpavlin 3
13     # Make sure we can load the model
14     use_ok('Arh::Model::UnitMaterial');
15 dpavlin 27 use_ok('Arh::Test');
16 dpavlin 3
17     # Grab a system user
18     my $system_user = Arh::CurrentUser->superuser;
19     ok($system_user, "Found a system user");
20    
21 dpavlin 28 ok( my $unit = Arh::Test->Unit, 'Unit' );
22 dpavlin 22
23     ok( my $material = Arh::Model::Material->new, 'Material' );
24     ok( $material->create(
25     name => 'test material',
26     ), 'create' );
27    
28 dpavlin 3 # Try testing a create
29     my $o = Arh::Model::UnitMaterial->new(current_user => $system_user);
30 dpavlin 22 my ($id) = $o->create(
31     unit => $unit,
32     material => $material,
33     );
34 dpavlin 3 ok($id, "UnitMaterial create returned success");
35     ok($o->id, "New UnitMaterial has valid id set");
36     is($o->id, $id, "Create returned the right id");
37    
38 dpavlin 22 ok( $material->create( name => 'another' ), 'another material' );
39    
40 dpavlin 3 # And another
41 dpavlin 22 $o->create(
42     unit => $unit,
43     material => $material,
44     );
45 dpavlin 3 ok($o->id, "UnitMaterial create returned another value");
46     isnt($o->id, $id, "And it is different from the previous one");
47    
48     # Searches in general
49     my $collection = Arh::Model::UnitMaterialCollection->new(current_user => $system_user);
50     $collection->unlimit;
51 dpavlin 14 is($collection->count, 5, "Finds 5 records");
52 dpavlin 3
53     # Searches in specific
54     $collection->limit(column => 'id', value => $o->id);
55     is($collection->count, 1, "Finds one record with specific id");
56    
57     # Delete one of them
58     $o->delete;
59     $collection->redo_search;
60     is($collection->count, 0, "Deleted row is gone");
61    
62     # And the other one is still there
63     $collection->unlimit;
64 dpavlin 14 is($collection->count, 4, "Still 4 left");
65 dpavlin 3

  ViewVC Help
Powered by ViewVC 1.1.26