Bugzilla – Attachment 77577 Details for
Bug 21178
Add Koha::Patron::set_password method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21178: (follow-up) Stringify exception correctly
Bug-21178-follow-up-Stringify-exception-correctly.patch (text/plain), 2.64 KB, created by
Tomás Cohen Arazi
on 2018-08-08 14:27:12 UTC
(
hide
)
Description:
Bug 21178: (follow-up) Stringify exception correctly
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2018-08-08 14:27:12 UTC
Size:
2.64 KB
patch
obsolete
>From e2e59894953c3fd4836f482f7383d3fad63be3c7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 8 Aug 2018 11:23:15 -0300 >Subject: [PATCH] Bug 21178: (follow-up) Stringify exception correctly > >This patch adds code to stringify the Password::TooShort exception. > >To test: >- Run: > $ kshell > k$ prove t/Koha/Exceptions.t >=> SUCCESS: Tests pass! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Exceptions/Password.pm | 20 ++++++++++++++++++++ > t/Koha/Exceptions.t | 22 +++++++++++++++++++++- > 2 files changed, 41 insertions(+), 1 deletion(-) > >diff --git a/Koha/Exceptions/Password.pm b/Koha/Exceptions/Password.pm >index 30a239bbb9..bffafdbadd 100644 >--- a/Koha/Exceptions/Password.pm >+++ b/Koha/Exceptions/Password.pm >@@ -41,6 +41,20 @@ use Exception::Class ( > } > ); > >+sub full_message { >+ my $self = shift; >+ >+ my $msg = $self->message; >+ >+ unless ( $msg) { >+ if ( $self->isa('Koha::Exceptions::Password::TooShort') ) { >+ $msg = sprintf("Password length (%s) is shorter than required (%s)", $self->length, $self->min_length ); >+ } >+ } >+ >+ return $msg; >+} >+ > =head1 NAME > > Koha::Exceptions::Password - Base class for password exceptions >@@ -67,6 +81,12 @@ Password is too weak. > > Password contains trailing spaces, which is forbidden. > >+=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 c306d31cb9..7ecc115cfd 100644 >--- a/t/Koha/Exceptions.t >+++ b/t/Koha/Exceptions.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Exception; > > subtest 'Koha::Exceptions::Object::FKConstraint tests' => sub { >@@ -41,3 +41,23 @@ subtest 'Koha::Exceptions::Object::FKConstraint tests' => sub { > is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); > }; > >+subtest 'Koha::Exceptions::Password tests' => sub { >+ >+ plan tests => 5; >+ >+ use_ok('Koha::Exceptions::Password'); >+ >+ throws_ok >+ { Koha::Exceptions::Password::TooShort->throw( length => 4, min_length => 5 ); } >+ 'Koha::Exceptions::Password::TooShort', >+ 'Exception is thrown :-D'; >+ >+ # stringify the exception >+ is( "$@", 'Password length (4) is shorter than required (5)', 'Exception stringified correctly' ); >+ >+ throws_ok >+ { Koha::Exceptions::Password::TooShort->throw( "Manual message exception" ) } >+ 'Koha::Exceptions::Password::TooShort', >+ 'Exception is thrown :-D'; >+ is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); >+}; >-- >2.18.0
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 21178
:
77575
|
77576
|
77577
|
77578
|
77632
|
77885
|
77886
|
77916
|
77917
|
78833
|
80133
|
80134
|
80135
|
80136