From: G. Richardson Date: Thu, 28 Jul 2016 13:29:22 +0000 (+0200) Subject: Test für Erzeugnisse per Rose erstellen erweitert X-Git-Tag: release-3.5.4~2169 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5222d83a988103d78a2dd32b11ca2e1306a156f9;p=kivitendo-erp.git Test für Erzeugnisse per Rose erstellen erweitert --- diff --git a/t/part/assembly.t b/t/part/assembly.t index 302cffd6c..f6241c45f 100644 --- a/t/part/assembly.t +++ b/t/part/assembly.t @@ -13,12 +13,21 @@ Support::TestSetup::login(); clear_up(); reset_state(); -is( SL::DB::Manager::Part->get_all_count(), 3, "total number of parts created is 2"); +is( SL::DB::Manager::Part->get_all_count(), 3, "total number of parts created is 3"); -my $assembly = SL::DB::Manager::Part->find_by( partnumber => 'as1' ); +my $assembly_part = SL::DB::Manager::Part->find_by( partnumber => 'as1' ); +my $assembly_item_part = SL::DB::Manager::Part->find_by( partnumber => '19000' ); -is($assembly->type, 'assembly', 'assembly has correct type'); -is( scalar @{$assembly->assemblies}, 2, 'assembly consists of two parts' ); +is($assembly_part->inventory_accno_id, undef, "assembly doesn't have an inventory accno id"); + +is($assembly_part->type, 'assembly', 'assembly has correct type'); +is( scalar @{$assembly_part->assemblies}, 2, 'assembly consists of two parts' ); + +# fetch assembly item corresponding to partnumber 19000 +my $assembly_items = $assembly_part->find_assemblies( { parts_id => $assembly_item_part->id } ) || die "can't find assembly_item"; +my $assembly_item = $assembly_items->[0]; +is($assembly_item->part->partnumber, '19000', 'assembly part part relation works'); +is($assembly_item->assembly_part->partnumber, 'as1', 'assembly part assembly part relation works'); clear_up(); done_testing; @@ -42,11 +51,12 @@ sub reset_state { $part2->partnumber($part1->partnumber + 1); $part2->save; - my $assembly_part = SL::DB::Part->new_assembly(partnumber => 'as1', - description => 'assembly', - unit => $unit->name, + my $assembly_part = SL::DB::Part->new_assembly(partnumber => 'as1', + description => 'assembly', + unit => $unit->name, + inventory_accno_id => undef, # override ); - my $assembly_1 = SL::DB::Assembly->new(parts_id => $part2->id, qty => 3, bom => 1); + my $assembly_1 = SL::DB::Assembly->new(parts_id => $part1->id, qty => 3, bom => 1); my $assembly_2 = SL::DB::Assembly->new(parts_id => $part2->id, qty => 3, bom => 1); $assembly_part->add_assemblies($assembly_1, $assembly_2); $assembly_part->save;