From 56bb435fbe03a9b3f23040e6b7c11eae1817174c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 24 Jul 2018 15:43:06 +0200 Subject: [PATCH] Bug 20469: (follow-up) Add Koha::Holds->waiting_or_transit Content-Type: text/plain; charset=utf-8 Adding this variant next to existing ->waiting and ->unfilled methods. The method will be used in the next patch in Koha::Item. Trivial unit test added in Holds.t Test plan: Run t/db_dependent/Holds.t Signed-off-by: Marcel de Rooy --- Koha/Holds.pm | 12 ++++++++++++ t/db_dependent/Holds.t | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Koha/Holds.pm b/Koha/Holds.pm index f5da469..3ae9bcb 100644 --- a/Koha/Holds.pm +++ b/Koha/Holds.pm @@ -49,6 +49,18 @@ sub waiting { return $self->search( { found => 'W' } ); } +=head3 waiting_or_transit + +returns a set of holds that are waiting or in transit + +=cut + +sub waiting_or_transit { + my ( $self ) = @_; + + return $self->search({ found => ['W', 'T'] }); +} + =head3 unfilled returns a set of holds that are unfilled from an existing set diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 93fe745..cc38bc3e 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,7 +7,7 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 55; +use Test::More tests => 56; use MARC::Record; use C4::Biblio; use C4::Items; @@ -120,6 +120,7 @@ ok( $hold_branch == $hold->branch(), "branch method returns stashed branch" ); my $hold_found = $hold->found(); $hold->set({ found => 'W'})->store(); is( Koha::Holds->waiting()->count(), 1, "Koha::Holds->waiting returns waiting holds" ); +is( Koha::Holds->waiting_or_transit->count, 1, "Koha::Holds->waiting_or_transit returns 1 too" ); is( Koha::Holds->unfilled()->count(), 4, "Koha::Holds->unfilled returns unfilled holds" ); my $patron = Koha::Patrons->find( $borrowernumbers[0] ); -- 2.1.4