From 5222d83a988103d78a2dd32b11ca2e1306a156f9 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 28 Jul 2016 15:29:22 +0200 Subject: [PATCH] =?utf8?q?Test=20f=C3=BCr=20Erzeugnisse=20per=20Rose=20ers?= =?utf8?q?tellen=20erweitert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- t/part/assembly.t | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) 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; -- 2.20.1