From 2ca41ee33df7c1edd09b660ec9357e04500e3cac Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 13 Jan 2025 22:37:19 +0000 Subject: [PATCH] Bug 37334: Add filter_by_recall test --- t/db_dependent/Koha/Items.t | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t index 7a2d3b7868f..79f9ada2229 100755 --- a/t/db_dependent/Koha/Items.t +++ b/t/db_dependent/Koha/Items.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 24; +use Test::More tests => 25; use Test::MockModule; use Test::Exception; @@ -2380,3 +2380,33 @@ subtest 'filter_by_in_bundle' => sub { $schema->storage->txn_rollback; }; + +subtest 'filter_by_has_recalls' => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + + $biblio = $builder->build_sample_biblio( { author => 'Hall, Daria' } ); + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } ); + + my $item = $builder->build_sample_item( + { + biblionumber => $biblio->biblionumber, + library => $library->branchcode, + } + ); + + C4::Circulation::AddIssue( $patron, $item->barcode ); + + is( $biblio->items->filter_by_has_recalls->count, 0, "0 items with recalls on this record" ); + + Koha::Recalls->add_recall( { biblio => $item->biblio, item => $item, patron => $patron } ); + + is( $biblio->items->filter_by_has_recalls->count, 1, "1 item with recalls on this record" ); + + $schema->storage->txn_rollback; + +}; -- 2.39.5