Bugzilla – Attachment 182868 Details for
Bug 40018
Remove warning from Koha/Template/Plugin/Koha.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40018: Remove warnings from Koha/Template/Plugin/Koha.t
Bug-40018-Remove-warnings-from-KohaTemplatePluginK.patch (text/plain), 2.65 KB, created by
David Nind
on 2025-05-30 21:48:51 UTC
(
hide
)
Description:
Bug 40018: Remove warnings from Koha/Template/Plugin/Koha.t
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-05-30 21:48:51 UTC
Size:
2.65 KB
patch
obsolete
>From 1bc8726cd8f52ace22d91bc938dc775621b7da0a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 28 May 2025 16:37:45 +0200 >Subject: [PATCH] Bug 40018: Remove warnings from Koha/Template/Plugin/Koha.t > >Because we still use CGI::Session (bug 17427), we need to mock >CGI::Session to remove those 2 warnings >rollback ineffective with AutoCommit enabled > >Test plan: >Run the tests after this patch, it should be green > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/Template/Plugin/Koha.t | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/Koha/Template/Plugin/Koha.t b/t/db_dependent/Koha/Template/Plugin/Koha.t >index 4cb1de7e8a..91cfed59a7 100755 >--- a/t/db_dependent/Koha/Template/Plugin/Koha.t >+++ b/t/db_dependent/Koha/Template/Plugin/Koha.t >@@ -17,10 +17,12 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use Template::Context; > use Template::Stash; >+use Test::MockModule; >+use Test::NoWarnings; > > use C4::Auth; > use Koha::Cache::Memory::Lite; >@@ -29,22 +31,26 @@ use Koha::Template::Plugin::Koha; > > my $schema = Koha::Database->new->schema; > >+my $session_id = 42; >+my $cgi_session = Test::MockModule->new('CGI::Session'); >+$cgi_session->mock( 'load', sub { return bless { id => $session_id }, 'CGI::Session' } ); >+$cgi_session->mock( 'new', sub { return bless { id => $session_id }, 'CGI::Session' } ); >+$cgi_session->mock( 'param', sub { return $session_id } ); >+ > subtest 'GenerateCSRF() tests' => sub { > > plan tests => 1; > > $schema->storage->txn_begin; > >- my $session = C4::Auth::get_session(''); >- >- my $stash = Template::Stash->new( { sessionID => $session->id } ); >+ my $stash = Template::Stash->new( { sessionID => $session_id } ); > my $context = Template::Context->new( { STASH => $stash } ); > > my $plugin = Koha::Template::Plugin::Koha->new($context); > > my $token = $plugin->GenerateCSRF(); > >- ok( Koha::Token->new->check_csrf( { session_id => $session->id, token => $token } ) ); >+ ok( Koha::Token->new->check_csrf( { session_id => $session_id, token => $token } ) ); > > $schema->storage->txn_rollback; > }; >@@ -54,9 +60,7 @@ subtest 'GenerateCSRF - New CSRF token generated every time we need one' => sub > > $schema->storage->txn_begin; > >- my $session = C4::Auth::get_session(''); >- >- my $stash = Template::Stash->new( { sessionID => $session->id } ); >+ my $stash = Template::Stash->new( { sessionID => $session_id } ); > my $context = Template::Context->new( { STASH => $stash } ); > > my $plugin = Koha::Template::Plugin::Koha->new($context); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40018
:
182822
|
182823
| 182868