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

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

Return to bug 22379