|
Lines 19-31
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 9; |
22 |
use Test::More tests => 10; |
| 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; |
| 26 |
|
26 |
|
| 27 |
use C4::Items qw( ModItemTransfer ); |
27 |
use C4::Items qw( ModItemTransfer ); |
| 28 |
use C4::Circulation; |
28 |
use C4::Circulation; |
|
|
29 |
use C4::Reserves; |
| 29 |
|
30 |
|
| 30 |
use Koha::AuthUtils; |
31 |
use Koha::AuthUtils; |
| 31 |
|
32 |
|
|
Lines 633-638
subtest 'RenewHold' => sub {
Link Here
|
| 633 |
$schema->storage->txn_rollback; |
634 |
$schema->storage->txn_rollback; |
| 634 |
}; |
635 |
}; |
| 635 |
|
636 |
|
|
|
637 |
subtest 'CancelHold' => sub { |
| 638 |
plan tests => 4; |
| 639 |
|
| 640 |
$schema->storage->txn_begin; |
| 641 |
|
| 642 |
my $cgi = new CGI; |
| 643 |
|
| 644 |
my $library = $builder->build_object({ |
| 645 |
class => 'Koha::Libraries', |
| 646 |
}); |
| 647 |
|
| 648 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', |
| 649 |
value => { |
| 650 |
branchcode => $library->branchcode, |
| 651 |
}, |
| 652 |
} ); |
| 653 |
|
| 654 |
my $patron2 = $builder->build_object( { class => 'Koha::Patrons', |
| 655 |
value => { |
| 656 |
branchcode => $library->branchcode, |
| 657 |
}, |
| 658 |
} ); |
| 659 |
|
| 660 |
my $item = $builder->build_sample_item({ library => $library->branchcode }); |
| 661 |
|
| 662 |
my $reserve = C4::Reserves::AddReserve( $library->branchcode, |
| 663 |
$patron->borrowernumber, |
| 664 |
$item->biblionumber, |
| 665 |
); |
| 666 |
|
| 667 |
# Affecting the reserve sets it to a waiting state |
| 668 |
C4::Reserves::ModReserveAffect( $item->itemnumber, |
| 669 |
$patron->borrowernumber, |
| 670 |
undef, |
| 671 |
$reserve, |
| 672 |
); |
| 673 |
|
| 674 |
$cgi->param( patron_id => $patron2->borrowernumber ); |
| 675 |
$cgi->param( item_id => $reserve ); |
| 676 |
|
| 677 |
|
| 678 |
my $reply = C4::ILSDI::Services::CancelHold($cgi); |
| 679 |
is( $reply->{code}, 'BorrowerCannotCancelHold', 'If the patron is wrong, BorrowerCannotCancelHold should be returned'); |
| 680 |
|
| 681 |
$cgi->param( patron_id => $patron->borrowernumber ); |
| 682 |
$reply = C4::ILSDI::Services::CancelHold($cgi); |
| 683 |
is( $reply->{code}, 'BorrowerCannotCancelHold', 'If reserve in a Waiting state, patron cannot cancel'); |
| 684 |
|
| 685 |
C4::Reserves::ModReserveStatus( $item->itemnumber, 'T' ); |
| 686 |
$reply = C4::ILSDI::Services::CancelHold($cgi); |
| 687 |
is( $reply->{code}, 'BorrowerCannotCancelHold', 'If reserve in a Transfer state, patron cannot cancel'); |
| 688 |
|
| 689 |
C4::Reserves::ModReserve( {rank => 1, reserve_id => $reserve, branchcode => $library->branchcode} ); |
| 690 |
$cgi->param( item_id => $reserve ); |
| 691 |
$reply = C4::ILSDI::Services::CancelHold($cgi); |
| 692 |
is( $reply->{code}, 'Canceled', 'If the patron is fine and reserve not waiting, Canceled should be returned and reserve canceled'); |
| 693 |
|
| 694 |
$schema->storage->txn_rollback; |
| 695 |
}; |
| 696 |
|
| 636 |
subtest 'GetPatronInfo paginated loans' => sub { |
697 |
subtest 'GetPatronInfo paginated loans' => sub { |
| 637 |
plan tests => 7; |
698 |
plan tests => 7; |
| 638 |
|
699 |
|
| 639 |
- |
|
|