Tests: Template-Objekt aus Presenter in eigenes Verzeichnis cachen lassen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 27 Feb 2017 15:44:20 +0000 (16:44 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 27 Feb 2017 16:22:34 +0000 (17:22 +0100)
t/Support/TestSetup.pm
t/controllers/base/render.t

index 5a1e42f..6937b2e 100644 (file)
@@ -34,7 +34,7 @@ sub login {
   die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client);
 
   $::instance_conf = SL::InstanceConfiguration->new;
-  $::request       = SL::Request->new( cgi => CGI->new({}), layout => SL::Layout::None->new );
+  $::request       = Support::TestSetup->create_new_request;
 
   die 'cannot reach auth db'               unless $::auth->session_tables_present;
 
@@ -52,10 +52,20 @@ sub login {
   return 1;
 }
 
-sub create_new_form {
-  my $form = Form->new('');
-  $form->template(Template->new(template_config())) || die;
-  return $form;
+sub create_new_form { Form->new('') }
+
+sub create_new_request {
+  my $self = shift;
+
+  my $request = SL::Request->new(
+    cgi    => CGI->new({}),
+    layout => SL::Layout::None->new,
+    @_,
+  );
+
+  $request->presenter->{template} = Template->new(template_config()) || die;
+
+  return $request;
 }
 
 sub template_config {
index 753c1cb..b9ce240 100644 (file)
@@ -17,8 +17,7 @@ Support::TestSetup::login();
 sub reset_test_env {
   $ENV{HTTP_USER_AGENT} = 'Perl Tests';
 
-  $::request       = SL::Request->new(
-    cgi => CGI->new({}),
+  $::request = Support::TestSetup->create_new_request(
     layout => SL::Layout::Javascript->new,
   );