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

(-)a/t/db_dependent/SIP/Transaction.t (-2 / +108 lines)
Lines 4-10 Link Here
4
# Current state is very rudimentary. Please help to extend it!
4
# Current state is very rudimentary. Please help to extend it!
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::More tests => 16;
7
use Test::More tests => 17;
8
8
9
use Koha::Database;
9
use Koha::Database;
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
Lines 439-444 subtest do_checkin => sub { Link Here
439
    };
439
    };
440
};
440
};
441
441
442
subtest do_checkout_with_sysprefs_override => sub {
443
    plan tests => 8;
444
445
    my $mockILS = Test::MockObject->new;
446
    my $server = { ils => $mockILS };
447
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
448
    my $institution = {
449
        id             => $library->id,
450
        implementation => "ILS",
451
        policy         => {
452
            checkin  => "true",
453
            renewal  => "true",
454
            checkout => "true",
455
            timeout  => 100,
456
            retries  => 5,
457
        }
458
    };
459
    my $ils = C4::SIP::ILS->new($institution);
460
    my $item = $builder->build_sample_item(
461
        {
462
            library => $library->branchcode,
463
        }
464
    );
465
466
    my $patron_under_noissuescharge = $builder->build_object(
467
        {
468
            class => 'Koha::Patrons',
469
            value => {
470
                branchcode => $library->branchcode,
471
            }
472
        }
473
    );
474
475
    my $fee_under_noissuescharge = $builder->build(
476
        {
477
            source => 'Accountline',
478
            value  => {
479
                borrowernumber => $patron_under_noissuescharge->borrowernumber,
480
                amountoutstanding => 4,
481
            }
482
        }
483
    );
484
485
    my $patron_over_noissuescharge = $builder->build_object(
486
487
        {
488
            class => 'Koha::Patrons',
489
            value => {
490
                branchcode => $library->branchcode,
491
            }
492
        }
493
    );
494
495
    my $fee_over_noissuescharge = $builder->build(
496
        {
497
            source => 'Accountline',
498
            value  => {
499
                borrowernumber => $patron_over_noissuescharge->borrowernumber,
500
                amountoutstanding => 6,
501
            }
502
        }
503
    );
504
505
506
    $server->{account}->{override_fine_on_checkout} = 0;
507
508
    t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '0' );
509
    t::lib::Mocks::mock_preference( 'AllowFineOverride', '0' );
510
    my $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
511
    is( $patron_under_noissuescharge->checkouts->count, 1, 'Checkout is allowed when the amount is under noissuecharge, AllFinesNeedOverride and AllowFineOverride disabled');
512
513
    $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode );
514
515
    $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
516
    is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride and AllowFineOverride disabled');
517
518
    t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '0' );
519
    t::lib::Mocks::mock_preference( 'AllowFineOverride', '1' );
520
521
    $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
522
    is( $patron_under_noissuescharge->checkouts->count, 1, 'Checkout is allowed when the amount is under noissuecharge, AllFinesNeedOverride disabled and AllowFineOverride enabled');
523
524
    $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode );
525
526
    $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
527
    is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride disabled and AllowFineOverride enabled');
528
529
    t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '1' );
530
    t::lib::Mocks::mock_preference( 'AllowFineOverride', '0' );
531
532
    $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
533
    is( $patron_under_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is under noissuecharge, AllFinesNeedOverride enabled and AllowFineOverride disabled');
534
535
    $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
536
    is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride enabled and AllowFineOverride disabled');
537
538
    t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '1' );
539
    t::lib::Mocks::mock_preference( 'AllowFineOverride', '1' );
540
541
    $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
542
    is( $patron_under_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is under noissuecharge, AllFinesNeedOverride and AllowFineOverride enabled');
543
544
    $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account});
545
    is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride and AllowFineOverride enabled');
546
};
547
548
442
subtest do_checkout_with_patron_blocked => sub {
549
subtest do_checkout_with_patron_blocked => sub {
443
    plan tests => 4;
550
    plan tests => 4;
444
551
445
- 

Return to bug 32408