From 9d627a1240796e9cb8e746c10268ec8b1ab07cc6 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 20 May 2022 11:45:54 -0300 Subject: [PATCH] Bug 30825: Add unit tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall --- t/db_dependent/Koha/Item.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 176e8feed17..d7f530da7e2 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 => 30; +use Test::More tests => 31; use Test::Exception; use Test::MockModule; @@ -2295,3 +2295,26 @@ subtest 'current_branchtransfers relationship' => sub { $schema->storage->txn_rollback; }; + +subtest 'holds_control_library() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); + my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); + + my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_1->id } }); + my $item = $builder->build_sample_item({ library => $library_2->id }); + + t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'ItemHomeLibrary' ); + + is( $item->holds_control_library( $patron ), $library_2->id ); + + t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); + + is( $item->holds_control_library( $patron ), $library_1->id ); + + $schema->storage->txn_rollback; +}; -- 2.25.1