From 5a44fc4f27de79c3460d7782eb3769e9b6e11bb2 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Wed, 12 Oct 2022 13:10:50 -0400 Subject: [PATCH] Bug 24860: (QA follow-up) Add unit tests to cover Koha::Hold::item_group --- t/db_dependent/Koha/Hold.t | 46 +++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t index 5aeebd073a..1c93c77523 100755 --- a/t/db_dependent/Koha/Hold.t +++ b/t/db_dependent/Koha/Hold.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Exception; use Test::MockModule; @@ -863,3 +863,47 @@ subtest 'cancellation_requestable_from_opac() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'Koha::Hold::item_group tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $category = $builder->build_object( + { + class => 'Koha::Patron::Categories', + value => { exclude_from_local_holds_priority => 0 } + } + ); + my $patron = $builder->build_object( + { + class => "Koha::Patrons", + value => { + branchcode => $library->branchcode, + categorycode => $category->categorycode + } + } + ); + my $biblio = $builder->build_sample_biblio(); + + my $item_group = + Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store(); + + my $hold = $builder->build_object( + { + class => "Koha::Holds", + value => { + borrowernumber => $patron->borrowernumber, + biblionumber => $biblio->biblionumber, + priority => 1, + item_group_id => $item_group->id, + } + } + ); + + is( $hold->item_group->id, $item_group->id, "Got correct item group" ); + + $schema->storage->txn_rollback; +}; -- 2.30.2