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>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
(cherry picked from commit 26ffc16c38)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
This commit is contained in:
parent
b3f525497b
commit
00457f7e73
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue