@@ -, +, @@ --- t/db_dependent/Koha/Item.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) --- a/t/db_dependent/Koha/Item.t +++ a/t/db_dependent/Koha/Item.t @@ -20,7 +20,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 29; +use Test::More tests => 30; use Test::Exception; use Test::MockModule; @@ -2211,3 +2211,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; +}; --