Bugzilla – Attachment 148683 Details for
Bug 25560
Define itemtype specific rules in the UpdateNotForLoanStatusOnCheckin system preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25560: Unit tests
Bug-25560-Unit-tests.patch (text/plain), 4.53 KB, created by
Kyle M Hall (khall)
on 2023-03-24 16:51:50 UTC
(
hide
)
Description:
Bug 25560: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-03-24 16:51:50 UTC
Size:
4.53 KB
patch
obsolete
>From 96dee7fea6f92a324e1e43bf2ba98f97e2e72417 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 1 Aug 2022 18:58:19 +0000 >Subject: [PATCH] Bug 25560: Unit tests > >Test plan: >1. Run tests >sudo koha-shell <instancename> >prove t/db_dependent/Circulation/issue.t > >Sponsored-By: Waikato Institute of Technology, NZ > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Circulation/issue.t | 38 ++++++++++++++++++++++++++---- > 1 file changed, 33 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index f388dab0076..9a28963b6c5 100755 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 49; >+use Test::More tests => 50; > use DateTime::Duration; > > use t::lib::Mocks; >@@ -77,6 +77,11 @@ my $itemtype = $builder->build( > value => { notforloan => undef, rentalcharge => 0 } > } > )->{itemtype}; >+my $itemtype2 = $builder->build( >+ { source => 'Itemtype', >+ value => { notforloan => undef } >+ } >+)->{itemtype}; > my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; > my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; > my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; >@@ -123,10 +128,17 @@ my $daysago10 = output_pref( > > # Add biblio and item > my $record = MARC::Record->new(); >+my $record2 = MARC::Record->new(); > $record->append_fields( >+ MARC::Field->new( '942', '0', '0', c => $itemtype ), >+ MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); >+ >+$record2->append_fields( >+ MARC::Field->new( '942', '0', '0', c => $itemtype2 ), > MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); > > my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); >+my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' ); > > my $barcode_1 = 'barcode_1'; > my $barcode_2 = 'barcode_2'; >@@ -385,7 +397,8 @@ my $itemnumber = Koha::Item->new( > homebranch => $branchcode_1, > holdingbranch => $branchcode_1, > notforloan => 1, >- itype => $itemtype >+ itype => $itemtype, >+ biblioitemnumber => $biblioitemnumber > }, > )->store->itemnumber; > >@@ -397,16 +410,30 @@ AddReturn( 'barcode_3', $branchcode_1 ); > my $item = Koha::Items->find( $itemnumber ); > ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); > >-t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); >+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 updates notforloan value from 1 to 9 with setting "1: 9"} ); >+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 does not update notforloan value from 9 with setting "1: 9"} ); >+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} ); > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: ONLYMESSAGE' ); > $item->notforloan(1)->store; >@@ -496,6 +523,7 @@ is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location val > > > # Bug 14640 - Cancel the hold on checking out if asked >+Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; > my $reserve_id = AddReserve( > { > branchcode => $branchcode_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 25560
:
105236
|
105237
|
105238
|
105239
|
105240
|
105241
|
105242
|
105243
|
105244
|
105245
|
109562
|
109563
|
109564
|
109565
|
109566
|
109567
|
112492
|
112887
|
113161
|
113212
|
113213
|
113214
|
113215
|
113216
|
113217
|
131816
|
131817
|
131818
|
131819
|
131820
|
135742
|
135743
|
136079
|
136080
|
136081
|
136082
|
136083
|
136084
|
138494
|
138495
|
138496
|
138497
|
138498
|
138499
|
146556
|
146557
|
146558
|
146559
|
146993
|
148679
|
148680
|
148681
|
148682
| 148683