Bug 14310 [QA Followup] - Add unit tests
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
This commit is contained in:
parent
c60c8f0821
commit
2566dbdc4d
1 changed files with 22 additions and 5 deletions
|
@ -23,8 +23,9 @@ use Koha::Database;
|
||||||
use Koha::Borrowers;
|
use Koha::Borrowers;
|
||||||
use Koha::Libraries;
|
use Koha::Libraries;
|
||||||
use Koha::Item;
|
use Koha::Item;
|
||||||
|
use Koha::DateUtils;
|
||||||
|
|
||||||
use Test::More tests => 23;
|
use Test::More tests => 31;
|
||||||
|
|
||||||
use_ok('Koha::Hold');
|
use_ok('Koha::Hold');
|
||||||
|
|
||||||
|
@ -57,16 +58,32 @@ $item->store();
|
||||||
|
|
||||||
my $hold = Koha::Hold->new(
|
my $hold = Koha::Hold->new(
|
||||||
{
|
{
|
||||||
biblionumber => $biblionumber,
|
biblionumber => $biblionumber,
|
||||||
itemnumber => $item->id(),
|
itemnumber => $item->id(),
|
||||||
found => 'W',
|
|
||||||
waitingdate => '2000-01-01',
|
waitingdate => '2000-01-01',
|
||||||
borrowernumber => $borrower->borrowernumber(),
|
borrowernumber => $borrower->borrowernumber(),
|
||||||
branchcode => $branches[1]->branchcode(),
|
branchcode => $branches[1]->branchcode(),
|
||||||
|
suspend => 0,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$hold->store();
|
$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();
|
$item = $hold->item();
|
||||||
|
|
||||||
my $hold_borrower = $hold->borrower();
|
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' );
|
is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' );
|
||||||
|
|
||||||
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' );
|
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( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set" );
|
||||||
|
|
||||||
is( $hold->is_waiting, 1, 'The hold is waiting' );
|
is( $hold->is_waiting, 1, 'The hold is waiting' );
|
||||||
|
|
Loading…
Reference in a new issue