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

(-)a/t/db_dependent/Koha/Account.t (-3 / +33 lines)
Lines 924-930 subtest 'pay() handles lost items when paying by amount ( not specifying the los Link Here
924
924
925
subtest 'pay() renews items when appropriate' => sub {
925
subtest 'pay() renews items when appropriate' => sub {
926
926
927
    plan tests => 1;
927
    plan tests => 7;
928
928
929
    $schema->storage->txn_begin;
929
    $schema->storage->txn_begin;
930
930
Lines 975-981 subtest 'pay() renews items when appropriate' => sub { Link Here
975
    my $module = Test::MockModule->new('C4::Circulation');
975
    my $module = Test::MockModule->new('C4::Circulation');
976
    $module->mock('AddRenewal', sub { $called = 1; });
976
    $module->mock('AddRenewal', sub { $called = 1; });
977
    $module->mock('CanBookBeRenewed', sub { return 1; });
977
    $module->mock('CanBookBeRenewed', sub { return 1; });
978
    $account->pay(
978
    my $result = $account->pay(
979
        {
979
        {
980
            amount     => '1',
980
            amount     => '1',
981
            library_id => $library->id,
981
            library_id => $library->id,
Lines 983-988 subtest 'pay() renews items when appropriate' => sub { Link Here
983
    );
983
    );
984
984
985
    is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' );
985
    is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' );
986
    is(ref($result->{renew_result}), 'ARRAY', "Pay result contains 'renew_result' ARRAY" );
987
    is( scalar @{$result->{renew_result}}, 1, "renew_result contains one renewal result" );
988
    is( $result->{renew_result}->[0]->{itemnumber}, $item->id, "renew_result contains itemnumber of renewed item" );
989
990
    # Reset test by adding a new overdue
991
    Koha::Account::Line->new(
992
        {
993
            issue_id       => $checkout->id,
994
            borrowernumber => $patron->id,
995
            itemnumber     => $item->id,
996
            date           => \'NOW()',
997
            debit_type_code => 'OVERDUE',
998
            status         => 'UNRETURNED',
999
            interface      => 'cli',
1000
            amount => '1',
1001
            amountoutstanding => '1',
1002
        }
1003
    )->store();
1004
    $called = 0;
1005
1006
    t::lib::Mocks::mock_preference( 'RenewAccruingItemWhenPaid', 0 );
1007
    $result = $account->pay(
1008
        {
1009
            amount     => '1',
1010
            library_id => $library->id,
1011
        }
1012
    );
1013
1014
    is( $called, 0, 'C4::Circulation::AddRenew NOT called when RenewAccruingItemWhenPaid disabled' );
1015
    is(ref($result->{renew_result}), 'ARRAY', "Pay result contains 'renew_result' ARRAY" );
1016
    is( scalar @{$result->{renew_result}}, 0, "renew_result contains no renewal results" );
986
1017
987
    $schema->storage->txn_rollback;
1018
    $schema->storage->txn_rollback;
988
};
1019
};
989
- 

Return to bug 25508