Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 77061a7b

Von Kivitendo Admin vor mehr als 9 Jahren hinzugefügt

  • ID 77061a7b4a39fe5fedbc1186bf9f048e78627cde
  • Vorgänger 96326d7c
  • Nachfolger 28fee2e2

Aufräumen der DB am Ende der individuellen Tests

die Tests sollten am Ende ihre eigenen angelegten Daten löschen, damit
andere Tests beim Löschen ihrer Daten keine Abhängigkeitsprobleme
bekommen:

create_periodic_invoices.t
price_tax_calculator.t
record_links.t
sales_orders.t

Unterschiede anzeigen:

t/background_job/create_periodic_invoices.t
45 45
  $unit           = SL::DB::Manager::Unit->find_by(name => 'psch')                          || croak "No unit";
46 46
}
47 47

  
48
sub clear_up {
49
  "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part);
50
};
51

  
48 52
sub create_invoices {
49 53
  my %params = @_;
50 54

  
51 55
  $params{$_} ||= {} for qw(customer part tax order orderitem periodic_invoices_config);
52 56

  
53 57
  # Clean up: remove invoices, orders, parts and customers
54
  "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part);
58
  clear_up();
55 59

  
56 60
  $customer     = SL::DB::Customer->new(
57 61
    name        => 'Test Customer',
......
237 241
create_invoices(periodic_invoices_config => { periodicity => 'y', order_value_periodicity => '5', start_date => DateTime->from_kivitendo('01.01.2009') });
238 242
are_invoices 'p=y ovp=5',[ '01.01.2009', 66.67 ], [ '01.01.2010', 66.67 ], [ '01.01.2011', 66.67 ], [ '01.01.2012', 66.67 ], [ '01.01.2013', 66.65 ], [ '01.01.2014', 66.67 ];
239 243

  
244
clear_up();
245

  
240 246
done_testing();
t/controllers/financial_overview/sales_orders.t
37 37

  
38 38
our ($ar_chart, $buchungsgruppe, $ctrl, $currency_id, $customer, $employee, $order, $part, $tax_zone, $unit, @invoices);
39 39

  
40
sub clear_up {
41
  "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part);
42
};
43

  
40 44
sub init_common_state {
41 45
  $ar_chart       = SL::DB::Manager::Chart->find_by(accno => '1400')                        || croak "No AR chart";
42 46
  $buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group";
......
52 56
  $params{$_} ||= {} for qw(customer part tax order orderitem);
53 57

  
54 58
  # Clean up: remove invoices, orders, parts and customers
55
  "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part);
59
  clear_up();
56 60

  
57 61
  $customer     = SL::DB::Customer->new(
58 62
    name        => 'Test Customer',
......
203 207
is_deeply($ctrl->data->{$_}, { months => [ (0) x 12 ], quarters => [ 0, 0, 0, 0 ], year => 0 }, "periodic conf p=q ovp=y, no invoices, starting and ending before current year, data for $_")
204 208
  for qw(purchase_invoices purchase_orders requests_for_quotation sales_invoices sales_orders sales_orders_per_inv sales_quotations);
205 209

  
210
clear_up();
211

  
206 212
done_testing();
t/db_helper/price_tax_calculator.t
24 24

  
25 25
my ($customer, $currency_id, @parts, $buchungsgruppe, $buchungsgruppe7, $unit, $employee, $tax, $tax7, $taxzone);
26 26

  
27
sub reset_state {
28
  my %params = @_;
29

  
30
  $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax);
31

  
27
sub clear_up {
32 28
  SL::DB::Manager::Order->delete_all(all => 1);
33 29
  SL::DB::Manager::DeliveryOrder->delete_all(all => 1);
34 30
  SL::DB::Manager::Invoice->delete_all(all => 1);
35 31
  SL::DB::Manager::Part->delete_all(all => 1);
36 32
  SL::DB::Manager::Customer->delete_all(all => 1);
33
};
34

  
35
sub reset_state {
36
  my %params = @_;
37

  
38
  $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax);
39

  
40
  clear_up();
37 41

  
38 42
  $buchungsgruppe  = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%', %{ $params{buchungsgruppe} }) || croak "No accounting group";
39 43
  $buchungsgruppe7 = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 7%')                                || croak "No accounting group for 7\%";
......
376 380
test_default_invoice_two_items_19_7_tax_not_included();
377 381
test_default_invoice_three_items_sellprice_rounding_discount();
378 382

  
383
clear_up();
379 384
done_testing();
t/db_helper/record_links.t
25 25
my ($customer, $currency_id, $buchungsgruppe, $employee, $vendor, $taxzone);
26 26
my ($link, $links, $o1, $o2, $d, $i);
27 27

  
28
sub reset_state {
29
  my %params = @_;
30

  
31
  $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax);
32

  
28
sub clear_up {
33 29
  SL::DB::Manager::DeliveryOrder->delete_all(all => 1);
34 30
  SL::DB::Manager::Order->delete_all(all => 1);
35 31
  SL::DB::Manager::Invoice->delete_all(all => 1);
32
  SL::DB::Manager::Part->delete_all(all => 1);
36 33
  SL::DB::Manager::Customer->delete_all(all => 1);
37 34
  SL::DB::Manager::Vendor->delete_all(all => 1);
35
};
36

  
37
sub reset_state {
38
  my %params = @_;
39

  
40
  $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax);
41

  
42
  clear_up();
38 43

  
39 44
  $buchungsgruppe  = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%', %{ $params{buchungsgruppe} }) || croak "No accounting group";
40 45
  $employee        = SL::DB::Manager::Employee->current                                                                    || croak "No employee";
......
104 109

  
105 110
reset_state();
106 111

  
107

  
108 112
$o1 = new_order();
109 113
$i  = new_invoice();
110 114

  
......
313 317

  
314 318
$links = $o1->linked_records(direction => 'both', recursive => 1, save_path => 1);
315 319
is @$links, 4, 'recursive dir=both does not give duplicates';
320

  
321
clear_up();
322

  
316 323
1;

Auch abrufbar als: Unified diff