From 57979f2b02af9816cbe918e2edef56615749f8d3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 23 Apr 2025 17:08:11 +0200 Subject: [PATCH] Bug 34776: Unit tests Content-Type: text/plain; charset=utf-8 Just a small beginning.. --- t/Form_MessagingPreferences.t | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/t/Form_MessagingPreferences.t b/t/Form_MessagingPreferences.t index 40a68dd402..fd1d5fee7b 100755 --- a/t/Form_MessagingPreferences.t +++ b/t/Form_MessagingPreferences.t @@ -1,15 +1,26 @@ #!/usr/bin/perl -# -# This Koha test module is a stub! -# Add more tests here!!! -use strict; -use warnings; +use Modern::Perl; +use CGI; +use Template; -use Test::NoWarnings; -use Test::More tests => 2; +use Test::More tests => 1; +use Test::MockModule; +#use Test::NoWarnings; -BEGIN { - use_ok('C4::Form::MessagingPreferences'); -} +use C4::Form::MessagingPreferences; +subtest 'restore_values' => sub { + plan tests => 1; + my $cgi = CGI->new; + my $template_module = Test::MockModule->new( 'Template' ); + my $vars = {}; + $template_module->mock( 'param', sub { my ( $self, $key, $val ) = @_; $vars->{$key} = $val; } ); + my $template = Template->new( ENCODING => 'UTF-8' ); + + C4::Form::MessagingPreferences::restore_form_values( $cgi, $template ); + require Data::Dumper; warn Data::Dumper::Dumper( $vars ); #FIXME Remove debugging + # TODO Add some checking on $vars->{messaging_preferences} here + + ok(1); # FIXME Replace +}; -- 2.39.5