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

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

Return to bug 27753