Browse Source

Bug 23964: Clarify and expand tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
remotes/origin/19.11.x
Jonathan Druart 5 years ago
committed by Martin Renvoize
parent
commit
b9422bef70
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 17
      t/db_dependent/Reserves.t

17
t/db_dependent/Reserves.t

@ -672,7 +672,7 @@ subtest '_koha_notify_reserve() tests' => sub {
};
subtest 'ReservesNeedReturns' => sub {
plan tests => 10;
plan tests => 13;
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
my $item_info = {
@ -709,33 +709,36 @@ subtest 'ReservesNeedReturns' => sub {
$item->onloan('2010-01-01')->store;
$hold = place_item_hold( $patron, $item, $library, $priority );
isnt( $hold->priority, 0, 'If ReservesNeedReturns is 0 but item onloan priority must not be set to 0' );
is( $hold->priority, 1, 'If ReservesNeedReturns is 0 but item onloan priority must be set to 1' );
$hold->delete;
t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 0); # '0' means damaged holds not allowed
$item->onloan(undef)->damaged(1)->store;
$hold = place_item_hold( $patron, $item, $library, $priority );
isnt( $hold->priority, 0, 'If ReservesNeedReturns is 0 but item damaged and not allowed holds on damaged items priority must not be set to 0' );
is( $hold->priority, 1, 'If ReservesNeedReturns is 0 but item damaged and not allowed holds on damaged items priority must be set to 1' );
$hold->delete;
t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1); # '0' means damaged holds not allowed
$hold = place_item_hold( $patron, $item, $library, $priority );
is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and damaged holds allowed, priority must have been set to 0' );
is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and damaged holds allowed, found must have been set waiting' );
is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and damaged holds allowed, found must have been set waiting' );
$hold->delete;
my $hold_1 = place_item_hold( $patron, $item, $library, $priority );
is( $hold_1->found, 'W', 'First hold on item is set to waiting with ReservesNeedReturns set to 0' );
is( $hold_1->priority, 0, 'First hold on item is set to waiting with ReservesNeedReturns set to 0' );
$hold = place_item_hold( $patron_2, $item, $library, $priority );
isnt( $hold->priority, 0, 'If ReservesNeedReturns is 0 but item already on hold priority must not be set to 0' );
is( $hold->priority, 1, 'If ReservesNeedReturns is 0 but item already on hold priority must be set to 1' );
$hold->delete;
$hold_1->delete;
$hold->delete;
$builder->build({ source => "Branchtransfer", value => {
itemnumber => $item->itemnumber,
datearrived => undef,
} });
$item->damaged(0)->store;
$hold = place_item_hold( $patron, $item, $library, $priority );
isnt( $hold->priority, 0, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
is( $hold->found, undef, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
is( $hold->priority, 1, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # Don't affect other tests
};

Loading…
Cancel
Save