|
Lines 22-28
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
Link Here
|
| 22 |
( $biblionumbertagfield, $biblionumbertagsubfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" ); |
22 |
( $biblionumbertagfield, $biblionumbertagsubfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" ); |
| 23 |
|
23 |
|
| 24 |
subtest 'Biblio record' => sub { |
24 |
subtest 'Biblio record' => sub { |
| 25 |
plan tests => 17; |
25 |
plan tests => 20; |
| 26 |
my $leader = '00203nam a2200097 4500'; |
26 |
my $leader = '00203nam a2200097 4500'; |
| 27 |
my $input = CGI->new; |
27 |
my $input = CGI->new; |
| 28 |
$input->param( -name => 'biblionumber', -value => '42' ); |
28 |
$input->param( -name => 'biblionumber', -value => '42' ); |
|
Lines 73-82
subtest 'Biblio record' => sub {
Link Here
|
| 73 |
$input->param( -name => "tag_490_code_b_1123", -value => 'b' ); |
73 |
$input->param( -name => "tag_490_code_b_1123", -value => 'b' ); |
| 74 |
$input->param( -name => "tag_490_subfield_b_1123", -value => '490b' ); |
74 |
$input->param( -name => "tag_490_subfield_b_1123", -value => '490b' ); |
| 75 |
|
75 |
|
|
|
76 |
# A field (900) after 490 |
| 77 |
$input->param( -name => "tag_900_indicator1_1123", -value => "" ); |
| 78 |
$input->param( -name => "tag_900_indicator2_1123", -value => "" ); |
| 79 |
$input->param( -name => "tag_900_code_a_1123", -value => 'a' ); |
| 80 |
$input->param( -name => "tag_900_subfield_a_1123", -value => "This string has bad \x{1B}characters in it" ); |
| 81 |
|
| 76 |
my $record = C4::Biblio::TransformHtmlToMarc($input, 1); |
82 |
my $record = C4::Biblio::TransformHtmlToMarc($input, 1); |
| 77 |
|
83 |
|
| 78 |
my @all_fields = $record->fields; |
84 |
my @all_fields = $record->fields; |
| 79 |
is( @all_fields, 7, 'The record should have been created with 7 fields' ); |
85 |
is( @all_fields, 8, 'The record should have been created with 8 fields' ); |
| 80 |
# biblionumber + 2x010 + 100 + 200 + 390 + 490 |
86 |
# biblionumber + 2x010 + 100 + 200 + 390 + 490 |
| 81 |
my @fields_010 = $record->field('010'); |
87 |
my @fields_010 = $record->field('010'); |
| 82 |
is( @fields_010, 2, 'The record should have been created with 2 010' ); |
88 |
is( @fields_010, 2, 'The record should have been created with 2 010' ); |
|
Lines 92-97
subtest 'Biblio record' => sub {
Link Here
|
| 92 |
is( @subfields_200_a, 2, 'The record should have been created with 2 200$a' ); |
98 |
is( @subfields_200_a, 2, 'The record should have been created with 2 200$a' ); |
| 93 |
is_deeply( \@subfields_200_a, [ 'first title', 'second title' ], 'The 2 titles should have been kept in the correct order' ); |
99 |
is_deeply( \@subfields_200_a, [ 'first title', 'second title' ], 'The 2 titles should have been kept in the correct order' ); |
| 94 |
|
100 |
|
|
|
101 |
my @fields_900 = $record->field('900'); |
| 102 |
is( @fields_900, 1, 'The record should have been created with 1 900' ); |
| 103 |
is_deeply( |
| 104 |
$fields_900[0]->subfields(), [ 'a', 'This string has bad characters in it' ], |
| 105 |
'Field 900 had its non-XML characters stripped' |
| 106 |
); |
| 107 |
|
| 95 |
my @subfields_biblionumber = $record->subfield( $biblionumbertagfield, $biblionumbertagsubfield ); |
108 |
my @subfields_biblionumber = $record->subfield( $biblionumbertagfield, $biblionumbertagsubfield ); |
| 96 |
is( @subfields_biblionumber, 1, 'The record should contain only one biblionumber field' ); |
109 |
is( @subfields_biblionumber, 1, 'The record should contain only one biblionumber field' ); |
| 97 |
|
110 |
|
|
Lines 105-110
subtest 'Biblio record' => sub {
Link Here
|
| 105 |
is( $all_fields[4]->tag, '390', 'Fifth field is 390' ); |
118 |
is( $all_fields[4]->tag, '390', 'Fifth field is 390' ); |
| 106 |
is( $all_fields[5]->subfield('a'), 42, 'Sixth field contains bibnumber' ); |
119 |
is( $all_fields[5]->subfield('a'), 42, 'Sixth field contains bibnumber' ); |
| 107 |
is( $all_fields[6]->tag, '490', 'Last field is 490' ); |
120 |
is( $all_fields[6]->tag, '490', 'Last field is 490' ); |
|
|
121 |
|
| 122 |
my $new_record = eval { MARC::Record::new_from_xml( $record->as_xml(), 'UTF-8' ); }; |
| 123 |
my $record_error = $@; |
| 124 |
ok( !$record_error, 'No errors parsing MARCXML generated by TransformHtmlToMarc' ); |
| 125 |
|
| 108 |
}; |
126 |
}; |
| 109 |
|
127 |
|
| 110 |
subtest 'Add authority record' => sub { |
128 |
subtest 'Add authority record' => sub { |
| 111 |
- |
|
|