Tests: $::form nur über Helfermethode Support::TestSetup::create_new_form anlege
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 10 Feb 2017 15:09:13 +0000 (16:09 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 10 Feb 2017 15:09:13 +0000 (16:09 +0100)
Diese Helfermethode erstellt und konfiguriert auch gleich das
Template-Objekt mit dem Pfad zum Test-eigenen
Template-Cache-Verzeichnis.

t/000setup_database.t
t/Support/TestSetup.pm
t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t
t/controllers/financial_overview/sales_orders.t

index e5031d1..f61c8a3 100755 (executable)
@@ -14,6 +14,7 @@ use SL::InstanceConfiguration;
 use SL::LXDebug;
 use SL::Layout::None;
 use SL::LxOfficeConf;
+use Support::TestSetup;
 
 our ($db_cfg, $dbh);
 
@@ -51,7 +52,7 @@ sub setup {
   $::lxdebug       = LXDebug->new(target => LXDebug::STDERR_TARGET);
   $::lxdebug->disable_sub_tracing;
   $::locale        = Locale->new($::lx_office_conf{system}->{language});
-  $::form          = Form->new;
+  $::form          = Support::TestSetup->create_new_form;
   $::auth          = SL::Auth->new(unit_tests_database => 1);
   $::locale        = Locale->new('de');
   $::instance_conf = SL::InstanceConfiguration->new;
index 2894cbb..5a1e42f 100644 (file)
@@ -29,7 +29,7 @@ sub login {
   $::lxdebug       = LXDebug->new(target => LXDebug::STDERR_TARGET);
   $::lxdebug->disable_sub_tracing;
   $::locale        = Locale->new($::lx_office_conf{system}->{language});
-  $::form          = Form->new;
+  $::form          = Support::TestSetup->create_new_form;
   $::auth          = SL::Auth->new(unit_tests_database => 1);
   die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client);
 
@@ -48,13 +48,14 @@ sub login {
 
   $SIG{__DIE__} = sub { Carp::confess( @_ ) } if $::lx_office_conf{debug}->{backtrace_on_die};
 
-  Support::TestSetup::create_form_template_provider();
 
   return 1;
 }
 
-sub create_form_template_provider {
-  $::form->template(Template->new(template_config())) || die;
+sub create_new_form {
+  my $form = Form->new('');
+  $form->template(Template->new(template_config())) || die;
+  return $form;
 }
 
 sub template_config {
index 943666d..30cf323 100644 (file)
@@ -101,7 +101,7 @@ sub create_sales_order {
 
   ok($order->save(cascade => 1));
 
-  $::form = Form->new('');
+  $::form = Support::TestSetup->create_new_form;
   $ctrl   = SL::Controller::FinancialControllingReport->new;
 
   $ctrl->orders($ctrl->models->get);
index cfa4ad5..abfcf7e 100644 (file)
@@ -105,7 +105,7 @@ sub create_sales_order {
 
   ok($order->save(cascade => 1));
 
-  $::form         = Form->new('');
+  $::form         = Support::TestSetup->create_new_form;
   $::form->{year} = 2014;
   $ctrl           = SL::Controller::FinancialOverview->new;