From a75e82bb7ee5f5e0fbad4272962841c92561495c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 16 Aug 2021 15:17:24 +0200 Subject: [PATCH] Bug 24387: Fix Letters/TemplateToolkit.t We must cast to date or the comparison does not work --- Koha/AdditionalContents.pm | 4 ++-- t/db_dependent/Letters/TemplateToolkit.t | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm index fa32aa6318a..a631862b9bc 100644 --- a/Koha/AdditionalContents.pm +++ b/Koha/AdditionalContents.pm @@ -72,8 +72,8 @@ sub search_for_display { my $search_params; $search_params->{location} = $params->{location}; $search_params->{branchcode} = [ $params->{library_id}, undef ] if $params->{library_id}; - $search_params->{published_on} = { '<=' => \'NOW()' }; - $search_params->{-or} = [ expirationdate => { '>=' => \'NOW()' }, + $search_params->{published_on} = { '<=' => \'CAST(NOW() AS DATE)' }; + $search_params->{-or} = [ expirationdate => { '>=' => \'CAST(NOW() AS DATE)' }, expirationdate => undef ]; if ( $params->{lang} ) { diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t index 0aa71f2e74d..04658e78999 100755 --- a/t/db_dependent/Letters/TemplateToolkit.t +++ b/t/db_dependent/Letters/TemplateToolkit.t @@ -39,7 +39,7 @@ use Koha::Biblio; use Koha::Biblioitem; use Koha::Item; use Koha::Hold; -use Koha::AdditionalContent; +use Koha::AdditionalContents; use Koha::Serial; use Koha::Subscription; use Koha::Suggestion; @@ -631,16 +631,21 @@ EOF my $branchcode = $library->{branchcode}; Koha::AdditionalContents->delete; - my $news_item = Koha::AdditionalContent->new( + my $news_item = $builder->build_object( { - branchcode => $branchcode, - title => "A wonderful news", - content => "This is the wonderful news.", - lang => "slip", - expiration_date => undef, - published_on => $one_minute_ago + class => 'Koha::AdditionalContents', + value => { + category => 'news', + location => "slip", + branchcode => $branchcode, + lang => 'default', + title => "A wonderful news", + content => "This is the wonderful news.", + expiration_date => undef, + published_on => $one_minute_ago + } } - )->store; + ); # historic syntax my $template = <