Bugzilla – Attachment 119756 Details for
Bug 27281
Replace call to `C4::Circulation::DeleteTransfer` with `Koha::Item::Transfer->cancel({ comment => $comment })` in `C4::Circulation::LostItem`
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27281: (follow-up) Clean up LostItem test
Bug-27281-follow-up-Clean-up-LostItem-test.patch (text/plain), 6.23 KB, created by
Kyle M Hall (khall)
on 2021-04-16 15:29:37 UTC
(
hide
)
Description:
Bug 27281: (follow-up) Clean up LostItem test
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-04-16 15:29:37 UTC
Size:
6.23 KB
patch
obsolete
>From beddfdad2abc63af82603c04ba8e622e76f0e7b7 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 8 Mar 2021 14:59:06 +0000 >Subject: [PATCH] Bug 27281: (follow-up) Clean up LostItem test > >The LostItem test was rather messy, and wasn't actually testing much in >reality. This patch cleans it up and adds testing for transfer queue >handling of ListItem cancellations. > >Test plan >1/ Confirm t/db_dependent/Circulation.t still passes >2/ Read the tests before and after and confirm that they test what is >required. >3/ Signoff > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 97 ++++++++++++++++++++---------------- > 1 file changed, 54 insertions(+), 43 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 77dee7389f..143c5c8a79 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -3475,57 +3475,68 @@ subtest 'Set waiting flag' => sub { > }; > > subtest 'Cancel transfers on lost items' => sub { >- plan tests => 6; >- my $library_1 = $builder->build( { source => 'Branch' } ); >- my $patron_1 = $builder->build( { source => 'Borrower', value => { branchcode => $library_1->{branchcode}, categorycode => $patron_category->{categorycode} } } ); >- my $library_2 = $builder->build( { source => 'Branch' } ); >- my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); >- my $biblio = $builder->build_sample_biblio({branchcode => $library->{branchcode}}); >- my $item = $builder->build_sample_item({ >- biblionumber => $biblio->biblionumber, >- library => $library_1->{branchcode}, >- }); >+ plan tests => 5; > >- set_userenv( $library_2 ); >- my $reserve_id = AddReserve( >+ my $library_to = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $item = $builder->build_sample_item(); >+ my $old_transfer = $builder->build_object( > { >- branchcode => $library_2->{branchcode}, >- borrowernumber => $patron_2->{borrowernumber}, >- biblionumber => $item->biblionumber, >- priority => 1, >- itemnumber => $item->itemnumber, >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $item->holdingbranch, >+ tobranch => $library_to->branchcode, >+ reason => 'Manual', >+ datesent => \'NOW()', >+ datearrived => \'NOW()', >+ datecancelled => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ my $transfer_1 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $item->holdingbranch, >+ tobranch => $library_to->branchcode, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ my $transfer_2 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $item->holdingbranch, >+ tobranch => $library_to->branchcode, >+ reason => 'Manual', >+ datesent => \'NOW()', >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()' >+ } > } > ); > >- #Return book and add transfer >- set_userenv( $library_1 ); >- my $do_transfer = 1; >- my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); >- ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); >- C4::Circulation::transferbook({ >- from_branch => $library_1->{branchcode}, >- to_branch => $library_2->{branchcode}, >- barcode => $item->barcode, >- trigger => 'Reserve', >- }); >- my $hold = Koha::Holds->find( $reserve_id ); >- is( $hold->found, 'T', 'Hold is in transit' ); >- >- #Check transfer exists and the items holding branch is the transfer destination branch before marking it as lost >- my ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); >- is( $frombranch, $library_1->{branchcode}, 'The transfer is generated from the correct library'); >- is( $tobranch, $library_2->{branchcode}, 'The transfer is generated to the correct library'); >- my $itemcheck = Koha::Items->find($item->itemnumber); >- is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Items holding branch is the transfers origination branch before it is marked as lost' ); >- >- #Simulate item being marked as lost and confirm the transfer is deleted and the items holding branch is the transfers source branch >+ # Simulate item being marked as lost > $item->itemlost(1)->store; > LostItem( $item->itemnumber, 'test', 1 ); >- ($datesent,$frombranch,$tobranch) = GetTransfers($item->itemnumber); >- is( $tobranch, undef, 'The transfer on the lost item has been deleted as the LostItemCancelOutstandingTransfer is enabled'); >- $itemcheck = Koha::Items->find($item->itemnumber); >- is( $itemcheck->holdingbranch, $library_1->{branchcode}, 'Lost item with cancelled hold has holding branch equallying the transfers source branch' ); > >+ $transfer_1->discard_changes; >+ isnt($transfer_1->datecancelled, undef, "Queud transfer was cancelled upon item lost"); >+ is($transfer_1->cancellation_reason, 'ItemLost', "Cancellation reason was set to 'ItemLost'"); >+ $transfer_2->discard_changes; >+ isnt($transfer_2->datecancelled, undef, "Active transfer was cancelled upon item lost"); >+ is($transfer_2->cancellation_reason, 'ItemLost', "Cancellation reason was set to 'ItemLost'"); >+ $old_transfer->discard_changes; >+ is($old_transfer->datecancelled, undef, "Old transfers are unaffected"); > }; > > subtest 'CanBookBeIssued | is_overdue' => sub { >-- >2.24.3 (Apple Git-128)
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 27281
:
117921
|
117922
|
117924
|
117925
|
117926
|
119754
|
119755
|
119756
|
119757
|
119847
|
119848
|
119849
|
119850
|
119986
|
120105
|
120107
|
120117