Bug 34666: Unit test
Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
6f5915cf01
commit
99d7e55be6
1 changed files with 41 additions and 1 deletions
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
use Test::More tests => 77;
|
use Test::More tests => 78;
|
||||||
use Test::MockModule;
|
use Test::MockModule;
|
||||||
use Test::Warn;
|
use Test::Warn;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ use DateTime::Duration;
|
||||||
use C4::Circulation qw( AddReturn AddIssue );
|
use C4::Circulation qw( AddReturn AddIssue );
|
||||||
use C4::Items;
|
use C4::Items;
|
||||||
use C4::Biblio qw( GetMarcFromKohaField ModBiblio );
|
use C4::Biblio qw( GetMarcFromKohaField ModBiblio );
|
||||||
|
use C4::HoldsQueue;
|
||||||
use C4::Members;
|
use C4::Members;
|
||||||
use C4::Reserves qw( AddReserve AlterPriority CheckReserves GetReservesControlBranch ModReserve ModReserveAffect ReserveSlip CalculatePriority CanReserveBeCanceledFromOpac CanBookBeReserved IsAvailableForItemLevelRequest MoveReserve ChargeReserveFee RevertWaitingStatus CanItemBeReserved MergeHolds );
|
use C4::Reserves qw( AddReserve AlterPriority CheckReserves GetReservesControlBranch ModReserve ModReserveAffect ReserveSlip CalculatePriority CanReserveBeCanceledFromOpac CanBookBeReserved IsAvailableForItemLevelRequest MoveReserve ChargeReserveFee RevertWaitingStatus CanItemBeReserved MergeHolds );
|
||||||
use Koha::ActionLogs;
|
use Koha::ActionLogs;
|
||||||
|
@ -1773,3 +1774,42 @@ subtest 'DefaultHoldExpiration tests' => sub {
|
||||||
|
|
||||||
$schema->txn_rollback;
|
$schema->txn_rollback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
subtest '_Findgroupreserves' => sub {
|
||||||
|
plan tests => 1;
|
||||||
|
$schema->storage->txn_begin;
|
||||||
|
|
||||||
|
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||||
|
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||||
|
my $item = $builder->build_sample_item();
|
||||||
|
|
||||||
|
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
|
||||||
|
my $reserve_id_1 = AddReserve(
|
||||||
|
{
|
||||||
|
branchcode => $item->homebranch,
|
||||||
|
borrowernumber => $patron_1->id,
|
||||||
|
biblionumber => $item->biblionumber,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
my $reserve_id_2 = AddReserve(
|
||||||
|
{
|
||||||
|
branchcode => $item->homebranch,
|
||||||
|
borrowernumber => $patron_2->id,
|
||||||
|
biblionumber => $item->biblionumber,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
C4::HoldsQueue::AddToHoldTargetMap(
|
||||||
|
{
|
||||||
|
$item->id => {
|
||||||
|
borrowernumber => $patron_1->id, biblionumber => $item->biblionumber,
|
||||||
|
holdingbranch => $item->holdingbranch, item_level => 0, reserve_id => $reserve_id_1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# When the hold is title level and in the hold fill targets we expect this to be the only hold returned
|
||||||
|
my @reserves = C4::Reserves::_Findgroupreserve( $item->biblionumber, $item->id, 0, [] );
|
||||||
|
is( scalar @reserves, 1, "We should only get the hold that is in the map" );
|
||||||
|
$schema->txn_rollback;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue