Bugzilla – Attachment 180210 Details for
Bug 35292
Define itemtype specific rules in the UpdateNotForLoanStatusOnCheckOut system preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35292: Move tests for UpdateNotForLoanStatusOnCheckin in a subtest
Bug-35292-Move-tests-for-UpdateNotForLoanStatusOnC.patch (text/plain), 9.13 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-04-01 14:52:12 UTC
(
hide
)
Description:
Bug 35292: Move tests for UpdateNotForLoanStatusOnCheckin in a subtest
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-04-01 14:52:12 UTC
Size:
9.13 KB
patch
obsolete
>From d7e8e661dc2b8e0b618e43294d91a1c95b0307d9 Mon Sep 17 00:00:00 2001 >From: Baptiste <baptiste.wojtkowski@biblibre.com> >Date: Mon, 9 Dec 2024 16:57:40 +0100 >Subject: [PATCH] Bug 35292: Move tests for UpdateNotForLoanStatusOnCheckin in > a subtest > >Note: These patches have been split for sake of understandability for >review but they should probably be squashe >--- > t/db_dependent/Circulation/issue.t | 160 +++++++++++++++-------------- > 1 file changed, 82 insertions(+), 78 deletions(-) > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index d42f6e033f6..f4ef34ce549 100755 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -17,8 +17,7 @@ > > use Modern::Perl; > >-use Test::NoWarnings; >-use Test::More tests => 67; >+use Test::More tests => 60; > use DateTime::Duration; > > use t::lib::Mocks; >@@ -435,83 +434,88 @@ ok( > $return->{returndate} eq '2014-04-01 23:42:00', > "Item returned with a return date of '2014-04-01 23:42' has that return date" > ); >+subtest 'AddIssue Update notforloanstatus according to UpdateNotForLoanStatusOnCheckin' => sub { >+ plan tests => 7; >+ my $itemnumber = Koha::Item->new( >+ { >+ biblionumber => $biblionumber, >+ barcode => 'barcode_3', >+ itemcallnumber => 'callnumber3', >+ homebranch => $branchcode_1, >+ holdingbranch => $branchcode_1, >+ notforloan => 1, >+ itype => $itemtype, >+ biblioitemnumber => $biblioitemnumber >+ }, >+ )->store->itemnumber; > >-my $itemnumber = Koha::Item->new( >- { >- biblionumber => $biblionumber, >- barcode => 'barcode_3', >- itemcallnumber => 'callnumber3', >- homebranch => $branchcode_1, >- holdingbranch => $branchcode_1, >- notforloan => 1, >- itype => $itemtype, >- biblioitemnumber => $biblioitemnumber >- }, >-)->store->itemnumber; >- >-t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); >-t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); >-my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); >- >-AddReturn( 'barcode_3', $branchcode_1 ); >-my $item = Koha::Items->find($itemnumber); >-ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); >- >-my $updatenotforloanstatusoncheckin = " >-_ALL_:\n >- 1: 0\n >- 9: 1\n\n >-$itemtype:\n >- 1: 9 >-"; >-t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); >-AddReturn( 'barcode_3', $branchcode_1 ); >-$item = Koha::Items->find($itemnumber); >-ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} ); >-my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); >-is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); >+ t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); >+ t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); >+ my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); >+ >+ AddReturn( 'barcode_3', $branchcode_1 ); >+ my $item = Koha::Items->find($itemnumber); >+ ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); >+ >+ my $updatenotforloanstatusoncheckin = " >+ _ALL_:\n >+ 1: 0\n >+ 9: 1\n\n >+ $itemtype:\n >+ 1: 9 >+ "; >+ t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); >+ AddReturn( 'barcode_3', $branchcode_1 ); >+ $item = Koha::Items->find($itemnumber); >+ ok( >+ $item->notforloan eq 9, >+ q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} >+ ); >+ my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); >+ is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); > >-AddReturn( 'barcode_3', $branchcode_1 ); >-$item = Koha::Items->find($itemnumber); >-ok( >- $item->notforloan eq 9, >- q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} >-); >+ AddReturn( 'barcode_3', $branchcode_1 ); >+ $item = Koha::Items->find($itemnumber); >+ ok( >+ $item->notforloan eq 9, >+ q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} >+ ); > >-# Change the returning item to an item type without a rule >-Koha::Items->find($itemnumber)->itype($itemtype2)->store; >-Koha::Items->find($itemnumber)->notforloan(1)->store; >-AddReturn( 'barcode_3', $branchcode_1 ); >-$item = Koha::Items->find($itemnumber); >-ok( >- $item->notforloan eq 0, >- q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} >-); >+ # Change the returning item to an item type without a rule >+ Koha::Items->find($itemnumber)->itype($itemtype2)->store; >+ Koha::Items->find($itemnumber)->notforloan(1)->store; >+ AddReturn( 'barcode_3', $branchcode_1 ); >+ $item = Koha::Items->find($itemnumber); >+ ok( >+ $item->notforloan eq 0, >+ q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} >+ ); > >-t::lib::Mocks::mock_preference( >- 'UpdateNotForLoanStatusOnCheckin', q{_ALL_: >- 1: ONLYMESSAGE >-} >-); >-$item->notforloan(1)->store; >-AddReturn( 'barcode_3', $branchcode_1 ); >-$item->discard_changes; >-is( >- $item->notforloan, 1, >- q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 for _ALL_ with setting "1: ONLYMESSAGE"} >-); >+ t::lib::Mocks::mock_preference( >+ 'UpdateNotForLoanStatusOnCheckin', q{_ALL_: >+ 1: ONLYMESSAGE >+ } >+ ); >+ $item->notforloan(1)->store; >+ AddReturn( 'barcode_3', $branchcode_1 ); >+ $item->discard_changes; >+ is( >+ $item->notforloan, 1, >+ q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 for _ALL_ with setting "1: ONLYMESSAGE"} >+ ); > >-t::lib::Mocks::mock_preference( >- 'UpdateNotForLoanStatusOnCheckin', "$itemtype:\n >- 1: ONLYMESSAGE >-" >-); >-AddReturn( 'barcode_3', $branchcode_1 ); >-$item->discard_changes; >-is( >- $item->notforloan, 1, >- q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} >-); >+ t::lib::Mocks::mock_preference( >+ 'UpdateNotForLoanStatusOnCheckin', "$itemtype:\n >+ 1: ONLYMESSAGE >+ " >+ ); >+ AddReturn( 'barcode_3', $branchcode_1 ); >+ $item->discard_changes; >+ is( >+ $item->notforloan, 1, >+ q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} >+ ); >+}; > > ############################################## > # >@@ -537,7 +541,7 @@ subtest 'AddReturn: Update notforloanstatus according to UpdateNotForLoanStatusO > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); > AddIssue( $patron_2, 'barcode_6', dt_from_string ); >- $item = Koha::Items->find($itemnumber4); >+ my $item = Koha::Items->find($itemnumber4); > ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); > AddReturn( 'barcode_6', $branchcode_1 ); > >@@ -629,7 +633,7 @@ subtest '_updateNotForLoanFromYaml' => sub { > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); >- $item = Koha::Items->find($itemnumber4); >+ my $item = Koha::Items->find($itemnumber4); > $item->notforloan(-1)->store; > C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' ); > ok( >@@ -772,7 +776,7 @@ my $item2 = Koha::Items->find($itemnumber2); > ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); > > t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); >-$log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); >+my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); > AddReturn( 'barcode_4', $branchcode_1 ); > $item2 = Koha::Items->find($itemnumber2); > is( >@@ -783,7 +787,7 @@ is( > $item2->permanent_location, 'GEN', > q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} > ); >-$log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); >+my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); > is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); > AddReturn( 'barcode_4', $branchcode_1 ); > $item2 = Koha::Items->find($itemnumber2); >-- >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 35292
:
175201
|
175202
|
175203
|
175316
|
175317
|
175318
|
175319
|
175320
|
175321
|
175322
|
179818
|
179819
|
179820
|
179821
|
179822
|
179823
|
179824
|
180101
|
180102
|
180103
|
180104
|
180105
|
180106
|
180181
|
180182
|
180183
|
180184
|
180185
|
180186
|
180210
|
180212
|
180213
|
180214
|
180215
|
180216
|
180217
|
180218
|
180632
|
180633
|
180634
|
180635
|
180636
|
180637
|
180638
|
180646