Bugzilla – Attachment 165704 Details for
Bug 30324
Parent and child itemtype checkout limits not enforced as expected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30324: Unit tests
Bug-30324-Unit-tests.patch (text/plain), 5.35 KB, created by
Victor Grousset/tuxayo
on 2024-04-26 21:39:36 UTC
(
hide
)
Description:
Bug 30324: Unit tests
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-04-26 21:39:36 UTC
Size:
5.35 KB
patch
obsolete
>From de8b7cf62af5b04fc0e44cbe33724fb9d31f53e4 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 11 Jan 2024 14:50:35 +0000 >Subject: [PATCH] Bug 30324: Unit tests > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > t/db_dependent/Circulation/TooMany.t | 70 +++++++++++++++++++++------- > 1 file changed, 53 insertions(+), 17 deletions(-) > >diff --git a/t/db_dependent/Circulation/TooMany.t b/t/db_dependent/Circulation/TooMany.t >index 02e972a353..cf744dca24 100755 >--- a/t/db_dependent/Circulation/TooMany.t >+++ b/t/db_dependent/Circulation/TooMany.t >@@ -42,6 +42,7 @@ $dbh->do(q|DELETE FROM borrowers|); > #$dbh->do(q|DELETE FROM branches|); > $dbh->do(q|DELETE FROM categories|); > $dbh->do(q|DELETE FROM accountlines|); >+$dbh->do(q|DELETE FROM itemtypes WHERE parent_type IS NOT NULL|); > $dbh->do(q|DELETE FROM itemtypes|); > Koha::CirculationRules->search()->delete(); > >@@ -812,7 +813,7 @@ subtest 'empty string means unlimited' => sub { > }; > > subtest 'itemtype group tests' => sub { >- plan tests => 17; >+ plan tests => 20; > > t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' ); > Koha::CirculationRules->set_rules( >@@ -821,7 +822,7 @@ subtest 'itemtype group tests' => sub { > categorycode => '*', > itemtype => '*', > rules => { >- maxissueqty => '', >+ maxissueqty => '5', > maxonsiteissueqty => '', > issuelength => 1, > firstremind => 1, # 1 day of grace >@@ -886,10 +887,17 @@ subtest 'itemtype group tests' => sub { > itype => $child_itype_1->{itemtype} > } > ); >+ my $checkout_item = $builder->build_sample_item( >+ { >+ homebranch => $branch->{branchcode}, >+ holdingbranch => $branch->{branchcode}, >+ itype => $parent_itype->{itemtype} >+ } >+ ); > >- my $all_iq_rule = $builder->build( >+ my $all_iq_rule = $builder->build_object( > { >- source => 'CirculationRule', >+ class => 'Koha::CirculationRules', > value => { > branchcode => $branch->{branchcode}, > categorycode => $category->{categorycode}, >@@ -903,16 +911,15 @@ subtest 'itemtype group tests' => sub { > undef, 'Checkout allowed, using all rule of 1' ); > > #Checkout an item >- my $issue = >- C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); >+ my $issue = C4::Circulation::AddIssue( $patron, $checkout_item->barcode, dt_from_string() ); > like( $issue->issue_id, qr|^\d+$|, 'The issue should have been inserted' ); > >- #Patron has 1 checkout of child itype1 >+ #Patron has 1 checkout of parent itemtype {{{{ child itype1 > >- my $parent_iq_rule = $builder->build( >+ my $parent_iq_rule = $builder->build_object( > { >- source => 'CirculationRule', >- value => { >+ class => 'Koha::CirculationRules', >+ value => { > branchcode => $branch->{branchcode}, > categorycode => $category->{categorycode}, > itemtype => $parent_itype->{itemtype}, >@@ -922,8 +929,35 @@ subtest 'itemtype group tests' => sub { > } > ); > >- is( C4::Circulation::TooMany( $patron, $item ), >- undef, 'Checkout allowed, using parent type rule of 2' ); >+ is( >+ C4::Circulation::TooMany( $patron, $item ), >+ undef, 'Checkout allowed, using parent type rule of 2' >+ ); >+ >+ $all_iq_rule->rule_value(5)->store; >+ $parent_iq_rule->rule_value(1)->store; >+ >+ my $data = C4::Circulation::TooMany( $patron, $item ); >+ my $rule = delete $data->{circulation_rule}; >+ is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); >+ is_deeply( >+ $data, >+ { >+ reason => 'TOO_MANY_CHECKOUTS', >+ count => 1, >+ max_allowed => 1, >+ }, >+ 'Checkout not allowed, using parent type rule of 1' >+ ); >+ >+ $parent_iq_rule->rule_value(2)->store; >+ >+ is( >+ C4::Circulation::TooMany( $patron, $item ), >+ undef, 'Checkout allowed, using specific type of 1 and only parent type checked out' >+ ); >+ >+ $checkout_item->itype( $child_itype_1->{itemtype} )->store; > > my $child1_iq_rule = $builder->build_object( > { >@@ -938,8 +972,8 @@ subtest 'itemtype group tests' => sub { > } > ); > >- my $data = C4::Circulation::TooMany( $patron, $item ); >- my $rule = delete $data->{circulation_rule}; >+ $data = C4::Circulation::TooMany( $patron, $item ); >+ $rule = delete $data->{circulation_rule}; > is( ref $rule, 'Koha::CirculationRule', 'Circulation rule was returned' ); > is_deeply( > $data, >@@ -1017,9 +1051,11 @@ subtest 'itemtype group tests' => sub { > ); > > #increase parent type to greater than specific >- my $circ_rule_object = >- Koha::CirculationRules->find( $parent_iq_rule->{id} ); >- $circ_rule_object->rule_value(4)->store(); >+# my $circ_rule_object = >+# Koha::CirculationRules->find( $parent_iq_rule->{id} ); >+# $circ_rule_object->rule_value(4)->store(); >+ $parent_iq_rule->rule_value(4)->store(); >+ > > is( C4::Circulation::TooMany( $patron, $item_1 ), > undef, 'Checkout allowed, using specific type rule of 3' ); >-- >2.44.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 30324
:
160877
|
160878
|
161030
|
161031
|
161161
|
165663
|
165664
|
165665
| 165704 |
165705
|
165706