Lines 5-11
Link Here
|
5 |
|
5 |
|
6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
7 |
use Test::NoWarnings; |
7 |
use Test::NoWarnings; |
8 |
use Test::More tests => 21; |
8 |
use Test::More tests => 22; |
9 |
use Test::Warn; |
9 |
use Test::Warn; |
10 |
|
10 |
|
11 |
use DateTime; |
11 |
use DateTime; |
Lines 710-715
subtest do_checkin => sub {
Link Here
|
710 |
}; |
710 |
}; |
711 |
}; |
711 |
}; |
712 |
|
712 |
|
|
|
713 |
subtest 'cancel_waiting_holds_with_cancellation_requests at checkin' => sub { |
714 |
plan tests => 5; |
715 |
|
716 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
717 |
my $patron1 = $builder->build_object( |
718 |
{ |
719 |
class => 'Koha::Patrons', |
720 |
value => { |
721 |
branchcode => $library->branchcode, |
722 |
} |
723 |
} |
724 |
); |
725 |
|
726 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); |
727 |
|
728 |
my $item = $builder->build_sample_item( |
729 |
{ |
730 |
library => $library->branchcode, |
731 |
} |
732 |
); |
733 |
|
734 |
# Set up a hold for patron1 |
735 |
my $hold = AddReserve( |
736 |
{ |
737 |
branchcode => $library->branchcode, |
738 |
borrowernumber => $patron1->borrowernumber, |
739 |
biblionumber => $item->biblio->biblionumber, |
740 |
itemnumber => $item->itemnumber, |
741 |
} |
742 |
); |
743 |
|
744 |
# Mark the hold as waiting |
745 |
my $hold_obj = Koha::Holds->find($hold); |
746 |
$hold_obj->update( { found => 'W' } )->store(); |
747 |
|
748 |
# Add a cancellation request for the hold |
749 |
my $cancellation_request = Koha::Hold::CancellationRequest->new( |
750 |
{ |
751 |
hold_id => $hold_obj->id, |
752 |
creation_date => \'NOW()', |
753 |
} |
754 |
)->store; |
755 |
|
756 |
is( |
757 |
$item->holds->waiting->filter_by_has_cancellation_requests->count, 1, |
758 |
'Hold has a cancellation request' |
759 |
); |
760 |
|
761 |
my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); |
762 |
my $transaction = C4::SIP::ILS::Transaction::Checkin->new(); |
763 |
|
764 |
$transaction->item($sip_item); |
765 |
$transaction->do_checkin( $library->branchcode, C4::SIP::Sip::timestamp ); |
766 |
|
767 |
# Check if the hold still exists |
768 |
$hold_obj = Koha::Holds->find($hold); |
769 |
ok( !defined( $hold_obj ), 'Hold has been cancelled and deleted' ); |
770 |
|
771 |
my $old_hold = Koha::Old::Holds->find($hold); |
772 |
ok( $old_hold, 'Hold was moved to old reserves'); |
773 |
# QUESTION: Should the cancellation reason be set to "Cancelled by SIP"? |
774 |
is( $old_hold->cancellation_reason, undef, 'No cancellation reason was set' ); |
775 |
|
776 |
# FIXME: What should happen to the cancellation request? |
777 |
# Check that the cancellation request is deleted |
778 |
# my $existing_cancellation_requests = Koha::Hold::CancellationRequests->search( { hold_id => $hold } ); |
779 |
# is( $existing_cancellation_requests->count, 0, 'Cancellation request is deleted after processing' ); |
780 |
|
781 |
# Verify the item's hold count |
782 |
is( $item->holds->count, 0, 'No holds remain on the item after cancellation' ); |
783 |
}; |
784 |
|
713 |
subtest do_checkout_with_sysprefs_override => sub { |
785 |
subtest do_checkout_with_sysprefs_override => sub { |
714 |
plan tests => 8; |
786 |
plan tests => 8; |
715 |
|
787 |
|
716 |
- |
|
|