Bug 37651: Unit tests
Test plan:
Run t/db_dependent/Holds.t (Without previous patches, it would fail.)
Run t/db_dependent/Koha/Biblios.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ae5c6bbbee)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
1512257d40
commit
cec7863006
|
|
@ -7,7 +7,7 @@ use t::lib::TestBuilder;
|
|||
|
||||
use C4::Context;
|
||||
|
||||
use Test::More tests => 73;
|
||||
use Test::More tests => 74;
|
||||
use Test::NoWarnings;
|
||||
use Test::Exception;
|
||||
|
||||
|
|
@ -2109,3 +2109,26 @@ subtest 'EmailPatronWhenHoldIsPlaced tests' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'current_holds with future holds' => sub {
|
||||
plan tests => 2;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 2 );
|
||||
my $item = $builder->build_sample_item;
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $hold_id = AddReserve(
|
||||
{
|
||||
reservation_date => dt_from_string()->add( days => 1 ),
|
||||
branchcode => $item->homebranch,
|
||||
borrowernumber => $patron->id,
|
||||
biblionumber => $item->biblionumber,
|
||||
itemnumber => $item->itemnumber,
|
||||
}
|
||||
);
|
||||
is( $item->biblio->current_holds->count, 1, 'Future hold was counted' );
|
||||
t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 );
|
||||
is( $item->biblio->current_holds->count, 0, 'No future hold was counted when ConfirmFutureHolds is zero' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ subtest 'store' => sub {
|
|||
};
|
||||
|
||||
subtest 'holds + current_holds' => sub {
|
||||
plan tests => 5;
|
||||
plan tests => 6;
|
||||
C4::Reserves::AddReserve(
|
||||
{
|
||||
branchcode => $patron->branchcode,
|
||||
|
|
@ -85,12 +85,16 @@ subtest 'holds + current_holds' => sub {
|
|||
reservation_date => dt_from_string->add( days => 2 ),
|
||||
}
|
||||
);
|
||||
t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 );
|
||||
$holds = $biblio->holds;
|
||||
is( $holds->count, 1, '->holds should return future holds' );
|
||||
$holds = $biblio->current_holds;
|
||||
is( $holds->count, 0, '->current_holds should not return future holds' );
|
||||
is( $holds->count, 0, '->current_holds without lookahead should not return future holds' );
|
||||
t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 2 );
|
||||
$holds = $biblio->current_holds;
|
||||
is( $holds->count, 1, '->current_holds with lookahead returns future holds' );
|
||||
$holds->delete;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 );
|
||||
};
|
||||
|
||||
subtest 'waiting_or_in_transit' => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue