Bugzilla – Attachment 55650 Details for
Bug 17302
Add Koha::Util::Normalize for normalization functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 17302: [Follow-up] Make Normalize.pm undef-resistent
PASSED-QA-Bug-17302-Follow-up-Make-Normalizepm-und.patch (text/plain), 2.67 KB, created by
Katrin Fischer
on 2016-09-18 11:00:12 UTC
(
hide
)
Description:
[PASSED QA] Bug 17302: [Follow-up] Make Normalize.pm undef-resistent
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2016-09-18 11:00:12 UTC
Size:
2.67 KB
patch
obsolete
>From 55f3881b74922ae323c5ec3e97da5cf53463c9e7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 16 Sep 2016 09:39:15 +0200 >Subject: [PATCH] [PASSED QA] Bug 17302: [Follow-up] Make Normalize.pm > undef-resistent > >Trivial changes for passing undef to the norm routines. >Added a few dumb tests too. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >--- > Koha/Util/Normalize.pm | 16 +++++++++++----- > t/Koha/Util/Normalize.t | 20 +++++++++++++++++++- > 2 files changed, 30 insertions(+), 6 deletions(-) > >diff --git a/Koha/Util/Normalize.pm b/Koha/Util/Normalize.pm >index 487d5da..a654c3f 100644 >--- a/Koha/Util/Normalize.pm >+++ b/Koha/Util/Normalize.pm >@@ -41,8 +41,10 @@ Default normalization function > =cut > > sub legacy_default { >+ my ( $string ) = @_; >+ return if !defined( $string ); > >- my $string = uc shift; >+ $string = uc $string; > > $string =~ s/[.;:,\]\[\)\(\/'"]//g; > $string =~ s/^\s+//; >@@ -59,8 +61,8 @@ Normalization function removing spaces > =cut > > sub remove_spaces { >- >- my $string = shift; >+ my ( $string ) = @_; >+ return if !defined( $string ); > > $string =~ s/\s+//g; > >@@ -74,8 +76,10 @@ Normalization function converting characters into upper-case > =cut > > sub upper_case { >+ my ( $string ) = @_; >+ return if !defined( $string ); > >- my $string = uc shift; >+ $string = uc $string; > > return $string; > } >@@ -87,8 +91,10 @@ Normalization function converting characters into lower-case > =cut > > sub lower_case { >+ my ( $string ) = @_; >+ return if !defined( $string ); > >- my $string = lc shift; >+ $string = lc $string; > > return $string; > } >diff --git a/t/Koha/Util/Normalize.t b/t/Koha/Util/Normalize.t >index 9ebdf06..7480c23 100644 >--- a/t/Koha/Util/Normalize.t >+++ b/t/Koha/Util/Normalize.t >@@ -17,12 +17,30 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; >+use Test::Warn; > > BEGIN { > use_ok('Koha::Util::Normalize'); > } > >+subtest 'pass undef' => sub { >+ plan tests => 8; >+ >+ is( legacy_default(), undef, 'legacy_default returns undef' ); >+ warning_is { legacy_default() } undef, 'no warn from legacy_default'; >+ >+ is( remove_spaces(), undef, 'remove_spaces returns undef' ); >+ warning_is { remove_spaces() } undef, 'no warn from remove_spaces'; >+ >+ is( upper_case(), undef, 'upper_case returns undef' ); >+ warning_is { upper_case() } undef, 'no warn from upper_case'; >+ >+ is( lower_case(), undef, 'lower_case returns undef' ); >+ warning_is { lower_case() } undef, 'no warn from lower_case'; >+}; >+ >+ > subtest 'legacy_default() normalizer' => sub { > > plan tests => 1; >-- >2.7.4
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 17302
:
55571
|
55591
|
55600
|
55601
|
55649
| 55650