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

(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-2 / +55 lines)
Lines 30-36 use Koha::CirculationRules; Link Here
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
use t::lib::Mocks;
31
use t::lib::Mocks;
32
32
33
use Test::More tests => 21;
33
use Test::More tests => 22;
34
34
35
my $dbh    = C4::Context->dbh;
35
my $dbh    = C4::Context->dbh;
36
my $schema = Koha::Database->new()->schema();
36
my $schema = Koha::Database->new()->schema();
Lines 246-249 Koha::CirculationRules->set_rule( Link Here
246
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
246
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
247
is( $data->{duration}, 2, "Circulation rules override system preferences" );
247
is( $data->{duration}, 2, "Circulation rules override system preferences" );
248
248
249
250
subtest "Test patron's own holds do not count towards HighHolds count" => sub {
251
252
    plan tests => 2;
253
254
    my $item = $builder->build_sample_item();
255
    my $item2 = $builder->build_sample_item({ biblionumber => $item->biblionumber });
256
    my $item3 = $builder->build_sample_item({ biblionumber => $item->biblionumber });
257
258
    my $patron = $builder->build_object({
259
        class => 'Koha::Patrons',
260
        value => {
261
            branchcode => $item->homebranch
262
        }
263
    });
264
    my $hold = $builder->build_object({
265
        class => 'Koha::Holds',
266
        value => {
267
            biblionumber => $item->biblionumber,
268
            borrowernumber => $patron->id,
269
            suspend => 0,
270
            found => undef
271
        }
272
    });
273
274
    Koha::CirculationRules->set_rules(
275
        {
276
            branchcode   => $item->homebranch,
277
            categorycode => undef,
278
            itemtype     => $item->itype,
279
            rules        => {
280
                issuelength     => '14',
281
                lengthunit      => 'days',
282
                reservesallowed => '99',
283
                holds_per_record => '1',
284
            }
285
        }
286
    );
287
288
    t::lib::Mocks::mock_preference( 'decreaseLoanHighHolds',               1 );
289
    t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsDuration',       1 );
290
    t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsValue',          1 );
291
    t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl',        'static' );
292
    t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' );
293
294
    my $data = C4::Circulation::checkHighHolds( $item->unblessed , $patron->unblessed );
295
    ok( !$data->{exceeded}, "Patron's hold on the record does not limit their own circulation if static decrease");
296
    t::lib::Mocks::mock_preference( 'decreaseLoanHighHoldsControl',        'dynamic' );
297
    # 3 items on record, patron has 1 hold
298
    $data = C4::Circulation::checkHighHolds( $item->unblessed , $patron->unblessed );
299
    ok( !$data->{exceeded}, "Patron's hold on the record does not limit their own circulation if dynamic decrease");
300
301
};
302
249
$schema->storage->txn_rollback();
303
$schema->storage->txn_rollback();
250
- 

Return to bug 29102