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

(-)a/t/db_dependent/Circulation/MarkIssueReturned.t (-2 / +37 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 3;
20
use Test::More tests => 4;
21
use Test::Exception;
21
use Test::Exception;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 27-34 use C4::Circulation; Link Here
27
use C4::Context;
27
use C4::Context;
28
use Koha::Checkouts;
28
use Koha::Checkouts;
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils qw(dt_from_string);
30
use Koha::Old::Checkouts;
31
use Koha::Old::Checkouts;
31
use Koha::Patrons;
32
use Koha::Patrons;
33
use Koha::Patron::Debarments;
32
34
33
my $schema = Koha::Database->schema;
35
my $schema = Koha::Database->schema;
34
my $builder = t::lib::TestBuilder->new;
36
my $builder = t::lib::TestBuilder->new;
Lines 188-190 subtest 'Manually pass a return date' => sub { Link Here
188
190
189
    $schema->storage->txn_rollback;
191
    $schema->storage->txn_rollback;
190
};
192
};
191
- 
193
194
subtest 'AutoRemoveOverduesRestrictions' => sub {
195
    plan tests => 2;
196
197
    t::lib::Mocks::mock_preference('AutoRemoveOverduesRestrictions', 1);
198
199
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
200
    t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } );
201
    my $item_1 = $builder->build_sample_item;
202
    my $item_2 = $builder->build_sample_item;
203
    my $item_3 = $builder->build_sample_item;
204
    my $five_days_ago = dt_from_string->subtract( days => 5 );
205
    my $checkout_1 = AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # overdue
206
    my $checkout_2 = AddIssue( $patron->unblessed, $item_2->barcode, $five_days_ago ); # overdue
207
    my $checkout_3 = AddIssue( $patron->unblessed, $item_3->barcode ); # not overdue
208
209
    Koha::Patron::Debarments::AddUniqueDebarment(
210
        {
211
            borrowernumber => $patron->borrowernumber,
212
            type           => 'OVERDUES',
213
            comment => "OVERDUES_PROCESS simulation",
214
        }
215
    );
216
217
    C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_1->itemnumber );
218
219
    my $debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber });
220
    is( $debarments->[0]->{type}, 'OVERDUES', 'OVERDUES debarment is not removed if patron still has overdues' );
221
222
    C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item_2->itemnumber );
223
224
    $debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber });
225
    is( scalar @$debarments, 0, 'OVERDUES debarment is removed if patron does not have overdues' );
226
};

Return to bug 24413