|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 5; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
| 25 |
use Koha::RecordProcessor; |
25 |
use Koha::RecordProcessor; |
|
Lines 143-168
subtest "new() tests" => sub {
Link Here
|
| 143 |
|
143 |
|
| 144 |
is( $metadata_record, undef, 'record object mandatory') |
144 |
is( $metadata_record, undef, 'record object mandatory') |
| 145 |
}; |
145 |
}; |
| 146 |
|
|
|
| 147 |
subtest "stripWhitespaceChars() tests" => sub { |
| 148 |
plan tests => 2; |
| 149 |
|
| 150 |
# Test default values with a MARC::Record record |
| 151 |
my $record = MARC::Record->new(); |
| 152 |
|
| 153 |
$record->add_fields( |
| 154 |
[ '001', '1234' ], |
| 155 |
[ '150', ' ', ' ', a => 'Test' ], |
| 156 |
[ '520', ' ', ' ', a => "This is\na test!\t" ], |
| 157 |
[ '521', ' ', ' ', a => "This is a\t test!\t" ], |
| 158 |
); |
| 159 |
|
| 160 |
my $p = Koha::RecordProcessor->new({ filters => ['TrimFields'] }); |
| 161 |
$p->process( $record ); |
| 162 |
|
| 163 |
my $get520a = $record->subfield('520','a'); |
| 164 |
is( $get520a, "This is a test!", "Whitespace characters are appropriately stripped or replaced with spaces" ); |
| 165 |
|
| 166 |
my $get521a = $record->subfield('521','a'); |
| 167 |
is( $get521a, "This is a\t test!", "Trailing tabs are stripped while inner tabs are kept" ); |
| 168 |
}; |