Bugzilla – Attachment 101008 Details for
Bug 24901
C4::Circulation::transferbook lacks tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24901: Add tests for transferbook
Bug-24901-Add-tests-for-transferbook.patch (text/plain), 6.67 KB, created by
Nick Clemens (kidclamp)
on 2020-03-19 12:20:34 UTC
(
hide
)
Description:
Bug 24901: Add tests for transferbook
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-03-19 12:20:34 UTC
Size:
6.67 KB
patch
obsolete
>From 37118424f95af948e95253554e521c8eac3841ae Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 19 Mar 2020 08:10:00 +0000 >Subject: [PATCH] Bug 24901: Add tests for transferbook > >Test plan: >0/ Read the commit and confirm the new tests make sence >1/ Run the tests and verify they pass >2/ Signoff > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Circulation/transferbook.t | 113 +++++++++++++++++++++++++++++- > 1 file changed, 111 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Circulation/transferbook.t b/t/db_dependent/Circulation/transferbook.t >index e37324f147..d9ca2c5ee6 100644 >--- a/t/db_dependent/Circulation/transferbook.t >+++ b/t/db_dependent/Circulation/transferbook.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 4; > use t::lib::TestBuilder; > use t::lib::Mocks; > >@@ -47,8 +47,55 @@ subtest 'transfer a non-existant item' => sub { > ); > }; > >+#subtest 'UseBranchTransferLimits tests' => sub { >+# plan tests => 0; >+#}; >+ >+subtest 'transfer already at destination' => sub { >+ plan tests => 5; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; >+ t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode } >+ } >+ ); >+ >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->branchcode, >+ } >+ ); >+ >+ my ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); >+ is( $dotransfer, 0, 'Transfer of reserved item failed with ignore reserves: true' ); >+ is_deeply( >+ $messages, >+ { 'DestinationEqualsHolding' => 1 }, >+ "We got the expected failure message: DestinationEqualsHolding" >+ ); >+ >+ # We are making sure there is no regression, feel free to change the behavior if needed. >+ # * Contrary to the POD, if ignore_reserves is not passed (or is false), any item reserve >+ # found will override all other measures that may prevent transfer and force a transfer. >+ AddReserve({ >+ branchcode => $item->homebranch, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber, >+ }); >+ >+ ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); >+ is( $dotransfer, 1, 'Transfer of reserved item succeeded without ignore reserves' ); >+ is( $messages->{ResFound}->{ResFound}, 'Reserved', "We found the reserve"); >+ is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info"); >+}; >+ > subtest 'transfer an issued item' => sub { >- plan tests => 3; >+ plan tests => 5; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; > t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); >@@ -75,13 +122,75 @@ subtest 'transfer an issued item' => sub { > my ($dotransfer, $messages) = transferbook( $library->branchcode, $item->barcode ); > is( $messages->{WasReturned}, $patron->borrowernumber, 'transferbook should have return a WasReturned flag is the item was issued before the transferbook call'); > >+ # Reset issue >+ $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to ); >+ >+ # We are making sure there is no regression, feel free to change the behavior if needed. >+ # * Contrary to the POD, if ignore_reserves is not passed (or is false), any item reserve >+ # found will override all other measures that may prevent transfer and force a transfer. > AddReserve({ > branchcode => $item->homebranch, > borrowernumber => $patron->borrowernumber, > biblionumber => $item->biblionumber, > itemnumber => $item->itemnumber, > }); >+ > ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); >+ is( $dotransfer, 1, 'Transfer of reserved item succeeded without ignore reserves' ); > is( $messages->{ResFound}->{ResFound}, 'Reserved', "We found the reserve"); > is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info"); >+ is( $messages->{WasReturned}, $patron->borrowernumber, "We got the return info"); > }; >+ >+subtest 'ignore_reserves flag' => sub { >+ plan tests => 10; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; >+ t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode } >+ } >+ ); >+ >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->branchcode, >+ } >+ ); >+ >+ AddReserve({ >+ branchcode => $item->homebranch, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber, >+ }); >+ >+ # We are making sure there is no regression, feel free to change the behavior if needed. >+ # * Contrary to the POD, if ignore_reserves is not passed (or is false), any item reserve >+ # found will override all other measures that may prevent transfer and force a transfer. >+ my ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); >+ is( $dotransfer, 1, 'Transfer of reserved item succeeded without ignore reserves' ); >+ is( $messages->{ResFound}->{ResFound}, 'Reserved', "We found the reserve"); >+ is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info"); >+ >+ my $ignore_reserves = 0; >+ ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode, $ignore_reserves ); >+ is( $dotransfer, 1, 'Transfer of reserved item succeeded with ignore reserves: false' ); >+ is( $messages->{ResFound}->{ResFound}, 'Reserved', "We found the reserve"); >+ is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info"); >+ >+ $ignore_reserves = 1; >+ ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode, $ignore_reserves ); >+ is( $dotransfer, 0, 'Transfer of reserved item failed with ignore reserves: true' ); >+ is_deeply( >+ $messages, >+ { 'DestinationEqualsHolding' => 1 }, >+ "We got the expected failure message: DestinationEqualsHolding" >+ ); >+ isnt( $messages->{ResFound}->{ResFound}, 'Reserved', "We did not return that we found a reserve"); >+ isnt( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We did not return the reserve info"); >+}; >+ >+ >-- >2.11.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 24901
:
100996
|
100997
|
101007
| 101008 |
102519