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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Fri Nov 30 23:23:14 2007 UTC (11 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2010 byte(s)
another huge code dump:
- rename database columns to prevent conficts with standards
- added editing accessor to user which returns edit mode
- ToggleEdit action to change editing state (broken)
- tweaks all over templates to make units entry a breeze
- version bump [0.03]
1 #!/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 use Jifty::Test tests => 20;
12
13 # Make sure we can load the model
14 use_ok('Arh::Model::UnitMaterial');
15
16 # Grab a system user
17 my $system_user = Arh::CurrentUser->superuser;
18 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 inv_id => 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
46 my $o = Arh::Model::UnitMaterial->new(current_user => $system_user);
47 my ($id) = $o->create(
48 unit => $unit,
49 material => $material,
50 );
51 ok($id, "UnitMaterial create returned success");
52 ok($o->id, "New UnitMaterial has valid id set");
53 is($o->id, $id, "Create returned the right id");
54
55 ok( $material->create( name => 'another' ), 'another material' );
56
57 # And another
58 $o->create(
59 unit => $unit,
60 material => $material,
61 );
62 ok($o->id, "UnitMaterial create returned another value");
63 isnt($o->id, $id, "And it is different from the previous one");
64
65 # Searches in general
66 my $collection = Arh::Model::UnitMaterialCollection->new(current_user => $system_user);
67 $collection->unlimit;
68 is($collection->count, 5, "Finds 5 records");
69
70 # Searches in specific
71 $collection->limit(column => 'id', value => $o->id);
72 is($collection->count, 1, "Finds one record with specific id");
73
74 # Delete one of them
75 $o->delete;
76 $collection->redo_search;
77 is($collection->count, 0, "Deleted row is gone");
78
79 # And the other one is still there
80 $collection->unlimit;
81 is($collection->count, 4, "Still 4 left");
82

  ViewVC Help
Powered by ViewVC 1.1.26