Bugzilla – Attachment 156607 Details for
Bug 15504
Track Patron's Last Activity
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15504: (follow-up) Tidy 'lastseen' section of unit test
Bug-15504-follow-up-Tidy-lastseen-section-of-unit-.patch (text/plain), 8.44 KB, created by
Martin Renvoize (ashimema)
on 2023-10-06 10:48:07 UTC
(
hide
)
Description:
Bug 15504: (follow-up) Tidy 'lastseen' section of unit test
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-10-06 10:48:07 UTC
Size:
8.44 KB
patch
obsolete
>From c447d369a7768e7d75b94971897338f7a11efd3e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 6 Oct 2023 11:25:01 +0100 >Subject: [PATCH] Bug 15504: (follow-up) Tidy 'lastseen' section of unit test > >--- > t/db_dependent/Koha/Patron.t | 85 +++++++++++++++++++++++------------- > 1 file changed, 55 insertions(+), 30 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index f3083053dd3..d3fd6df69f2 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -1936,17 +1936,17 @@ subtest 'update_lastseen tests' => sub { > plan tests => 18; > $schema->storage->txn_begin; > >- my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $userid = $patron->userid; > >- $patron->lastseen( undef ); >+ $patron->lastseen(undef); > $patron->store(); > > my $cache = Koha::Caches->get_instance(); > my $cache_key = "track_login_" . $patron->userid; > $cache->clear_from_cache($cache_key); > >- t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); > t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'login,connection,check_in,check_out,renewal' ); > > is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' ); >@@ -1954,86 +1954,111 @@ subtest 'update_lastseen tests' => sub { > my $now = dt_from_string(); > Time::Fake->offset( $now->epoch ); > >- $patron->update_lastseen( 'login' ); >+ $patron->update_lastseen('login'); > $patron->_result()->discard_changes(); > isnt( $patron->lastseen, undef, 'Patron should have last seen set when TrackLastPatronActivity = 1' ); > my $last_seen = $patron->lastseen; > > Time::Fake->offset( $now->epoch + 5 ); >+ > # Test that lastseen isn't updated more than once in a day (regardless of activity passed) >- $patron->update_lastseen( 'login' ); >+ $patron->update_lastseen('login'); > $patron->_result()->discard_changes(); > is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a login' ); >- $patron->update_lastseen( 'connection' ); >+ $patron->update_lastseen('connection'); > $patron->_result()->discard_changes(); > is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a SIP/ILSDI connection' ); >- $patron->update_lastseen( 'check_out' ); >+ $patron->update_lastseen('check_out'); > $patron->_result()->discard_changes(); > is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a check out' ); >- $patron->update_lastseen( 'check_in' ); >+ $patron->update_lastseen('check_in'); > $patron->_result()->discard_changes(); > is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a check in' ); >- $patron->update_lastseen( 'renewal' ); >+ $patron->update_lastseen('renewal'); > $patron->_result()->discard_changes(); > is( $patron->lastseen, $last_seen, 'Patron last seen should still be unchanged after a renewal' ); > > # Check that tracking is disabled when the activity isn't listed > t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' ); >- $cache->clear_from_cache($cache_key); # Rule out the more than once day prevention above >+ $cache->clear_from_cache($cache_key); # Rule out the more than once day prevention above > >- $patron->update_lastseen( 'login' ); >+ $patron->update_lastseen('login'); > $patron->_result()->discard_changes(); >- is( $patron->lastseen, $last_seen, 'Patron last seen should be unchanged after a login if login is not selected as an option and the cache has been cleared' ); >+ is( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be unchanged after a login if login is not selected as an option and the cache has been cleared' >+ ); > >- $patron->update_lastseen( 'connection' ); >+ $patron->update_lastseen('connection'); > $patron->_result()->discard_changes(); >- is( $patron->lastseen, $last_seen, 'Patron last seen should be unchanged after a connection if connection is not selected as an option and the cache has been cleared' ); >+ is( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be unchanged after a connection if connection is not selected as an option and the cache has been cleared' >+ ); > >- $patron->update_lastseen( 'check_in' ); >+ $patron->update_lastseen('check_in'); > $patron->_result()->discard_changes(); >- is( $patron->lastseen, $last_seen, 'Patron last seen should be unchanged after a check_in if check_in is not selected as an option and the cache has been cleared' ); >+ is( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be unchanged after a check_in if check_in is not selected as an option and the cache has been cleared' >+ ); > >- $patron->update_lastseen( 'check_out' ); >+ $patron->update_lastseen('check_out'); > $patron->_result()->discard_changes(); >- is( $patron->lastseen, $last_seen, 'Patron last seen should be unchanged after a check_out if check_out is not selected as an option and the cache has been cleared' ); >+ is( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be unchanged after a check_out if check_out is not selected as an option and the cache has been cleared' >+ ); > >- $patron->update_lastseen( 'renewal' ); >+ $patron->update_lastseen('renewal'); > $patron->_result()->discard_changes(); >- is( $patron->lastseen, $last_seen, 'Patron last seen should be unchanged after a renewal if renewal is not selected as an option and the cache has been cleared' ); >+ is( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be unchanged after a renewal if renewal is not selected as an option and the cache has been cleared' >+ ); > > # Check tracking for each activity > t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'login,connection,check_in,check_out,renewal' ); > > $cache->clear_from_cache($cache_key); >- $patron->update_lastseen( 'login' ); >+ $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); >- $patron->update_lastseen( 'connection' ); >+ $patron->update_lastseen('connection'); > $patron->_result()->discard_changes(); >- isnt( $patron->lastseen, $last_seen, 'Patron last seen should be changed after a connection if we cleared the cache' ); >+ isnt( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be changed after a connection if we cleared the cache' >+ ); > > $cache->clear_from_cache($cache_key); >- $patron->update_lastseen( 'check_out' ); >+ $patron->update_lastseen('check_out'); > $patron->_result()->discard_changes(); >- isnt( $patron->lastseen, $last_seen, 'Patron last seen should be changed after a check_out if we cleared the cache' ); >+ isnt( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be changed after a check_out if we cleared the cache' >+ ); > > $cache->clear_from_cache($cache_key); >- $patron->update_lastseen( 'check_in' ); >+ $patron->update_lastseen('check_in'); > $patron->_result()->discard_changes(); >- isnt( $patron->lastseen, $last_seen, 'Patron last seen should be changed after a check_in if we cleared the cache' ); >+ isnt( >+ $patron->lastseen, $last_seen, >+ 'Patron last seen should be changed after a check_in if we cleared the cache' >+ ); > > $cache->clear_from_cache($cache_key); >- $patron->update_lastseen( 'renewal' ); >+ $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' ); > > # Check that the preference takes effect > t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' ); >- $patron->lastseen( undef )->store; >+ $patron->lastseen(undef)->store; > $cache->clear_from_cache($cache_key); >- $patron->update_lastseen( 'login' ); >+ $patron->update_lastseen('login'); > $patron->_result()->discard_changes(); > is( $patron->lastseen, undef, 'Patron should still have last seen unchanged when TrackLastPatronActivity = 0' ); > >-- >2.41.0
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 15504
:
152332
|
152333
|
152334
|
152335
|
152336
|
152500
|
152501
|
152502
|
152503
|
152504
|
152505
|
152506
|
155290
|
155291
|
155292
|
155293
|
155294
|
155295
|
155296
|
155534
|
155535
|
155536
|
155537
|
155538
|
155539
|
155540
|
156598
|
156599
|
156600
|
156601
|
156602
|
156603
|
156604
|
156605
|
156606
|
156607
|
156608
|
156742
|
156855
|
156856
|
156857
|
156858
|
156859
|
156860
|
156861
|
156862
|
156863
|
156864
|
156865
|
156866
|
156867
|
156868
|
156869
|
156870
|
156875
|
156879
|
156898
|
156899
|
156900
|
156901
|
156902
|
156903
|
156904
|
156905
|
156906
|
156907
|
156908
|
156909
|
156910
|
156911
|
156912
|
156913
|
156914
|
156915
|
156917
|
156918
|
156919
|
156920
|
156921
|
156922
|
156923
|
156924
|
156925
|
156926
|
156927
|
156928
|
156929
|
156930
|
156931
|
156932
|
156933
|
156934
|
156935
|
157602
|
157603
|
157604
|
157605
|
157606
|
157607
|
157608
|
157609
|
157610
|
157611
|
157612
|
157613
|
157614
|
157615
|
157616
|
157617
|
157618
|
157619
|
157620
|
157624