View | Details | Raw Unified | Return to bug 40435
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-2 / +52 lines)
Lines 19-25 use Modern::Perl; Link Here
19
use utf8;
19
use utf8;
20
20
21
use Test::NoWarnings;
21
use Test::NoWarnings;
22
use Test::More tests => 83;
22
use Test::More tests => 84;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Deep qw( cmp_deeply );
25
use Test::Deep qw( cmp_deeply );
Lines 1938-1943 subtest "CanBookBeRenewed | bookings" => sub { Link Here
1938
    $schema->storage->txn_rollback;
1938
    $schema->storage->txn_rollback;
1939
};
1939
};
1940
1940
1941
subtest "CanBookBeRenewed | future holds" => sub {
1942
    plan tests => 6;
1943
1944
    $schema->storage->txn_begin;
1945
    t::lib::Mocks::mock_preference( 'ConfirmFutureHolds',       3 );
1946
    t::lib::Mocks::mock_preference( 'FutureHoldsBlockRenewals', 1 );
1947
1948
    Koha::CirculationRules->set_rules(
1949
        {
1950
            categorycode => undef, branchcode => undef, itemtype => undef,
1951
            rules        => { renewalsallowed => 1, renewalperiod => 7 },
1952
        }
1953
    );
1954
1955
    my $future_date = DateTime->today->add( days => 2 );
1956
    my $patron1     = $builder->build_object( { class => 'Koha::Patrons' } );
1957
    my $patron2     = $builder->build_object( { class => 'Koha::Patrons' } );
1958
    my $item        = $builder->build_sample_item;
1959
    my $library     = $builder->build_object( { class => 'Koha::Libraries' } );
1960
    my $issue       = AddIssue( $patron1, $item->barcode );                       # not mangling userenv here
1961
    my $reserve_id  = AddReserve(
1962
        {
1963
            branchcode   => $library->branchcode, borrowernumber => $patron2->id,
1964
            biblionumber => $item->biblionumber,  itemnumber     => $item->id, reservation_date => $future_date
1965
        }
1966
    );
1967
    my $hold = Koha::Holds->find($reserve_id);
1968
1969
    # Future hold should block renewal
1970
    my ( $renewok, $error ) = CanBookBeRenewed( $patron1, $issue, 0 );
1971
    is( $renewok, 0,            'Cannot be renewed due to future hold' );
1972
    is( $error,   'on_reserve', 'Check error message' );
1973
1974
    # Move hold past 3 days limit so should be renewable
1975
    $hold->reservedate( $future_date->add( days => 2 ) )->store;
1976
    ( $renewok, $error ) = CanBookBeRenewed( $patron1, $issue, 0 );
1977
    is( $renewok, 1,     'Can be renewed when reservedate is too far' );
1978
    is( $error,   undef, 'No error message' );
1979
1980
    # Skip future holds for renewals
1981
    t::lib::Mocks::mock_preference( 'FutureHoldsBlockRenewals', 0 );
1982
    $hold->reservedate($future_date)->store;
1983
    ( $renewok, $error ) = CanBookBeRenewed( $patron1, $issue, 0 );
1984
    is( $renewok, 1,     'Can be renewed when future holds are skipped' );
1985
    is( $error,   undef, 'No error message 2' );
1986
1987
    t::lib::Mocks::mock_preference( 'ConfirmFutureHolds',       0 );
1988
    t::lib::Mocks::mock_preference( 'FutureHoldsBlockRenewals', 0 );
1989
    $schema->storage->txn_rollback;
1990
};
1991
1941
subtest "GetUpcomingDueIssues" => sub {
1992
subtest "GetUpcomingDueIssues" => sub {
1942
    plan tests => 12;
1993
    plan tests => 12;
1943
1994
1944
- 

Return to bug 40435