Bugzilla – Attachment 119260 Details for
Bug 28013
Improvements to CanBookBeRenewed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28013: Unit tests
Bug-28013-Unit-tests.patch (text/plain), 4.32 KB, created by
Joonas Kylmälä
on 2021-04-07 08:47:54 UTC
(
hide
)
Description:
Bug 28013: Unit tests
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2021-04-07 08:47:54 UTC
Size:
4.32 KB
patch
obsolete
>From 946ce460dd9ad6128ca11bb03ea38ca2d4ff3ede Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 2 Apr 2021 14:33:55 +0000 >Subject: [PATCH] Bug 28013: Unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Cover the case of multiple patrons and multiple items that can fill them > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > t/db_dependent/Circulation.t | 88 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 87 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index d0bfe6e207..77dee7389f 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 53; >+use Test::More tests => 54; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -282,6 +282,92 @@ Koha::CirculationRules->set_rules( > } > ); > >+subtest "CanBookBeRenewed AllowRenewalIfOtherItemsAvailable multiple borrowers and items tests" => sub { >+ plan tests => 5; >+ >+ #Can only reserve from home branch >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ itemtype => undef, >+ rule_name => 'holdallowed', >+ rule_value => 1 >+ } >+ ); >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'onshelfholds', >+ rule_value => 1 >+ } >+ ); >+ >+ # Patrons from three different branches >+ my $patron_borrower = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron_hold_1 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron_hold_2 = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $biblio = $builder->build_sample_biblio(); >+ >+ # Item at each patron branch >+ my $item_1 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ homebranch => $patron_borrower->branchcode >+ }); >+ my $item_2 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ homebranch => $patron_hold_2->branchcode >+ }); >+ my $item_3 = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ homebranch => $patron_hold_1->branchcode >+ }); >+ >+ my $issue = AddIssue( $patron_borrower->unblessed, $item_1->barcode); >+ my $datedue = dt_from_string( $issue->date_due() ); >+ is (defined $issue->date_due(), 1, "Item 1 checked out, due date: " . $issue->date_due() ); >+ >+ # Biblio-level holds >+ AddReserve( >+ { >+ branchcode => $patron_hold_1->branchcode, >+ borrowernumber => $patron_hold_1->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ reservation_date => dt_from_string(), >+ expiration_date => undef, >+ itemnumber => undef, >+ found => undef, >+ } >+ ); >+ AddReserve( >+ { >+ branchcode => $patron_hold_2->branchcode, >+ borrowernumber => $patron_hold_2->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 2, >+ reservation_date => dt_from_string(), >+ expiration_date => undef, >+ itemnumber => undef, >+ found => undef, >+ } >+ ); >+ t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); >+ >+ my ( $renewokay, $error ) = CanBookBeRenewed($patron_borrower->borrowernumber, $item_1->itemnumber); >+ is( $renewokay, 0, 'Cannot renew, reserved'); >+ is( $error, 'on_reserve', 'Cannot renew, reserved (returned error is on_reserve)'); >+ >+ t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); >+ >+ ( $renewokay, $error ) = CanBookBeRenewed($patron_borrower->borrowernumber, $item_1->itemnumber); >+ is( $renewokay, 1, 'Can renew, two items available for two holds'); >+ is( $error, undef, 'Can renew, each reserve has an item'); >+ >+ >+}; >+ > subtest "GetIssuingCharges tests" => sub { > plan tests => 4; > my $branch_discount = $builder->build_object({ class => 'Koha::Libraries' }); >-- >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 28013
:
118592
|
118928
|
118950
|
118951
|
119125
|
119126
|
119127
|
119253
|
119257
|
119258
|
119259
| 119260 |
119261