3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test
::More tests
=> 6;
24 use_ok
('Koha::Util::Normalize');
27 subtest
'pass undef' => sub {
30 is
( legacy_default
(), undef, 'legacy_default returns undef' );
31 warning_is
{ legacy_default
() } undef, 'no warn from legacy_default';
33 is
( remove_spaces
(), undef, 'remove_spaces returns undef' );
34 warning_is
{ remove_spaces
() } undef, 'no warn from remove_spaces';
36 is
( upper_case
(), undef, 'upper_case returns undef' );
37 warning_is
{ upper_case
() } undef, 'no warn from upper_case';
39 is
( lower_case
(), undef, 'lower_case returns undef' );
40 warning_is
{ lower_case
() } undef, 'no warn from lower_case';
44 subtest
'legacy_default() normalizer' => sub {
48 my $string = ' .; kY[]:, (l)/E\'"';
50 is
( Koha
::Util
::Normalize
::legacy_default
( $string ), 'KY LE',
51 'The \'legacy_default\' normalizer removes: .;:,][)(/\'" and shifts characters upper-case.
52 Also removes spaces from the beginning and ending, and replaces multiple spaces with a single one.' );
55 subtest
'remove_spaces() normalizer' => sub {
59 my $string = ' .; kY[]:, (l)/E\'"';
61 is
( Koha
::Util
::Normalize
::remove_spaces
( $string ), '.;kY[]:,(l)/E\'"',
62 'The \'remove_spaces\' normalizer removes all spaces' );
65 subtest
'upper_case() normalizer' => sub {
69 my $string = ' .; kY[]:, (l)/E\'"';
71 is
( Koha
::Util
::Normalize
::upper_case
( $string ), ' .; KY[]:, (L)/E\'"',
72 'The \'upper_case\' normalizer only makes characters upper-case' );
75 subtest
'lower_case() normalizer' => sub {
79 my $string = ' .; kY[]:, (l)/E\'"';
81 is
( Koha
::Util
::Normalize
::lower_case
( $string ), ' .; ky[]:, (l)/e\'"',
82 'The \'lower_case\' normalizer only makes characters lower-case' );