Bugzilla – Attachment 125232 Details for
Bug 22379
ILS-DI Method "CancelHold" doesn't check CanReserveBeCanceledFromOpac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22379: Unit tests for CancelHold service
Bug-22379-Unit-tests-for-CancelHold-service.patch (text/plain), 3.65 KB, created by
Arthur Suzuki
on 2021-09-24 09:13:51 UTC
(
hide
)
Description:
Bug 22379: Unit tests for CancelHold service
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2021-09-24 09:13:51 UTC
Size:
3.65 KB
patch
obsolete
>From b829f464c0549355570d70b336f5a3ac12e18040 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Mon, 27 Jan 2020 05:41:05 +0100 >Subject: [PATCH] Bug 22379: Unit tests for CancelHold service > >--- > t/db_dependent/ILSDI_Services.t | 62 ++++++++++++++++++++++++++++++++- > 1 file changed, 61 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 72681afd69..7cbfd9241f 100755 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use Test::More tests => 10; >+use Test::More tests => 11; > use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -27,6 +27,7 @@ use t::lib::Dates; > > use C4::Items qw( ModItemTransfer ); > use C4::Circulation qw( AddIssue ); >+use C4::Reserves qw (AddReserve ModReserve ModReserveAffect ModReserveStatus); > > use Koha::AuthUtils; > use Koha::DateUtils; >@@ -737,6 +738,65 @@ subtest 'RenewHold' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'CancelHold' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $cgi = CGI->new; >+ >+ my $library = $builder->build_object({ >+ class => 'Koha::Libraries', >+ }); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', >+ value => { >+ branchcode => $library->branchcode, >+ }, >+ } ); >+ >+ my $patron2 = $builder->build_object( { class => 'Koha::Patrons', >+ value => { >+ branchcode => $library->branchcode, >+ }, >+ } ); >+ >+ my $item = $builder->build_sample_item({ library => $library->branchcode }); >+ >+ my $reserve = C4::Reserves::AddReserve({branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber }); >+ >+ # Affecting the reserve sets it to a waiting state >+ C4::Reserves::ModReserveAffect( $item->itemnumber, >+ $patron->borrowernumber, >+ undef, >+ $reserve, >+ ); >+ >+ $cgi->param( patron_id => $patron2->borrowernumber ); >+ $cgi->param( item_id => $reserve ); >+ >+ >+ my $reply = C4::ILSDI::Services::CancelHold($cgi); >+ is( $reply->{code}, 'BorrowerCannotCancelHold', 'If the patron is wrong, BorrowerCannotCancelHold should be returned'); >+ >+ $cgi->param( patron_id => $patron->borrowernumber ); >+ $reply = C4::ILSDI::Services::CancelHold($cgi); >+ is( $reply->{code}, 'BorrowerCannotCancelHold', 'If reserve in a Waiting state, patron cannot cancel'); >+ >+ C4::Reserves::ModReserveStatus( $item->itemnumber, 'T' ); >+ $reply = C4::ILSDI::Services::CancelHold($cgi); >+ is( $reply->{code}, 'BorrowerCannotCancelHold', 'If reserve in a Transfer state, patron cannot cancel'); >+ >+ C4::Reserves::ModReserve( {rank => 1, reserve_id => $reserve, branchcode => $library->branchcode} ); >+ $cgi->param( item_id => $reserve ); >+ $reply = C4::ILSDI::Services::CancelHold($cgi); >+ is( $reply->{code}, 'Canceled', 'If the patron is fine and reserve not waiting, Canceled should be returned and reserve canceled'); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'GetPatronInfo paginated loans' => sub { > plan tests => 7; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22379
:
85413
|
85414
|
94387
|
97959
|
97960
|
125230
|
125231
|
125232
|
133903
|
133904