|
Lines 1204-1232
subtest 'GetFrameworkCode' => sub {
Link Here
|
| 1204 |
|
1204 |
|
| 1205 |
}; |
1205 |
}; |
| 1206 |
|
1206 |
|
| 1207 |
subtest 'ModBiblio on invalid record' => sub { |
1207 |
subtest 'ModBiblio on record with strippable non-XML characters' => sub { |
| 1208 |
plan tests => 3; |
1208 |
plan tests => 3; |
| 1209 |
|
1209 |
|
| 1210 |
t::lib::Mocks::mock_preference( "CataloguingLog", 1 ); |
1210 |
t::lib::Mocks::mock_preference( "CataloguingLog", 1 ); |
| 1211 |
|
1211 |
|
| 1212 |
# We create a record with an onvalid control character in the MARC |
1212 |
# We create a record with an invalid control character (chr(31)) in the MARC |
| 1213 |
my $record = MARC::Record->new(); |
1213 |
my $record = MARC::Record->new(); |
| 1214 |
my $field = MARC::Field->new( '650', '', '', 'a' => '00aD000015937' ); |
1214 |
my $field = MARC::Field->new( '650', '', '', 'a' => '00' . chr(31) . 'aD000015937' ); |
| 1215 |
$record->append_fields($field); |
1215 |
$record->append_fields($field); |
| 1216 |
|
1216 |
|
| 1217 |
my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' ); |
1217 |
my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' ); |
| 1218 |
|
1218 |
|
| 1219 |
warning_like { C4::Biblio::ModBiblio( $record, $biblionumber, '' ); } |
1219 |
# New behaviour: strippable non-XML characters are silently fixed; the |
| 1220 |
qr/parser error : PCDATA invalid Char value 31/, |
1220 |
# stripping event is reported via the warnings arrayref, not Perl warn() |
| 1221 |
'Modding the biblio warns about the encoding issues'; |
1221 |
my @warnings; |
| 1222 |
my $action_logs = |
1222 |
C4::Biblio::ModBiblio( $record, $biblionumber, '', { warnings => \@warnings } ); |
| 1223 |
Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } ); |
1223 |
like( |
| 1224 |
is( $action_logs->count, 1, "Modification of biblio was successful and recorded" ); |
1224 |
$warnings[0]{message}, qr/parser error : PCDATA invalid Char value 31/, |
| 1225 |
my $action_log = $action_logs->next; |
1225 |
'Non-XML character stripping reported via warnings arrayref' |
|
|
1226 |
); |
| 1227 |
|
| 1228 |
my $metadata = Koha::Biblios->find($biblionumber)->metadata; |
| 1226 |
like( |
1229 |
like( |
| 1227 |
$action_log->info, qr/parser error : PCDATA invalid Char value 31/, |
1230 |
$metadata->nonxml_stripped, qr/parser error : PCDATA invalid Char value 31/, |
| 1228 |
"Metadata issue successfully logged in action logs" |
1231 |
'nonxml_stripped persisted on biblio_metadata after ModBiblio' |
| 1229 |
); |
1232 |
); |
|
|
1233 |
|
| 1234 |
my $action_logs = |
| 1235 |
Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } ); |
| 1236 |
is( $action_logs->count, 1, "Modification of biblio was successfully recorded in action logs" ); |
| 1230 |
}; |
1237 |
}; |
| 1231 |
|
1238 |
|
| 1232 |
subtest 'UpdateTotalIssues on Invalid record' => sub { |
1239 |
subtest 'UpdateTotalIssues on Invalid record' => sub { |
| 1233 |
- |
|
|