Bugzilla – Attachment 129499 Details for
Bug 29483
AllowRenewalIfOtherItemsAvailable has poor performance for records with many items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29483: Unit tests
Bug-29483-Unit-tests.patch (text/plain), 11.15 KB, created by
Andrew Fuerste-Henry
on 2022-01-14 16:56:45 UTC
(
hide
)
Description:
Bug 29483: Unit tests
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2022-01-14 16:56:45 UTC
Size:
11.15 KB
patch
obsolete
>From 194ce11ff881284edf3ce9e76c3def623c9db6b2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 18 Nov 2021 16:11:24 +0000 >Subject: [PATCH] Bug 29483: Unit tests > >This patch updates the AllowRenewalIfOtherItemsAvailable tests to >remove deletion of all data, and create specific circ rules for this >test. It adjust several other tests that were relying on the rules from >this test, so thy too create their opwn specific rules. > >Additionally, we add tests to cover the case of mutliple items on the record, >and some items cannot fill some reserves. > >What is uncovered here is that the same patron is checked twice, so two holds can >be filled, but they only satisfy a single patron > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 165 +++++++++++++++++++++++++++-------- > 1 file changed, 128 insertions(+), 37 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 3b0b09b83f..405b9e6b71 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -1556,16 +1556,30 @@ subtest "Bug 13841 - Do not create new 0 amount fines" => sub { > }; > > subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { >- $dbh->do('DELETE FROM issues'); >- $dbh->do('DELETE FROM items'); >- $dbh->do('DELETE FROM circulation_rules'); >+ plan tests => 9; >+ my $biblio = $builder->build_sample_biblio(); >+ my $item_1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library2->{branchcode}, >+ } >+ ); >+ my $item_2= $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library2->{branchcode}, >+ itype => $item_1->effective_itemtype, >+ } >+ ); >+ > Koha::CirculationRules->set_rules( > { > categorycode => undef, >- itemtype => undef, >+ itemtype => $item_1->effective_itemtype, > branchcode => undef, > rules => { > reservesallowed => 25, >+ holds_per_record => 25, > issuelength => 14, > lengthunit => 'days', > renewalsallowed => 1, >@@ -1578,23 +1592,7 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > } > } > ); >- my $biblio = $builder->build_sample_biblio(); > >- my $item_1 = $builder->build_sample_item( >- { >- biblionumber => $biblio->biblionumber, >- library => $library2->{branchcode}, >- itype => $itemtype, >- } >- ); >- >- my $item_2= $builder->build_sample_item( >- { >- biblionumber => $biblio->biblionumber, >- library => $library2->{branchcode}, >- itype => $itemtype, >- } >- ); > > my $borrowernumber1 = Koha::Patron->new({ > firstname => 'Kyle', >@@ -1608,6 +1606,22 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > categorycode => $patron_category->{categorycode}, > branchcode => $library2->{branchcode}, > })->store->borrowernumber; >+ my $patron_category_2 = $builder->build( >+ { >+ source => 'Category', >+ value => { >+ category_type => 'P', >+ enrolmentfee => 0, >+ BlockExpiredPatronOpacActions => -1, # Pick the pref value >+ } >+ } >+ ); >+ my $borrowernumber3 = Koha::Patron->new({ >+ firstname => 'Carnegie', >+ surname => 'Hall', >+ categorycode => $patron_category_2->{categorycode}, >+ branchcode => $library2->{branchcode}, >+ })->store->borrowernumber; > > my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed; > my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed; >@@ -1629,7 +1643,7 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > Koha::CirculationRules->set_rules( > { > categorycode => undef, >- itemtype => undef, >+ itemtype => $item_1->effective_itemtype, > branchcode => undef, > rules => { > onshelfholds => 0, >@@ -1640,16 +1654,6 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); > is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); > >- Koha::CirculationRules->set_rules( >- { >- categorycode => undef, >- itemtype => undef, >- branchcode => undef, >- rules => { >- onshelfholds => 0, >- } >- } >- ); > t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); > ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); > is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); >@@ -1657,7 +1661,7 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > Koha::CirculationRules->set_rules( > { > categorycode => undef, >- itemtype => undef, >+ itemtype => $item_1->effective_itemtype, > branchcode => undef, > rules => { > onshelfholds => 1, >@@ -1668,25 +1672,53 @@ subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { > ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); > is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); > >+ t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); >+ ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); >+ is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); >+ >+ AddReserve( >+ { >+ branchcode => $library2->{branchcode}, >+ borrowernumber => $borrowernumber3, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ } >+ ); >+ >+ ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); >+ is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and one other item on record' ); >+ >+ my $item_3= $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library2->{branchcode}, >+ itype => $item_1->effective_itemtype, >+ } >+ ); >+ >+ ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); >+ is( $renewokay, 1, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' ); >+ > Koha::CirculationRules->set_rules( > { >- categorycode => undef, >- itemtype => undef, >+ categorycode => $patron_category_2->{categorycode}, >+ itemtype => $item_1->effective_itemtype, > branchcode => undef, > rules => { >- onshelfholds => 1, >+ reservesallowed => 0, > } > } > ); >- t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); >+ > ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); >- is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); >+ is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record, but only one of those holds can be filled when AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' ); > > # Setting item not checked out to be not for loan but holdable > $item_2->notforloan(-1)->store; > > ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber ); > is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' ); >+ > }; > > { >@@ -1771,6 +1803,25 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > holdingbranch => $holdingbranch->{branchcode}, > } > ); >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => $item->effective_itemtype, >+ branchcode => undef, >+ rules => { >+ reservesallowed => 25, >+ issuelength => 14, >+ lengthunit => 'days', >+ renewalsallowed => 1, >+ renewalperiod => 7, >+ norenewalbefore => undef, >+ auto_renew => 0, >+ fine => .10, >+ chargeperiod => 1, >+ maxissueqty => 20 >+ } >+ } >+ ); > > set_userenv($holdingbranch); > >@@ -1924,6 +1975,26 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > library => $library->{branchcode}, > } > ); >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => $library->{branchcode}, >+ rules => { >+ reservesallowed => 25, >+ issuelength => 14, >+ lengthunit => 'days', >+ renewalsallowed => 1, >+ renewalperiod => 7, >+ norenewalbefore => undef, >+ auto_renew => 0, >+ fine => .10, >+ chargeperiod => 1, >+ maxissueqty => 20 >+ } >+ } >+ ); >+ > > my ( $error, $question, $alerts ); > >@@ -2121,6 +2192,26 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > } > ); > >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => $library->{branchcode}, >+ rules => { >+ reservesallowed => 25, >+ issuelength => 14, >+ lengthunit => 'days', >+ renewalsallowed => 1, >+ renewalperiod => 7, >+ norenewalbefore => undef, >+ auto_renew => 0, >+ fine => .10, >+ chargeperiod => 1, >+ maxissueqty => 20 >+ } >+ } >+ ); >+ > my ( $error, $question, $alerts ); > my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); > >-- >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 29483
:
127656
|
127819
|
127820
|
127883
|
127884
|
127885
|
129450
|
129451
|
129452
|
129453
|
129454
|
129499
|
129500
|
129501
|
132094
|
132095
|
132096
|
132113
|
133389
|
133390
|
133391
|
134723