From 3b031ce5109523b62dfd84cb54be9955b5ceefe1 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 Just a small beginning.. Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Lucas Gass (cherry picked from commit 6cc683b518223479f0c427a8305071fbd9581b5e) Signed-off-by: Paul Derscheid --- 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 +};