From 0d5c224cc30a74a0b258bd3e929b82bbd3e2e088 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 22 Jul 2024 16:09:30 +0100 Subject: [PATCH] Bug 28762: Confirm return of not_for_loan in boolean context matches is_notforloan This patch is simply here to prove that is_notforloan is just not_for_loan but in a boolean context.. we'll remove it in the next patch. Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- Koha/Item.pm | 16 +--------------- t/db_dependent/Koha/Item.t | 6 +++--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 2c9318cc78..33ee8e0226 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2409,21 +2409,7 @@ the item's notforloan status or its item type sub is_notforloan { my ( $self ) = @_; - my $is_notforloan = 0; - - if ( $self->notforloan ){ - $is_notforloan = 1; - } - else { - my $itemtype = $self->itemtype; - if ($itemtype){ - if ( $itemtype->notforloan ){ - $is_notforloan = 1; - } - } - } - - return $is_notforloan; + return $self->not_for_loan; } =head3 is_denied_renewal diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index da3081f8dc..cd90a6ce7b 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -2251,12 +2251,12 @@ subtest 'Notforloan tests' => sub { my $item1 = $builder->build_sample_item; $item1->update({ notforloan => 0 }); $item1->itemtype->notforloan(0); - is ( $item1->is_notforloan, 0, 'Notforloan is correctly false by item status and item type'); + ok( !$item1->is_notforloan, 'Notforloan is correctly false by item status and item type'); $item1->update({ notforloan => 1 }); - is ( $item1->is_notforloan, 1, 'Notforloan is correctly true by item status'); + ok( $item1->is_notforloan, 'Notforloan is correctly true by item status'); $item1->update({ notforloan => 0 }); $item1->itemtype->update({ notforloan => 1 }); - is ( $item1->is_notforloan, 1, 'Notforloan is correctly true by item type'); + ok( $item1->is_notforloan, 'Notforloan is correctly true by item type'); $schema->storage->txn_rollback; }; -- 2.39.5