Revision e3b5a9ce
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
t/wh/transfer.t | ||
---|---|---|
4 | 4 |
use lib 't'; |
5 | 5 |
|
6 | 6 |
use_ok 'Support::TestSetup'; |
7 |
use_ok 'SL::DB::Bin'; |
|
7 | 8 |
use_ok 'SL::DB::Part'; |
8 | 9 |
use_ok 'SL::DB::Warehouse'; |
9 | 10 |
use_ok 'SL::WH'; |
10 | 11 |
|
11 | 12 |
use_ok('SL::DB::Inventory'); |
12 | 13 |
|
14 |
use constant NAME => 'UnitTestObject'; |
|
13 | 15 |
|
14 | 16 |
Support::TestSetup::login(); |
15 | 17 |
|
16 |
my $part = SL::DB::Part->new(unit => 'mg', description => 'TestObject'); |
|
18 |
# Clean up: remove test objects for part, warehouse, bin |
|
19 |
my $part = SL::DB::Manager::Part->get_first(partnumber => NAME(), description => NAME()); |
|
20 |
if ($part) { |
|
21 |
SL::DB::Manager::Inventory->delete_all(where => [ parts_id => $part->id ]); |
|
22 |
$part->delete; |
|
23 |
} |
|
24 |
|
|
25 |
SL::DB::Manager::Bin ->delete_all(where => [ or => [ description => NAME() . "1", description => NAME() . "2" ] ]); |
|
26 |
SL::DB::Manager::Warehouse->delete_all(where => [ description => NAME() ]); |
|
27 |
|
|
28 |
# Create test data |
|
29 |
$part = SL::DB::Part->new(unit => 'mg', description => NAME(), partnumber => NAME()); |
|
17 | 30 |
$part->save(); |
18 | 31 |
|
19 | 32 |
is(ref($part), 'SL::DB::Part', 'loading a part to test with id ' . $part->id); |
20 | 33 |
|
21 |
|
|
22 |
my $wh = SL::DB::Manager::Warehouse->get_first;
|
|
34 |
my $wh = SL::DB::Warehouse->new(description => NAME(), invalid => 0); |
|
35 |
$wh->save;
|
|
23 | 36 |
is(ref $wh, 'SL::DB::Warehouse', 'loading a warehouse to test with id ' . $wh->id); |
24 | 37 |
|
25 |
my $bin1 = $wh->bins->[0]; |
|
38 |
my $bin1 = SL::DB::Bin->new(description => NAME() . "1", warehouse_id => $wh->id); |
|
39 |
$bin1->save; |
|
26 | 40 |
is(ref $bin1, 'SL::DB::Bin', 'getting first bin to test with id ' . $bin1->id); |
27 | 41 |
|
28 |
my $bin2 = $wh->bins->[1]; |
|
42 |
my $bin2 = SL::DB::Bin->new(description => NAME() . "2", warehouse_id => $wh->id); |
|
43 |
$bin2->save; |
|
29 | 44 |
is(ref $bin2, 'SL::DB::Bin', 'getting another bin to test with id ' . $bin2->id); |
30 | 45 |
|
31 | 46 |
my $report = sub { |
... | ... | |
160 | 175 |
|
161 | 176 |
SL::DB::Manager::Inventory->delete_objects(where => [parts_id => $part->id]); |
162 | 177 |
|
163 |
$part->delete(); |
|
178 |
$bin1->delete; |
|
179 |
$bin2->delete; |
|
180 |
$wh->delete; |
|
181 |
$part->delete; |
|
164 | 182 |
|
165 | 183 |
done_testing; |
166 | 184 |
|
Auch abrufbar als: Unified diff
t/wh/transfer.t: Für leere DB fit gemacht
Artikel, Lager und Lagerplatz werden vorher bereinigt, angelegt und
hinterher bereinigt.