Bugzilla – Attachment 84432 Details for
Bug 21478
Koha::Hold->suspend_hold allows suspending in transit holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21478: Add Koha::Exceptions::Hold
Bug-21478-Add-KohaExceptionsHold.patch (text/plain), 3.52 KB, created by
Kyle M Hall (khall)
on 2019-01-25 20:12:21 UTC
(
hide
)
Description:
Bug 21478: Add Koha::Exceptions::Hold
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2019-01-25 20:12:21 UTC
Size:
3.52 KB
patch
obsolete
>From f14af883e44fa1e882d1de20a7716c87a309adb8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 25 Jan 2019 12:48:04 -0300 >Subject: [PATCH] Bug 21478: Add Koha::Exceptions::Hold > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Exceptions/Hold.pm | 69 +++++++++++++++++++++++++++++++++++++++++ > t/Koha/Exceptions.t | 23 +++++++++++++- > 2 files changed, 91 insertions(+), 1 deletion(-) > create mode 100644 Koha/Exceptions/Hold.pm > >diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm >new file mode 100644 >index 0000000000..5e6eeb0f9e >--- /dev/null >+++ b/Koha/Exceptions/Hold.pm >@@ -0,0 +1,69 @@ >+package Koha::Exceptions::Hold; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Koha::Exceptions::Exception; >+ >+use Exception::Class ( >+ 'Koha::Exceptions::Hold' => { >+ isa => 'Koha::Exceptions::Exception', >+ }, >+ 'Koha::Exceptions::Hold::CannotSuspendFound' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Found holds cannot be suspended", >+ fields => ['status'] >+ } >+); >+ >+sub full_message { >+ my $self = shift; >+ >+ my $msg = $self->message; >+ >+ unless ( $msg) { >+ if ( $self->isa('Koha::Exceptions::Hold::CannotSuspendFound') ) { >+ $msg = sprintf("Found hold cannot be suspended. Status=%s", $self->status ); >+ } >+ } >+ >+ return $msg; >+} >+ >+=head1 NAME >+ >+Koha::Exceptions::Hold - Base class for Hold exceptions >+ >+=head1 Exceptions >+ >+=head2 Koha::Exceptions::Hold >+ >+Generic Hold exception >+ >+=head2 Koha::Exceptions::Hold::CannotSuspendFound >+ >+Exception to be used when suspension is requested on a found hold. >+ >+=head1 Class methods >+ >+=head2 full_message >+ >+Overloaded method for exception stringifying. >+ >+=cut >+ >+1; >diff --git a/t/Koha/Exceptions.t b/t/Koha/Exceptions.t >index 7ecc115cfd..0b4c68e086 100644 >--- a/t/Koha/Exceptions.t >+++ b/t/Koha/Exceptions.t >@@ -17,9 +17,30 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Exception; > >+subtest 'Koha::Exceptions::Hold tests' => sub { >+ >+ plan tests => 5; >+ >+ use_ok('Koha::Exceptions::Hold'); >+ >+ throws_ok >+ { Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'W' ); } >+ 'Koha::Exceptions::Hold::CannotSuspendFound', >+ 'Exception is thrown :-D'; >+ >+ # stringify the exception >+ is( "$@", 'Found hold cannot be suspended. Status=W', 'Exception stringified correctly' ); >+ >+ throws_ok >+ { Koha::Exceptions::Hold::CannotSuspendFound->throw( "Manual message exception" ) } >+ 'Koha::Exceptions::Hold::CannotSuspendFound', >+ 'Exception is thrown :-D'; >+ is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); >+}; >+ > subtest 'Koha::Exceptions::Object::FKConstraint tests' => sub { > > plan tests => 5; >-- >2.17.2 (Apple Git-113)
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 21478
:
84409
|
84410
|
84411
|
84432
|
84433
|
84434
|
84456
|
84457
|
84458
|
84487