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'); |
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 |
|
|