Bugzilla – Attachment 131820 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), 8.48 KB, created by
Alex Buckley
on 2022-03-16 23:57:22 UTC
(
hide
)
Description:
Bug 25560: Unit tests
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2022-03-16 23:57:22 UTC
Size:
8.48 KB
patch
obsolete
>From b2c7db6d851e837dd77b867ebb58baded6df1bc1 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Fri, 22 May 2020 04:43:02 +0000 >Subject: [PATCH] Bug 25560: Unit tests > >Test plan: >1. Run tests >sudo koha-shell <instancename> >prove xt >prove t/db_dependent/Circulation/issue.t >prove t/db_dependent/Koha/Object.t > >Sponsored-By: Waikato Institute of Technology, NZ > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Circulation/issue.t | 83 ++++++++++++++++++++++++++++-- > t/db_dependent/Koha/Object.t | 4 +- > 2 files changed, 82 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index f953b04dc5..4c90efcd72 100755 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -17,9 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 48; >+use Test::More tests => 59; > use DateTime::Duration; >- > use t::lib::Mocks; > use t::lib::TestBuilder; > >@@ -75,9 +74,15 @@ $dbh->do(q|DELETE FROM statistics|); > # Generate sample datas > my $itemtype = $builder->build( > { source => 'Itemtype', >- value => { notforloan => undef, rentalcharge => 0 } >+ value => { notforloan => undef, rentalcharge => 0, updatenotforloan => 1 } >+ } >+)->{itemtype}; >+my $itemtype2 = $builder->build( >+ { source => 'Itemtype', >+ value => { notforloan => undef, updatenotforloan => 0 } > } > )->{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}; >@@ -124,10 +129,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'; >@@ -391,7 +403,8 @@ my $itemnumber = Koha::Item->new( > homebranch => $branchcode_1, > holdingbranch => $branchcode_1, > notforloan => 1, >- itype => $itemtype >+ itype => $itemtype, >+ biblioitemnumber => $biblioitemnumber > }, > )->store->itemnumber; > >@@ -409,6 +422,67 @@ 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"} ); > >+# Bug 25560: Exclude itemtypes from UpdateNotForLoanStatusOnCheckin syspref >+ >+# item-level_itypes syspref is set to 'Specific item' >+t::lib::Mocks::mock_preference( 'item-level_itypes', '1' ); >+ >+# Set biblioitems.itemtype to an itemtype with updatenotforloan = 0 >+Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store; >+ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloan eq 0, q{Biblio-level itemtype has a updatenotforloan set to 0} ); >+ >+# Keep items.itype on an itemtype with updatenotforloan = 1 >+ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 1, q{item level itemtype has a updatenotforloan set to 1}); >+ >+# items.notforloan status should change as the effective itemtype (item-level itype) >+# does allow notforloan status to be updated on checkin >+t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1'); >+AddReturn( 'barcode_3', $branchcode_1 ); >+$item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does update the notforloan value when ithe effective itemtype (specific item) has an enabled updatenotforloan flag} ); >+ >+# Set biblioitems.itemtype to an itemtype with updatenotforloan = 1 >+Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber)->store; >+ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber })->itemtype)->updatenotforloan eq 1, q{Biblio-level itemtype has a updatenotforloan set to 1 }); >+ >+# Set items.itype to an itemtype with updatenotforloanstatus = 0 >+Koha::Items->find( $itemnumber )->itype($itemtype2)->store; >+ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 0, q{item level itemtype has an updatenotforloan set to 0 }); >+ >+# items.notforloan status shouldn't change as the effective itemtype (item-level itype) >+# does not allow notforloan status to be updated on checkin >+t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9'); >+AddReturn( 'barcode_3', $branchcode_1 ); >+$item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value when th effective item type (specific item) has a disabled updatenotforloan flag} ); >+ >+# item-level_itypes syspref is set to 'bibliographic record' >+t::lib::Mocks::mock_preference( 'item-level_itypes', '0' ); >+ >+# Check items.itype is still an itemtype with updatenotforloan = 0 >+ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 0, q{item level itype has a updatenotforloanstatuscheckin set to 0}); >+ >+# items.notforloan status should change as the effective itemtype (biblio-level itemtype) >+# does allow notforloan status to be updated on checkin >+AddReturn( 'barcode_3', $branchcode_1 ); >+$item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value when the effective item type (bibliographic record) has an enabled updatenotforloan flag} ); >+ >+# Set biblioitems.itemtype to an itemtype with updatenotforloan = 0 >+Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store; >+ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloan eq 0, q{Biblio-level itemtype has a updatenotforloan set to 0 }); >+ >+# Set items.itype to an itemtype with updatenotforloan = 1 >+Koha::Items->find( $itemnumber )->itype($itemtype)->store; >+ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 1, q{item level itype has an updatenotforloan set to 1}); >+ >+# items.notforloan status shouldn't change as the effective itemtype (biblio-level itemtype) >+# doesn't allow notforloan status to be updated at checkin >+t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1'); >+AddReturn( 'barcode_3', $branchcode_1 ); >+$item = Koha::Items->find( $itemnumber ); >+ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloanvalue when the effective itemtype (bibliographic record) has a disabled updatenotforloan flag} ); >+ > my $itemnumber2 = Koha::Item->new( > { > biblionumber => $biblionumber, >@@ -488,6 +562,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, >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index 10c94c38e3..3e9ae3ea01 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -697,7 +697,7 @@ subtest "Test update method" => sub { > > subtest 'store() tests' => sub { > >- plan tests => 16; >+ plan tests => 17; > > # Using Koha::Library::Groups to test Koha::Object>-store > # Simple object with foreign keys and unique key >@@ -799,6 +799,7 @@ subtest 'store() tests' => sub { > rentalcharge => "", > notforloan => "", > hideinopac => "", >+ updatenotforloan => "", > } > )->store; > }; >@@ -806,6 +807,7 @@ subtest 'store() tests' => sub { > is( $itemtype->rentalcharge, undef, 'decimal DEFAULT NULL should default to null'); > is( $itemtype->notforloan, undef, 'int DEFAULT NULL should default to null'); > is( $itemtype->hideinopac, 0, 'int NOT NULL DEFAULT 0 should default to 0'); >+ is( $itemtype->updatenotforloan, 1, 'int NOT NULL DEFAULT 1 should default to 1'); > > subtest 'Bad value tests' => sub { > >-- >2.20.1
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