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

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

Return to bug 27753