Bugzilla – Attachment 194897 Details for
Bug 20956
BorrowersLog is not logging permission changes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20956: Fix test failures
794cfbe.patch (text/plain), 7.50 KB, created by
Lisette Scheer
on 2026-03-06 18:44:59 UTC
(
hide
)
Description:
Bug 20956: Fix test failures
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2026-03-06 18:44:59 UTC
Size:
7.50 KB
patch
obsolete
>From 794cfbe5055a21caedc7b9fc8a93d25e13a50cf7 Mon Sep 17 00:00:00 2001 >From: Ayoub Glizi-Vicioso <ayoub.glizi-vicioso@inLibro.com> >Date: Wed, 4 Feb 2026 17:07:08 -0500 >Subject: [PATCH] Bug 20956: Fix test failures > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> >--- > t/db_dependent/Koha/Patron.t | 88 ++++++++++++++++++++++++++++-------- > 1 file changed, 68 insertions(+), 20 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 3a40dc0a81c..5840c2edd38 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 46; >+use Test::More tests => 47; > use Test::NoWarnings; > use Test::Exception; > use Test::Warn; >@@ -41,6 +41,7 @@ use C4::Circulation qw( AddIssue AddReturn ); > > use t::lib::TestBuilder; > use t::lib::Mocks; >+use Test::MockModule; > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; >@@ -818,6 +819,7 @@ subtest 'permissions() tests' => sub { > my $patron = $builder->build_object( > { > class => 'Koha::Patrons', >+ > value => { flags => 4 } > } > ); >@@ -2420,10 +2422,24 @@ subtest 'alert_subscriptions tests' => sub { > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > >- my $subscription1 = $builder->build_object( { class => 'Koha::Subscriptions' } ); >+ my $subscription1 = $builder->build_object( >+ { >+ class => 'Koha::Subscriptions', >+ value => { >+ librarian => $patron->borrowernumber, >+ } >+ } >+ ); > $subscription1->add_subscriber($patron); > >- my $subscription2 = $builder->build_object( { class => 'Koha::Subscriptions' } ); >+ my $subscription2 = $builder->build_object( >+ { >+ class => 'Koha::Subscriptions', >+ value => { >+ librarian => $patron->borrowernumber, >+ } >+ } >+ ); > $subscription2->add_subscriber($patron); > > my @subscriptions = $patron->alert_subscriptions->as_list; >@@ -2459,6 +2475,26 @@ subtest 'update_lastseen tests' => sub { > plan tests => 26; > $schema->storage->txn_begin; > >+ my $mock_cache = Test::MockModule->new('Koha::Cache'); >+ my %fake_cache; >+ >+ $mock_cache->mock( >+ 'set_in_cache', >+ sub { >+ my ( $self, $key, $value ) = @_; >+ $fake_cache{$key} = $value; >+ return; >+ } >+ ); >+ >+ $mock_cache->mock( >+ 'get_from_cache', >+ sub { >+ my ( $self, $key ) = @_; >+ return $fake_cache{$key}; >+ } >+ ); >+ > my $cache = Koha::Caches->get_instance(); > > t::lib::Mocks::mock_preference( >@@ -2466,13 +2502,13 @@ subtest 'update_lastseen tests' => sub { > 'creation,login,connection,check_in,check_out,renewal,hold,article' > ); > >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >- my $userid = $patron->userid; >- $patron->lastseen(undef); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $patron_info = $patron->unblessed; > delete $patron_info->{borrowernumber}; > $patron->delete(); > $patron = Koha::Patron->new($patron_info)->store(); >+ $patron->update_lastseen( { activity => 'creation' } ); >+ $patron->discard_changes(); > > my $now = dt_from_string(); > my $today = $now->ymd(); >@@ -2482,21 +2518,31 @@ subtest 'update_lastseen tests' => sub { > 'Patron should have last seen when newly created if requested' > ); > >- my $cache_key = "track_activity_" . $patron->borrowernumber; >- my $cache_value = $cache->get_from_cache($cache_key); >- is( $cache_value, $today, "Cache was updated as expected" ); >+ my $cache_key = "track_activity_" . $patron->borrowernumber; >+ is( $cache->get_from_cache($cache_key), $today, "Cache was updated as expected" ); > > $patron->delete(); > > t::lib::Mocks::mock_preference( > 'TrackLastPatronActivityTriggers', >- 'login,connection,check_in,check_out,renewal,hold,article' >+ '' > ); >+ my $patron_no_trigger = $builder->build_object( { class => 'Koha::Patrons' } ); > >- $patron = Koha::Patron->new($patron_info)->store(); >- $cache_key = "track_activity_" . $patron->borrowernumber; >+ $patron_no_trigger->lastseen(undef)->store(); > >- is( $patron->lastseen, undef, 'Patron should have not last seen when newly created if trigger not set' ); >+ $patron_no_trigger->update_lastseen( { activity => 'login' } ); >+ $patron_no_trigger->discard_changes(); >+ >+ is( >+ $patron_no_trigger->lastseen, undef, >+ 'Patron should have not last seen when newly created if trigger not set' >+ ); >+ >+ t::lib::Mocks::mock_preference( >+ 'TrackLastPatronActivityTriggers', >+ 'login,connection,check_in,check_out,renewal,hold,article' >+ ); > > $now = dt_from_string(); > Time::Fake->offset( $now->epoch ); >@@ -2591,12 +2637,12 @@ subtest 'update_lastseen tests' => sub { > 'login,connection,check_in,check_out,renewal,hold,article' > ); > >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('login'); > $patron->_result()->discard_changes(); > isnt( $patron->lastseen, $last_seen, 'Patron last seen should be changed after a login if we cleared the cache' ); > >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('connection'); > $patron->_result()->discard_changes(); > isnt( >@@ -2604,7 +2650,7 @@ subtest 'update_lastseen tests' => sub { > 'Patron last seen should be changed after a connection if we cleared the cache' > ); > >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('check_out'); > $patron->_result()->discard_changes(); > isnt( >@@ -2612,7 +2658,7 @@ subtest 'update_lastseen tests' => sub { > 'Patron last seen should be changed after a check_out if we cleared the cache' > ); > >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('check_in'); > $patron->_result()->discard_changes(); > isnt( >@@ -2620,13 +2666,15 @@ subtest 'update_lastseen tests' => sub { > 'Patron last seen should be changed after a check_in if we cleared the cache' > ); > >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('hold'); > $patron->_result()->discard_changes(); > isnt( > $patron->lastseen, $last_seen, > 'Patron last seen should be changed after a hold if we cleared the cache' > ); >+ >+ %fake_cache = (); > $patron->update_lastseen('article'); > $patron->_result()->discard_changes(); > isnt( >@@ -2634,7 +2682,7 @@ subtest 'update_lastseen tests' => sub { > 'Patron last seen should be changed after a article if we cleared the cache' > ); > >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('renewal'); > $patron->_result()->discard_changes(); > isnt( $patron->lastseen, $last_seen, 'Patron last seen should be changed after a renewal if we cleared the cache' ); >@@ -2642,7 +2690,7 @@ subtest 'update_lastseen tests' => sub { > # Check that the preference takes effect > t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' ); > $patron->lastseen(undef)->store; >- $cache->clear_from_cache($cache_key); >+ %fake_cache = (); > $patron->update_lastseen('login'); > $patron->_result()->discard_changes(); > is( >-- >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 20956
:
182955
|
185483
|
185491
|
186388
|
187592
|
187593
|
187594
|
188260
|
188261
|
188262
|
188263
|
190686
|
190687
|
190688
|
190689
|
190690
|
191472
|
191473
|
191474
|
191475
|
191476
|
191477
|
191478
|
192506
|
192507
|
192508
|
192509
|
192510
|
192511
|
192512
|
192604
|
192605
|
192606
|
192607
|
192608
|
192609
|
192610
|
194527
|
194528
|
194529
|
194530
|
194531
|
194532
|
194533
|
194534
|
194612
|
194865
|
194866
|
194867
|
194868
|
194869
|
194870
|
194871
|
194882
|
194883
|
194884
|
194885
|
194886
|
194887
|
194888
|
194889
|
194890
|
194892
|
194893
|
194894
|
194895
|
194896
| 194897 |
194898
|
194899