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

(-)a/t/db_dependent/Circulation.t (-2 / +41 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 46;
21
use Test::More tests => 47;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Deep qw( cmp_deeply );
23
use Test::Deep qw( cmp_deeply );
24
24
Lines 40-47 use C4::Overdues qw(UpdateFine CalcFine); Link Here
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use Koha::Database;
41
use Koha::Database;
42
use Koha::Items;
42
use Koha::Items;
43
use Koha::Item::Transfers;
43
use Koha::Checkouts;
44
use Koha::Checkouts;
44
use Koha::Patrons;
45
use Koha::Patrons;
46
use Koha::Holds;
45
use Koha::CirculationRules;
47
use Koha::CirculationRules;
46
use Koha::Subscriptions;
48
use Koha::Subscriptions;
47
use Koha::Account::Lines;
49
use Koha::Account::Lines;
Lines 3647-3652 subtest "Test Backdating of Returns" => sub { Link Here
3647
    is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' );
3649
    is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' );
3648
};
3650
};
3649
3651
3652
subtest 'Filling a hold should cancel existing transfer' => sub {
3653
    plan tests => 4;
3654
3655
    t::lib::Mocks::mock_preference('AutomaticItemReturn', 1);
3656
3657
    my $libraryA = $builder->build_object( { class => 'Koha::Libraries' } )->store;
3658
    my $libraryB = $builder->build_object( { class => 'Koha::Libraries' } )->store;
3659
    my $patron = $builder->build_object(
3660
        {
3661
            class => 'Koha::Patrons',
3662
            value => {
3663
                categorycode => $patron_category->{categorycode},
3664
                branchcode => $libraryA->branchcode,
3665
            }
3666
        }
3667
    )->store;
3668
3669
    my $item = $builder->build_sample_item({
3670
        homebranch => $libraryB->branchcode,
3671
    });
3672
3673
    my ( undef, $message ) = AddReturn( $item->barcode, $libraryA->branchcode, undef, undef );
3674
    is( Koha::Item::Transfers->search({ itemnumber => $item->itemnumber, datearrived => undef })->count, 1, "We generate a transfer on checkin");
3675
    AddReserve(
3676
        $libraryA->branchcode, $patron->borrowernumber, $item->biblionumber, '',
3677
        1, undef, undef, '',
3678
        undef, $item->itemnumber, undef, undef
3679
    );
3680
    my $reserves = Koha::Holds->search({ itemnumber => $item->itemnumber });
3681
    is( $reserves->count, 1, "Reserve is placed");
3682
    ( undef, $message ) = AddReturn( $item->barcode, $libraryA->branchcode, undef, undef );
3683
    my $reserve = $reserves->next;
3684
    ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve->reserve_id );
3685
    $reserve->discard_changes;
3686
    ok( $reserve->found eq 'W', "Reserve is marked waiting" );
3687
    is( Koha::Item::Transfers->search({ itemnumber => $item->itemnumber, datearrived => undef })->count, 0, "No outstanding transfers when hold is waiting");
3688
};
3689
3650
$schema->storage->txn_rollback;
3690
$schema->storage->txn_rollback;
3651
C4::Context->clear_syspref_cache();
3691
C4::Context->clear_syspref_cache();
3652
$cache->clear_from_cache('single_holidays');
3692
$cache->clear_from_cache('single_holidays');
3653
- 

Return to bug 24620