Lines 19-25
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
21 |
|
21 |
|
22 |
use Test::More tests => 10; |
22 |
use Test::More tests => 11; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
Lines 27-32
use t::lib::Dates;
Link Here
|
27 |
|
27 |
|
28 |
use C4::Items qw( ModItemTransfer ); |
28 |
use C4::Items qw( ModItemTransfer ); |
29 |
use C4::Circulation qw( AddIssue ); |
29 |
use C4::Circulation qw( AddIssue ); |
|
|
30 |
use C4::Reserves qw (AddReserve ModReserve ModReserveAffect ModReserveStatus); |
30 |
|
31 |
|
31 |
use Koha::AuthUtils; |
32 |
use Koha::AuthUtils; |
32 |
use Koha::DateUtils; |
33 |
use Koha::DateUtils; |
Lines 737-742
subtest 'RenewHold' => sub {
Link Here
|
737 |
$schema->storage->txn_rollback; |
738 |
$schema->storage->txn_rollback; |
738 |
}; |
739 |
}; |
739 |
|
740 |
|
|
|
741 |
subtest 'CancelHold' => sub { |
742 |
plan tests => 4; |
743 |
|
744 |
$schema->storage->txn_begin; |
745 |
|
746 |
my $cgi = new CGI; |
747 |
|
748 |
my $library = $builder->build_object({ |
749 |
class => 'Koha::Libraries', |
750 |
}); |
751 |
|
752 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', |
753 |
value => { |
754 |
branchcode => $library->branchcode, |
755 |
}, |
756 |
} ); |
757 |
|
758 |
my $patron2 = $builder->build_object( { class => 'Koha::Patrons', |
759 |
value => { |
760 |
branchcode => $library->branchcode, |
761 |
}, |
762 |
} ); |
763 |
|
764 |
my $item = $builder->build_sample_item({ library => $library->branchcode }); |
765 |
|
766 |
my $reserve = C4::Reserves::AddReserve({branchcode => $library->branchcode, |
767 |
borrowernumber => $patron->borrowernumber, |
768 |
biblionumber => $item->biblionumber }); |
769 |
|
770 |
# Affecting the reserve sets it to a waiting state |
771 |
C4::Reserves::ModReserveAffect( $item->itemnumber, |
772 |
$patron->borrowernumber, |
773 |
undef, |
774 |
$reserve, |
775 |
); |
776 |
|
777 |
$cgi->param( patron_id => $patron2->borrowernumber ); |
778 |
$cgi->param( item_id => $reserve ); |
779 |
|
780 |
|
781 |
my $reply = C4::ILSDI::Services::CancelHold($cgi); |
782 |
is( $reply->{code}, 'BorrowerCannotCancelHold', 'If the patron is wrong, BorrowerCannotCancelHold should be returned'); |
783 |
|
784 |
$cgi->param( patron_id => $patron->borrowernumber ); |
785 |
$reply = C4::ILSDI::Services::CancelHold($cgi); |
786 |
is( $reply->{code}, 'BorrowerCannotCancelHold', 'If reserve in a Waiting state, patron cannot cancel'); |
787 |
|
788 |
C4::Reserves::ModReserveStatus( $item->itemnumber, 'T' ); |
789 |
$reply = C4::ILSDI::Services::CancelHold($cgi); |
790 |
is( $reply->{code}, 'BorrowerCannotCancelHold', 'If reserve in a Transfer state, patron cannot cancel'); |
791 |
|
792 |
C4::Reserves::ModReserve( {rank => 1, reserve_id => $reserve, branchcode => $library->branchcode} ); |
793 |
$cgi->param( item_id => $reserve ); |
794 |
$reply = C4::ILSDI::Services::CancelHold($cgi); |
795 |
is( $reply->{code}, 'Canceled', 'If the patron is fine and reserve not waiting, Canceled should be returned and reserve canceled'); |
796 |
|
797 |
$schema->storage->txn_rollback; |
798 |
}; |
799 |
|
740 |
subtest 'GetPatronInfo paginated loans' => sub { |
800 |
subtest 'GetPatronInfo paginated loans' => sub { |
741 |
plan tests => 7; |
801 |
plan tests => 7; |
742 |
|
802 |
|
743 |
- |
|
|