Bugzilla – Attachment 190854 Details for
Bug 41510
Fallback on bookable itemtype can break if item has no itemtype
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41510: Add test for effective_bookable with missing itemtype
Bug-41510-Add-test-for-effectivebookable-with-miss.patch (text/plain), 2.15 KB, created by
David Nind
on 2026-01-03 02:48:04 UTC
(
hide
)
Description:
Bug 41510: Add test for effective_bookable with missing itemtype
Filename:
MIME Type:
Creator:
David Nind
Created:
2026-01-03 02:48:04 UTC
Size:
2.15 KB
patch
obsolete
>From af1f4d4c1c35efea949e20edc503bbaf477edd20 Mon Sep 17 00:00:00 2001 >From: Paul Derscheid <paul.derscheid@lmscloud.de> >Date: Fri, 2 Jan 2026 11:16:21 +0100 >Subject: [PATCH] Bug 41510: Add test for effective_bookable with missing > itemtype > >- Add test case for the scenario where an item has no itemtype > because both items.itype and biblioitems.itemtype are NULL >- Note: We must set biblioitems.itemtype to NULL before creating the > item because Koha::Item->store() automatically populates itype from > biblioitems.itemtype when itype is not set > >Test plan: >- Apply this patch only >- Run: prove t/db_dependent/Koha/Item.t :: effective_bookable >- Verify test 6 FAILS with "Can't call method 'bookable' on an > undefined value" >- Apply the follow-up patch >- Run the test again >- Verify all tests PASS > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/Item.t | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 2485928770..bb74943bcf 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -3846,7 +3846,7 @@ subtest 'effective_not_for_loan_status() tests' => sub { > > subtest 'effective_bookable() tests' => sub { > >- plan tests => 5; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -3897,5 +3897,20 @@ subtest 'effective_bookable() tests' => sub { > '->effective_bookable returns item specific bookable value when item bookable is defined' > ); > >+ my $biblio_no_itype = $builder->build_sample_biblio; >+ $biblio_no_itype->biblioitem->set({ itemtype => undef })->store; >+ my $item_no_itype = $builder->build_sample_item({ >+ biblionumber => $biblio_no_itype->biblionumber, >+ itype => undef, >+ }); >+ warning_like { >+ is( >+ $item_no_itype->effective_bookable, 0, >+ '->effective_bookable returns 0 when item has no itemtype and item bookable is undefined' >+ ); >+ } >+ qr/item-level_itypes set but no itemtype set for item/, >+ 'Warning raised for missing itemtype when item-level_itypes is set'; >+ > $schema->storage->txn_rollback; > }; >-- >2.39.5
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 41510
:
190820
|
190821
| 190854 |
190855