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

(-)a/t/db_dependent/Circulation.t (-12 / +41 lines)
Lines 2634-2665 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
2634
2634
2635
2635
2636
subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub {
2636
subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub {
2637
    plan tests => 8;
2637
    plan tests => 1;
2638
2638
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2639
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2639
    t::lib::Mocks::mock_userenv( { branchcode => $library2->{branchcode} } );
2640
    t::lib::Mocks::mock_userenv( { branchcode => $library2->{branchcode} } );
2640
    t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue',         1 );
2641
    t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue',         1 );
2641
    t::lib::Mocks::mock_preference( 'AutoClaimReturnStatusOnCheckin', 1 );
2642
    t::lib::Mocks::mock_preference( 'AutoClaimReturnStatusOnCheckin', '' );
2642
    my $item     = $builder->build_sample_item( { library => $library2->{branchcode} } );
2643
    my $item     = $builder->build_sample_item( { library => $library2->{branchcode} } );
2643
    my $patron   = $builder->build_object( { class => 'Koha::Patrons' } );
2644
    my $patron   = $builder->build_object( { class => 'Koha::Patrons' } );
2644
    my $checkout = AddIssue( $patron, $item->barcode );
2645
    my $future   = dt_from_string()->add( days => 7 );
2646
    my $checkout = $builder->build_object(
2647
        {
2648
            class => 'Koha::Checkouts',
2649
            value => {
2650
                returndate      => undef,
2651
                renewals_count  => 0,
2652
                auto_renew      => 0,
2653
                borrowernumber  => $patron->borrowernumber,
2654
                itemnumber      => $item->itemnumber,
2655
                onsite_checkout => 0,
2656
                date_due        => $future,
2657
            }
2658
        }
2659
    );
2645
2660
2661
    # Claim return
2646
    my $claim = $checkout->claim_returned(
2662
    my $claim = $checkout->claim_returned(
2647
        {
2663
        {
2648
            created_by => $patron->id,
2664
            created_by => $patron->id,
2649
            notes      => "Test note",
2665
            notes      => "Test note",
2650
        }
2666
        }
2651
    );
2667
    );
2652
    is( $claim->issue_id,       $checkout->id, "Claim issue id matches" );
2668
    is( $claim->issue_id, $checkout->id,    "Return claim created for issue" );
2653
    is( $claim->itemnumber,     $item->id,     "Claim itemnumber matches" );
2669
    $item->discard_changes;
2654
    is( $claim->borrowernumber, $patron->id,   "Claim borrowernumber matches" );
2670
    is( $item->itemlost,  1, "Item set to lost as 1" );
2655
    is( $claim->notes,          "Test note",   "Claim notes match" );
2656
    is( $claim->created_by,     $patron->id,   "Claim created_by matches" );
2657
    ok( $claim->created_on, "Claim created_on is set" );
2658
2671
2672
    # Return tests with feature disabled
2659
    my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->{branchcode} );
2673
    my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->{branchcode} );
2660
    is( ref $messages->{ClaimAutoResolved}, 'Koha::Checkouts::ReturnClaim', "Claim auto resolved upon checkin" );
2674
    is(
2675
        ref $messages->{ReturnClaims}, 'Koha::Checkouts::ReturnClaim',
2676
        "AddReturn returns message 'ReturnClaims' containing the ReturnClaim object"
2677
    );
2678
    # FIXME: We should reset the checkout here else we hit a 'No patron' defined issue in the AutoClaim code.
2679
    #        This might highligt a bug in the code however.. should we allow trigger this code when the return
2680
    #        spots that there isn't a current issue
2681
2682
    # Now test with the feature enabled
2683
    t::lib::Mocks::mock_preference( 'AutoClaimReturnStatusOnCheckin', 'RETURNED_ON_CLAIM' );
2684
    ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->{branchcode} );
2685
    is(
2686
        ref $messages->{ClaimAutoResolved}, 'Koha::Checkouts::ReturnClaim',
2687
        "AddReturn returns message 'ClaimAutoResolved' containing the ReturnClaim object"
2688
    );
2661
    $claim->discard_changes;
2689
    $claim->discard_changes;
2662
    ok( $claim->resolved_by, "Claim is resolved" );
2690
    is( $claim->resolved_by, '', "Claim marked as resolved by '' when AutoClaimReturnStatusOnCheckin set" );
2691
    # FIXME: The code sets the resolved_by to the patron who was issued the item.. should this be the librarian performing the return instead?
2692
    is( $claim->resolution, 'RETURNED_ON_CLAIM', "Claim resolution set to match AutoClaimReturnStatusOnCheckin value" );
2663
};
2693
};
2664
2694
2665
subtest 'MultipleReserves' => sub {
2695
subtest 'MultipleReserves' => sub {
2666
- 

Return to bug 27753