From f01bf4b8199edcb96046e5a0b1a36177b74ab3b2 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 18 Jan 2024 19:58:32 +0000 Subject: [PATCH] Bug 16122: CanBookBeIssued unit test --- C4/Circulation.pm | 2 +- t/db_dependent/Circulation.t | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index deeb737ee3..2926326b9e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -836,7 +836,7 @@ sub CanBookBeIssued { ); #increment items.localuse - my $localuse_count = $item_object->localuse; + my $localuse_count = $item_object->localuse || 0; $localuse_count++; $item_object->localuse( $localuse_count )->store; diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 35e795f075..9376281512 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2434,7 +2434,7 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { }; subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { - plan tests => 11; + plan tests => 13; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $patron_category_x = $builder->build_object( @@ -2481,11 +2481,16 @@ subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { my $issue = AddIssue( $patron_2, $item_2->barcode ); $item_2->discard_changes; ok( $item_2->onloan, "Item is checked out" ); + is( $item_2->localuse, undef , 'No localuse is recorded.'); ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); $item_2->discard_changes; ok( !$item_2->onloan, "Checked out item is returned" ); + AddIssue( $patron, $item_2->barcode); + $item_2->discard_changes; # refresh + is( $item_2->localuse, 1 , 'Localuse is recorded.'); + # TODO There are other tests to provide here }; @@ -6217,7 +6222,6 @@ subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { }; - $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $branches = Koha::Libraries->search(); -- 2.30.2