Bugzilla – Attachment 80891 Details for
Bug 20844
Reset a hold when it is missing after allocation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20844: Added tests of the RevertWaitingStatus and RevertItemLevelHoldToBibLevelHold subroutines in C4/Reserves.pm
Bug-20844-Added-tests-of-the-RevertWaitingStatus-a.patch (text/plain), 6.39 KB, created by
Alex Buckley
on 2018-10-19 00:40:00 UTC
(
hide
)
Description:
Bug 20844: Added tests of the RevertWaitingStatus and RevertItemLevelHoldToBibLevelHold subroutines in C4/Reserves.pm
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2018-10-19 00:40:00 UTC
Size:
6.39 KB
patch
obsolete
>From 42844f690df03895d73de95972b66eb893a4a91d Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Thu, 18 Oct 2018 07:21:08 +0000 >Subject: [PATCH] Bug 20844: Added tests of the RevertWaitingStatus and > RevertItemLevelHoldToBibLevelHold subroutines in C4/Reserves.pm > >I have added unit tests for the two aforementioned subroutines which I >added in the previous patches on bug 20844, to the >t/db_dependent/Holds/RevertWaitingStatus.t test. > >Test plan: >1. Apply the patches on bug 20844 > >2. Go into koha-shell from the Koha home dir: >sudo koha-shell <instancename> > >3. Run the RevertWaitingStatus.t test file: >prove t/db_dependent/Holds/RevertWaitingStatus.t > >Sponsored-By: Brimbank Library, Australia >--- > C4/Reserves.pm | 7 +-- > .../prog/en/modules/cataloguing/additem.tt | 2 +- > t/db_dependent/Holds/RevertWaitingStatus.t | 64 +++++++++++++++++++++- > 3 files changed, 66 insertions(+), 7 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 54aa3c7..718def9 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -130,6 +130,8 @@ BEGIN { > &AlterPriority > &ToggleLowestPriority > >+ &RevertWaitingStatus >+ &RevertItemLevelHoldToBibLevelHold > &ReserveSlip > &ToggleSuspend > &SuspendAll >@@ -1403,7 +1405,6 @@ when _FixPriority calls itself. > > sub _FixPriority { > my ( $params ) = @_; >- warn Dumper($params); > my $reserve_id = $params->{reserve_id}; > my $rank = $params->{rank} // ''; > my $ignoreSetLowestRank = $params->{ignoreSetLowestRank}; >@@ -1412,16 +1413,13 @@ sub _FixPriority { > my $dbh = C4::Context->dbh; > > my $hold; >- warn $reserve_id; > if ( $reserve_id ) { > $hold = Koha::Holds->find( $reserve_id ); > return unless $hold; > } >- warn Dumper($hold); > unless ( $biblionumber ) { # FIXME This is a very weird API > $biblionumber = $hold->biblionumber; > } >- > if ( $rank eq "del" ) { # FIXME will crash if called without $hold > $hold->cancel; > } >@@ -1922,7 +1920,6 @@ sub RevertWaitingStatus { > "; > $sth = $dbh->prepare( $query ); > $sth->execute( $reserve->{'reserve_id'} ); >- warn $reserve->{reserve_id}; > _FixPriority( { biblionumber => $reserve->{biblionumber} } ); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index 4c68c97..2e45d7e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -264,7 +264,7 @@ function confirm_deletion() { > <div class="alert alert-warning"> > <form id="DeallocateLostItemLevelHold" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="DeallocateLostItemLevelHold"> > <input type="hidden" id="itemnumber" name="itemnumber" value="[% lostitemnumber | html %]"/> >- This item has an item-level hold on [% itemnumber | html %] it: >+ This item has an item-level hold on it: > <input type="submit" name="RetainHold" value="Retain Hold"/> > <input type="submit" name="CancelHold" value="Cancel hold"/> > </form> >diff --git a/t/db_dependent/Holds/RevertWaitingStatus.t b/t/db_dependent/Holds/RevertWaitingStatus.t >index 9877e68..a1a0c20 100755 >--- a/t/db_dependent/Holds/RevertWaitingStatus.t >+++ b/t/db_dependent/Holds/RevertWaitingStatus.t >@@ -16,7 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 3; >+use Test::More tests => 12; > use MARC::Record; > > use Koha::Libraries; >@@ -109,6 +109,68 @@ ok( scalar @$priorities == 2, 'Only 2 holds remain in the reserves table' ); > ok( $priorities->[0]->[0] == 1, 'First hold has a priority of 1' ); > ok( $priorities->[1]->[0] == 2, 'Second hold has a priority of 2' ); > >+#Bug 20844 >+#Test reverting the waiting status of holds when the reserved items are set to lost >+ >+#Create bib-level hold and test what happens when the item an allocated bib-level hold is allocated on is lost when the LostBibLevelHoldsRevert syspref is enabled >+my $hold_id = C4::Reserves::AddReserve( >+ $branchcode, >+ 4, >+ $biblionumber, >+ my $bibitems = q{}, >+ my $priority, >+ my $resdate, >+ my $expdate, >+ my $notes = q{}, >+ $title, >+ my $checkitem, >+ my $found, >+); >+ >+my $hold = Koha::Holds->find($hold_id); >+is( $hold->originalholdtype, 'B', 'Holds originalholdtype is "B" which is correct' ); >+ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's an allocated bib-level hold on $itemnumber and has status is 'W' >+$hold = Koha::Holds->find($hold_id); >+is( $hold->found, 'W', 'Hold status is "W" (waiting) which is correct' ); >+is( $hold->itemnumber, $itemnumber, 'Bib-level hold is allocated and has an itemnumber' ); >+t::lib::Mocks::mock_preference( 'LostBibLevelHoldsRevert', 1 ); >+ >+if (C4::Context->preference('LostBibLevelHoldsRevert') ) { >+ #When item is set to lost revert hold to bib-level (i.e. remove the itemnumber in hold record) and change reserves.found to '' >+ RevertWaitingStatus({ itemnumber => $itemnumber }); >+ RevertItemLevelHoldToBibLevelHold({ reserveid => $hold_id }); >+} >+$hold = Koha::Holds->find($hold_id); >+is( $hold->found, undef, 'reserve.found reverted to undef now item is lost' ); >+is( $hold->itemnumber, undef, 'Hold reverted back to unallocated bib level hold' ); >+ >+#Create item-level hold and test what happens when the reserved item is set to lost >+$hold_id = C4::Reserves::AddReserve( >+ $branchcode, >+ 4, >+ $biblionumber, >+ $bibitems = q{}, >+ $priority, >+ $resdate, >+ $expdate, >+ $notes = q{}, >+ $title, >+ $itemnumber, >+ $found, >+); >+ >+$hold = Koha::Holds->find($hold_id); >+is( $hold->itemnumber, $itemnumber, 'This is an item-level hold' ); >+ >+is( $hold->originalholdtype, 'I', 'Holds originalholdtype is correct' ); >+ModReserveAffect($itemnumber, 4, 0); #Confirm the hold - now it's a waiting item-level hold with a reserves.found value of 'W' >+$hold = Koha::Holds->find($hold_id); >+is( $hold->found, 'W', 'Hold status is waiting' ); >+ >+RevertWaitingStatus({ itemnumber => $itemnumber }); >+$hold = Koha::Holds->find($hold_id); >+is( $hold->found, undef, 'Reserves found value is reverted to undef as the reserved item has been lost' ); >+ > $schema->storage->txn_rollback; > > # Helper method to set up a Biblio. >-- >2.1.4
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 20844
:
79267
|
80760
|
80761
|
80890
|
80891
|
81045
|
81531
|
81623
|
81624
|
81640
|
81697
|
81698
|
81710
|
81711
|
81712
|
102334
|
102335
|
102336
|
113208
|
113209
|
113210
|
118264
|
118265
|
118266
|
125437
|
125438
|
125439
|
140214
|
140215
|
140216
|
150348
|
150349
|
150350
|
150480
|
159062
|
159063
|
159064
|
159065
|
159111
|
170263
|
170264