From 6bc85707baf453778b38856f32025aa84f4f2c14 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 16 Aug 2022 10:10:03 -0300 Subject: [PATCH] Bug 31313: Unit tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Item.t | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 4ad1604f60..b274f0d688 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -20,7 +20,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 25; +use Test::More tests => 26; use Test::Exception; use Test::MockModule; @@ -32,6 +32,7 @@ use Koha::Items; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Old::Items; +use Koha::Recalls; use List::MoreUtils qw(all); @@ -1722,3 +1723,29 @@ subtest 'item_group() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'has_pending_recall() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $library = $builder->build_object({ class => 'Koha::Libraries' }); + my $item = $builder->build_sample_item; + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + + t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode }); + t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); + + C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); + + my ($recall) = Koha::Recalls->add_recall({ biblio => $item->biblio, item => $item, patron => $patron }); + + ok( !$item->has_pending_recall, 'The item has no pending recalls' ); + + $recall->status('waiting')->store; + + ok( $item->has_pending_recall, 'The item has a pending recall' ); + + $schema->storage->txn_rollback; +}; -- 2.34.1