Bugzilla – Attachment 145587 Details for
Bug 32306
Hold modifications don't log correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32306: Add unit tests
Bug-32306-Add-unit-tests.patch (text/plain), 4.23 KB, created by
Emily Lamancusa (emlam)
on 2023-01-23 16:10:27 UTC
(
hide
)
Description:
Bug 32306: Add unit tests
Filename:
MIME Type:
Creator:
Emily Lamancusa (emlam)
Created:
2023-01-23 16:10:27 UTC
Size:
4.23 KB
patch
obsolete
>From 839814c41a89f3daa486887c6f18190ba06c2cf3 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Thu, 24 Nov 2022 13:06:55 +0200 >Subject: [PATCH] Bug 32306: Add unit tests > >In ModReserves logging changes actually happens >before we store any of made changes. > >To test: >1. Run prove t/db_dependent/Reserves.t >=> Tests should fail. > >Sponsored-by: Koha-Suomi Oy >--- > t/db_dependent/Reserves.t | 97 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 96 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 1f368e36b6..1433361882 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 77; >+use Test::More tests => 78; > use Test::MockModule; > use Test::Warn; > >@@ -1406,6 +1406,101 @@ subtest 'ModReserveAffect logging' => sub { > like( $log->info, qr{$expected}, 'Timestamp logged is the current one' ); > }; > >+subtest 'ModReserve logging' => sub { >+ >+ plan tests => 2; >+ >+ t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); >+ >+ my $item = $builder->build_sample_item; >+ my $patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { branchcode => $item->homebranch } >+ } >+ ); >+ >+ my $hold1 = $builder->build_object( >+ { >+ class => "Koha::Holds", >+ value => { >+ found => "W", >+ priority => 0, >+ itemnumber => undef, >+ biblionumber => $item->biblionumber, >+ waitingdate => undef, >+ cancellationdate => undef, >+ item_level_hold => 0, >+ lowestPriority => 0, >+ expirationdate => '2022-12-24', >+ suspend_until => undef, >+ suspend => 0, >+ itemtype => undef, >+ borrowernumber => $patron->borrowernumber >+ } >+ } >+ ); >+ >+ my $other_branch = $builder->build_object( { class => "Koha::Libraries" } ); >+ >+ # Test changing expiration date >+ my $params = { >+ rank => $hold1->priority, >+ reserve_id => $hold1->reserve_id, >+ biblionumber => $item->biblionumber, >+ borrowernumber => $patron->borrowernumber, >+ branchcode => $hold1->branchcode, >+ expirationdate => "2022-12-31", >+ }; >+ >+ ModReserve($params); >+ my $log = Koha::ActionLogs->search( >+ { module => 'HOLDS', action => 'MODIFY', object => $hold1->reserve_id } >+ )->next; >+ my $expected = sprintf q{'expirationdate' => '%s'}, >+ $params->{expirationdate}; >+ like( $log->info, qr{$expected}, >+ 'Expiration date should have changed in logs' ); >+ >+ # Test making other changes >+ my $hold2 = $builder->build_object( >+ { >+ class => "Koha::Holds", >+ value => { >+ found => undef, >+ priority => 1, >+ itemnumber => undef, >+ biblionumber => $item->biblionumber, >+ waitingdate => undef, >+ cancellationdate => undef, >+ item_level_hold => 0, >+ lowestPriority => 0, >+ expirationdate => '2022-12-24', >+ suspend_until => undef, >+ suspend => 0, >+ itemtype => undef, >+ borrowernumber => $patron->borrowernumber >+ } >+ } >+ ); >+ >+ $params = { >+ rank => $hold2->priority, >+ reserve_id => $hold2->reserve_id, >+ biblionumber => $item->biblionumber, >+ borrowernumber => $patron->borrowernumber, >+ branchcode => $other_branch->branchcode, >+ }; >+ >+ ModReserve($params); >+ $log = Koha::ActionLogs->search( >+ { module => 'HOLDS', action => 'MODIFY', object => $hold2->reserve_id } >+ )->next; >+ $expected = sprintf q{'branchcode' => '%s'}, $other_branch->branchcode; >+ like( $log->info, qr{$expected}, 'Branchcode should have changed in logs' ); >+ >+}; >+ > sub count_hold_print_messages { > my $message_count = $dbh->selectall_arrayref(q{ > SELECT COUNT(*) >-- >2.30.2
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 32306
:
144215
|
144216
| 145587 |
145588