From 748ee44e59d43442f3c58537032d639cb4380ec8 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 16 Oct 2015 11:02:18 -0400 Subject: [PATCH] Bug 14310 [QA Followup] - Add unit tests --- t/db_dependent/Hold.t | 27 ++++++++++++++++++++++----- 1 files changed, 22 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index ae8c19d..2808c97 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -23,8 +23,9 @@ use Koha::Database; use Koha::Borrowers; use Koha::Branches; use Koha::Item; +use Koha::DateUtils; -use Test::More tests => 23; +use Test::More tests => 31; use_ok('Koha::Hold'); @@ -57,16 +58,32 @@ $item->store(); my $hold = Koha::Hold->new( { - biblionumber => $biblionumber, - itemnumber => $item->id(), - found => 'W', + biblionumber => $biblionumber, + itemnumber => $item->id(), waitingdate => '2000-01-01', borrowernumber => $borrower->borrowernumber(), branchcode => $branches[1]->branchcode(), + suspend => 0, } ); $hold->store(); +is( $hold->suspend, 0, "Hold is not suspended" ); +$hold->suspend_hold(); +is( $hold->suspend, 1, "Hold is suspended" ); +$hold->resume(); +is( $hold->suspend, 0, "Hold is not suspended" ); +my $dt = dt_from_string(); +$hold->suspend_hold( $dt ); +is( $hold->suspend, 1, "Hold is suspended" ); +is( $hold->suspend_until, "$dt", "Hold is suspended with a date" ); +$hold->resume(); +is( $hold->suspend, 0, "Hold is not suspended" ); +is( $hold->suspend_until, undef, "Hold no longer has suspend_until date" ); +$hold->found('W'); +$hold->suspend_hold(); +is( $hold->suspend, 0, "Waiting hold cannot be suspended" ); + $item = $hold->item(); my $hold_borrower = $hold->borrower(); @@ -74,7 +91,7 @@ ok( $hold_borrower, 'Got hold borrower' ); is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' ); C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' ); -my $dt = $hold->waiting_expires_on(); +$dt = $hold->waiting_expires_on(); is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set" ); is( $hold->is_waiting, 1, 'The hold is waiting' ); -- 1.7.2.5