2 use Test::More tests => 4;
5 use C4::Biblio qw( AddBiblio GetMarcFromKohaField );
7 use C4::Charset qw( SanitizeRecord );
9 my $dbh = C4::Context->dbh;
10 $dbh->{RaiseError} = 1;
11 $dbh->{AutoCommit} = 0;
13 my $frameworkcode = q||;
16 DELETE FROM marc_subfield_structure WHERE kohafield='biblioitems.url'
19 INSERT INTO marc_subfield_structure(frameworkcode,kohafield,tagfield,tagsubfield)
20 VALUES ('$frameworkcode', 'biblioitems.url', '856', 'u')
22 my ( $url_field, $url_subfield ) = C4::Biblio::GetMarcFromKohaField('biblioitems.url', $frameworkcode);
24 my $title = q|My title & a word & another word|;
25 my $url = q|http://www.example.org/index.pl?arg1=val1&arg2=val2|;
26 my $record = MARC::Record->new();
27 $record->append_fields(
28 MARC::Field->new('100', ' ', ' ', a => 'my author'),
29 MARC::Field->new('245', ' ', ' ', a => $title),
30 MARC::Field->new($url_field, ' ', ' ', $url_subfield => $url ),
33 my ($biblionumber, $biblioitemnumber) = AddBiblio($record, $frameworkcode);
34 my ( $sanitized_record, $has_been_modified ) = C4::Charset::SanitizeRecord( $record, $biblionumber );
35 is( $has_been_modified, 0, 'SanitizeRecord: the record has not been modified' );
36 is( $url, $sanitized_record->subfield($url_field, $url_subfield), 'SanitizeRecord: the url has not been modified');
38 $title = q|My title & a word & another word|;
39 $record = MARC::Record->new();
40 $record->append_fields(
41 MARC::Field->new('100', ' ', ' ', a => 'my author'),
42 MARC::Field->new('245', ' ', ' ', a => $title),
43 MARC::Field->new($url_field, ' ', ' ', $url_subfield => $url ),
46 ($biblionumber, $biblioitemnumber) = AddBiblio($record, $frameworkcode);
47 ( $sanitized_record, $has_been_modified ) = C4::Charset::SanitizeRecord( $record, $biblionumber );
48 is( $has_been_modified, 1, 'SanitizeRecord: the record has been modified' );
49 is( $url, $sanitized_record->subfield($url_field, $url_subfield), 'SanitizeRecord: the url has not been modified');