Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8aea132f

Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt

  • ID 8aea132fabed254fd0f47d58a1a4b136308bc1d4
  • Vorgänger d8381bdd
  • Nachfolger 98625cb1

Test für Erzeugnisse

Unterschiede anzeigen:

t/part/assembly.t
1
use strict;
2
use Test::More;
3

  
4
use lib 't';
5
use Support::TestSetup;
6
use Test::Exception;
7
use SL::DB::Unit;
8
use SL::DB::Part;
9
use SL::DB::Assembly;
10

  
11
Support::TestSetup::login();
12

  
13
clear_up();
14
reset_state();
15

  
16
is( SL::DB::Manager::Part->get_all_count(), 3,  "total number of parts created is 2");
17

  
18
my $assembly = SL::DB::Manager::Part->find_by( partnumber => 'as1' );
19

  
20
is($assembly->type, 'assembly', 'assembly has correct type');
21
is( scalar @{$assembly->assemblies}, 2, 'assembly consists of two parts' );
22

  
23
clear_up();
24
done_testing;
25

  
26
sub clear_up {
27
  SL::DB::Manager::Assembly->delete_all(all => 1);
28
  SL::DB::Manager::Part->delete_all(    all => 1);
29
};
30

  
31
sub reset_state {
32
  my %params = @_;
33

  
34
  # create an assembly that consists of two parts
35
  my ($part1, $part2, $unit, $assembly_part, $assembly_1, $assembly_2);
36
  my $unit = SL::DB::Manager::Unit->find_by(name => 'Stck') || die "Can't find unit 'Stck'";
37

  
38
  $part1 = SL::DB::Part->new_part(partnumber => '19000',
39
                                  unit       => $unit->name,
40
                                 )->save;
41
  $part2 = $part1->clone_and_reset($part1);
42
  $part2->partnumber($part1->partnumber + 1);
43
  $part2->save;
44

  
45
  my $assembly_part = SL::DB::Part->new_assembly(partnumber  => 'as1',
46
                                                 description => 'assembly',
47
                                                 unit        => $unit->name,
48
                                                );
49
  my $assembly_1 = SL::DB::Assembly->new(parts_id => $part2->id, qty => 3, bom => 1);
50
  my $assembly_2 = SL::DB::Assembly->new(parts_id => $part2->id, qty => 3, bom => 1);
51
  $assembly_part->add_assemblies($assembly_1, $assembly_2);
52
  $assembly_part->save;
53
};
54

  
55
1;

Auch abrufbar als: Unified diff