From d4a97bb5aefc2157586577c1c2c7f3331926dae0 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Fri, 6 Oct 2017 08:03:56 +0000 Subject: [PATCH] Bug 14919: Add test for Koha::Patron->old_holds subroutine Signed-off-by: Katrin Fischer Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- t/db_dependent/Koha/Patrons.t | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index a0a19fdb21..bea2a02cbb 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -615,8 +615,8 @@ subtest 'search_upcoming_membership_expires' => sub { Koha::Patrons->search({ borrowernumber => { in => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber}, $patron_3->{borrowernumber} ] } })->delete; }; -subtest 'holds' => sub { - plan tests => 3; +subtest 'holds and old_holds' => sub { + plan tests => 6; my $library = $builder->build( { source => 'Branch' } ); my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); @@ -673,6 +673,18 @@ subtest 'holds' => sub { $holds = $patron->holds; is( $holds->count, 2, 'There should be 2 holds placed by this patron' ); + my $old_holds = $patron->old_holds; + is( ref($old_holds), 'Koha::Old::Holds', + 'Koha::Patron->old_holds should return a Koha::Old::Holds objects' ); + is( $old_holds->count, 0, 'There should not be any old holds yet'); + + my $hold = $holds->next; + $hold->cancel; + + $old_holds = $patron->old_holds; + is( $old_holds->count, 1, 'There should be 1 old (cancelled) hold'); + + $old_holds->delete; $holds->delete; $patron->delete; };