From 11983fc8852a99720463b504eec699db8f00eb7f 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 --- t/db_dependent/Koha/Item.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 8be4d4525c..ecf05bf98e 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 => 15; +use Test::More tests => 16; use Test::Exception; use Test::MockModule; @@ -1454,3 +1454,25 @@ subtest 'Recalls tests' => 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.34.1