Lines 110-139
subtest 'Testing _adjust_pubyear' => sub {
Link Here
|
110 |
is( C4::Biblio::_adjust_pubyear('broken'), undef, 'Non-matchign data returns nothing as the field must be int' ); |
110 |
is( C4::Biblio::_adjust_pubyear('broken'), undef, 'Non-matchign data returns nothing as the field must be int' ); |
111 |
}; |
111 |
}; |
112 |
|
112 |
|
113 |
subtest 'Test repeatable subfields' => sub { |
113 |
subtest 'Test repeatable subfields and no_items parameter' => sub { |
114 |
plan tests => 5; |
114 |
plan tests => 7; |
115 |
|
115 |
|
116 |
# Make 510x repeatable and 510y not |
116 |
# Make 510x repeatable and 510y not |
117 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '510' })->delete; |
117 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '510' })->delete; |
118 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'x', kohafield => 'items.test', repeatable => 1 })->store; |
118 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'x', kohafield => 'items.test', repeatable => 1 })->store; |
119 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'y', kohafield => 'items.norepeat', repeatable => 0 })->store; |
119 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'y', kohafield => 'items.norepeat', repeatable => 0 })->store; |
|
|
120 |
# Add 510a, 510b biblio fields |
121 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; |
122 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'b', kohafield => 'biblio.field2' })->store; |
120 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
123 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
121 |
|
124 |
|
122 |
|
125 |
|
123 |
my $marc = MARC::Record->new; |
126 |
my $marc = MARC::Record->new; |
124 |
$marc->append_fields( MARC::Field->new( '510', '', '', x => '1', x => '2', y => '3 | 4', y => '5' ) ); # actually, we should only have one $y (BZ 24652) |
127 |
$marc->append_fields( MARC::Field->new( '510', '', '', a => '0', b => '', x => '1', x => '2', y => '3 | 4', y => '5' ) ); |
|
|
128 |
# actually, we should only have one $y (BZ 24652) |
129 |
# By adding '0' in $a and empty string in $b, we are testing a small adjustment in TransformMarcToKohaOneField too |
125 |
my $result = C4::Biblio::TransformMarcToKoha( $marc ); |
130 |
my $result = C4::Biblio::TransformMarcToKoha( $marc ); |
|
|
131 |
is( $result->{field1}, '0', 'Biblio field 510a' ); |
132 |
is( exists $result->{field2}, '', 'No field for empty string expected' ); |
126 |
is( $result->{test}, '1 | 2', 'Check 510x for two values' ); |
133 |
is( $result->{test}, '1 | 2', 'Check 510x for two values' ); |
127 |
is( $result->{norepeat}, '3 | 4 | 5', 'Check 510y too' ); |
134 |
is( $result->{norepeat}, '3 | 4 | 5', 'Check 510y too' ); |
128 |
|
135 |
|
129 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; |
136 |
# Now test no_items parameter |
130 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
|
|
131 |
$marc->append_fields( MARC::Field->new( '510', '', '', a => '1' ) ); # actually, we should only have one $y (BZ 24652) |
132 |
|
133 |
$result = C4::Biblio::TransformMarcToKoha( $marc, '', 'no_items' ); |
137 |
$result = C4::Biblio::TransformMarcToKoha( $marc, '', 'no_items' ); |
|
|
138 |
is( $result->{field1}, '0', 'Biblio field returned when "no_items" passed' ); |
134 |
is( $result->{test}, undef, 'Item field not returned when "no_items" passed' ); |
139 |
is( $result->{test}, undef, 'Item field not returned when "no_items" passed' ); |
135 |
is( $result->{norepeat}, undef, 'Item field not returned when "no_items" passed' ); |
140 |
is( $result->{norepeat}, undef, 'Item field not returned when "no_items" passed' ); |
136 |
is( $result->{field1}, 1, 'Biblio field returned when "no_items" passed' ); |
|
|
137 |
}; |
141 |
}; |
138 |
|
142 |
|
139 |
# Cleanup |
143 |
# Cleanup |
140 |
- |
|
|