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

(-)a/Koha/Util/Normalize.pm (-5 / +11 lines)
Lines 41-48 Default normalization function Link Here
41
=cut
41
=cut
42
42
43
sub legacy_default {
43
sub legacy_default {
44
    my ( $string ) = @_;
45
    return if !defined( $string );
44
46
45
    my $string = uc shift;
47
    $string = uc $string;
46
48
47
    $string =~ s/[.;:,\]\[\)\(\/'"]//g;
49
    $string =~ s/[.;:,\]\[\)\(\/'"]//g;
48
    $string =~ s/^\s+//;
50
    $string =~ s/^\s+//;
Lines 59-66 Normalization function removing spaces Link Here
59
=cut
61
=cut
60
62
61
sub remove_spaces {
63
sub remove_spaces {
62
64
    my ( $string ) = @_;
63
    my $string = shift;
65
    return if !defined( $string );
64
66
65
    $string =~ s/\s+//g;
67
    $string =~ s/\s+//g;
66
68
Lines 74-81 Normalization function converting characters into upper-case Link Here
74
=cut
76
=cut
75
77
76
sub upper_case {
78
sub upper_case {
79
    my ( $string ) = @_;
80
    return if !defined( $string );
77
81
78
    my $string = uc shift;
82
    $string = uc $string;
79
83
80
    return $string;
84
    return $string;
81
}
85
}
Lines 87-94 Normalization function converting characters into lower-case Link Here
87
=cut
91
=cut
88
92
89
sub lower_case {
93
sub lower_case {
94
    my ( $string ) = @_;
95
    return if !defined( $string );
90
96
91
    my $string = lc shift;
97
    $string = lc $string;
92
98
93
    return $string;
99
    return $string;
94
}
100
}
(-)a/t/Koha/Util/Normalize.t (-2 / +19 lines)
Lines 17-28 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
use Test::Warn;
21
22
22
BEGIN {
23
BEGIN {
23
    use_ok('Koha::Util::Normalize');
24
    use_ok('Koha::Util::Normalize');
24
}
25
}
25
26
27
subtest 'pass undef' => sub {
28
    plan tests => 8;
29
30
    is( legacy_default(), undef, 'legacy_default returns undef' );
31
    warning_is { legacy_default() } undef, 'no warn from legacy_default';
32
33
    is( remove_spaces(), undef, 'remove_spaces returns undef' );
34
    warning_is { remove_spaces() } undef, 'no warn from remove_spaces';
35
36
    is( upper_case(), undef, 'upper_case returns undef' );
37
    warning_is { upper_case() } undef, 'no warn from upper_case';
38
39
    is( lower_case(), undef, 'lower_case returns undef' );
40
    warning_is { lower_case() } undef, 'no warn from lower_case';
41
};
42
43
26
subtest 'legacy_default() normalizer' => sub {
44
subtest 'legacy_default() normalizer' => sub {
27
45
28
    plan tests => 1;
46
    plan tests => 1;
29
- 

Return to bug 17302