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

(-)a/t/db_dependent/Circulation.t (-16 / +32 lines)
Lines 329-335 subtest "GetIssuingCharges tests" => sub { Link Here
329
329
330
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
330
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
331
subtest "CanBookBeRenewed tests" => sub {
331
subtest "CanBookBeRenewed tests" => sub {
332
    plan tests => 89;
332
    plan tests => 95;
333
333
334
    C4::Context->set_preference('ItemsDeniedRenewal','');
334
    C4::Context->set_preference('ItemsDeniedRenewal','');
335
    # Generate test biblio
335
    # Generate test biblio
Lines 464-469 subtest "CanBookBeRenewed tests" => sub { Link Here
464
            rule_value   => '1',
464
            rule_value   => '1',
465
        }
465
        }
466
    );
466
    );
467
    Koha::CirculationRules->set_rule(
468
        {
469
            categorycode => undef,
470
            branchcode   => undef,
471
            itemtype     => undef,
472
            rule_name    => 'renewalsallowed',
473
            rule_value   => '5',
474
        }
475
    );
467
    t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 );
476
    t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 );
468
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);
477
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);
469
    is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
478
    is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds');
Lines 567-572 subtest "CanBookBeRenewed tests" => sub { Link Here
567
    is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted');
576
    is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted');
568
    ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $item_5->itemnumber);
577
    ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $item_5->itemnumber);
569
    is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted');
578
    is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted');
579
    is( $error, 'restriction', "Correct error returned");
570
580
571
    # Users cannot renew an overdue item
581
    # Users cannot renew an overdue item
572
    my $item_6 = $builder->build_sample_item(
582
    my $item_6 = $builder->build_sample_item(
Lines 643-648 subtest "CanBookBeRenewed tests" => sub { Link Here
643
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
653
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
644
    $fines->delete();
654
    $fines->delete();
645
655
656
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','allow');
657
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
658
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
659
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
660
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is overdue but not pref does not block');
661
662
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','block');
663
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
664
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is not overdue but patron has overdues');
665
    is( $error, 'overdue', "Correct error returned");
666
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
667
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue so patron has overdues');
668
    is( $error, 'overdue', "Correct error returned");
669
670
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem');
671
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
672
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
673
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
674
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');
675
    is( $error, 'overdue', "Correct error returned");
676
646
677
647
    my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );
678
    my $old_issue_log_size = Koha::ActionLogs->count( \%params_issue );
648
    my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );
679
    my $old_renew_log_size = Koha::ActionLogs->count( \%params_renewal );
Lines 655-667 subtest "CanBookBeRenewed tests" => sub { Link Here
655
    $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
686
    $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
656
    $fines->delete();
687
    $fines->delete();
657
688
658
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem');
659
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
660
    is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue');
661
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
662
    is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue');
663
664
665
    $hold = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next;
689
    $hold = Koha::Holds->search({ biblionumber => $biblio->biblionumber, borrowernumber => $reserving_borrowernumber })->next;
666
    $hold->cancel;
690
    $hold->cancel;
667
691
Lines 1316-1328 subtest "CanBookBeRenewed tests" => sub { Link Here
1316
    my $units = C4::Overdues::get_chargeable_units('days', $future, $now, $library2->{branchcode});
1340
    my $units = C4::Overdues::get_chargeable_units('days', $future, $now, $library2->{branchcode});
1317
    ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' );
1341
    ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' );
1318
1342
1319
    # Users cannot renew any item if there is an overdue item
1320
    t::lib::Mocks::mock_preference('OverduesBlockRenewing','block');
1321
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_6->itemnumber);
1322
    is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue');
1323
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
1324
    is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue');
1325
1326
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
1343
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
1327
    t::lib::Mocks::mock_userenv({ patron => $manager,branchcode => $manager->branchcode });
1344
    t::lib::Mocks::mock_userenv({ patron => $manager,branchcode => $manager->branchcode });
1328
    t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','1');
1345
    t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','1');
1329
- 

Return to bug 18146