|
Lines 3-11
Link Here
|
| 3 |
# Tests for C4::AuthoritiesMarc::merge |
3 |
# Tests for C4::AuthoritiesMarc::merge |
| 4 |
|
4 |
|
| 5 |
use Modern::Perl; |
5 |
use Modern::Perl; |
| 6 |
|
|
|
| 7 |
use Test::NoWarnings; |
6 |
use Test::NoWarnings; |
| 8 |
use Test::More tests => 13; |
7 |
use Test::More tests => 14; |
| 9 |
|
8 |
|
| 10 |
use Getopt::Long; |
9 |
use Getopt::Long; |
| 11 |
use MARC::Record; |
10 |
use MARC::Record; |
|
Lines 211-216
subtest 'Test merge A1 to modified A1, test strict mode' => sub {
Link Here
|
| 211 |
# Note: the +1 comes from the added subfield $9 in the biblio |
210 |
# Note: the +1 comes from the added subfield $9 in the biblio |
| 212 |
}; |
211 |
}; |
| 213 |
|
212 |
|
|
|
213 |
subtest 'Test merge A1 to B1 (choosing language)' => sub { |
| 214 |
plan tests => 4; |
| 215 |
|
| 216 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', '' ); |
| 217 |
|
| 218 |
my $auth1 = MARC::Record->new; |
| 219 |
$auth1->append_fields( |
| 220 |
MARC::Field->new( '109', '0', '0', 'a' => 'language da', '7' => 'da' ), |
| 221 |
MARC::Field->new( '109', '0', '0', 'a' => 'language ba', '7' => 'ba' ), |
| 222 |
); |
| 223 |
my $authid1 = AddAuthority( $auth1, undef, $authtype1 ); |
| 224 |
|
| 225 |
my $marc = MARC::Record->new; |
| 226 |
$marc->append_fields( |
| 227 |
MARC::Field->new( '003', 'some_003' ), |
| 228 |
MARC::Field->new( '245', '', '', a => 'My title' ), |
| 229 |
MARC::Field->new( '609', '', '', a => 'language ba', '7' => 'ba', 9 => $authid1 ), |
| 230 |
); |
| 231 |
my ($biblionumber) = C4::Biblio::AddBiblio( $marc, '' ); |
| 232 |
|
| 233 |
@linkedrecords = ($biblionumber); |
| 234 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } ); |
| 235 |
my $biblio = Koha::Biblios->find($biblionumber)->metadata->record; |
| 236 |
|
| 237 |
is( |
| 238 |
$biblio->subfield( '609', 'a' ), 'language da', |
| 239 |
'When LanguageToReportOnMerge is not set, the first authority field is used' |
| 240 |
); |
| 241 |
|
| 242 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' ); |
| 243 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } ); |
| 244 |
$biblio = Koha::Biblios->find($biblionumber)->metadata->record; |
| 245 |
is( |
| 246 |
$biblio->subfield( '609', 'a' ), 'language ba', |
| 247 |
'When LanguageToReportOnMerge is set, the field with the matching language is reported' |
| 248 |
); |
| 249 |
|
| 250 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'xx' ); |
| 251 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } ); |
| 252 |
$biblio = Koha::Biblios->find($biblionumber)->metadata->record; |
| 253 |
is( |
| 254 |
$biblio->subfield( '609', 'a' ), 'language da', |
| 255 |
'When LanguageToReportOnMerge is set to a value that does not exist in the authority, the first authority field is used' |
| 256 |
); |
| 257 |
|
| 258 |
# Long form of lang code |
| 259 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' ); |
| 260 |
my $auth2 = MARC::Record->new; |
| 261 |
$auth2->append_fields( |
| 262 |
MARC::Field->new( '109', '0', '0', 'a' => 'language da (long form)', '7' => 'ba0yda0y' ), |
| 263 |
MARC::Field->new( '109', '0', '0', 'a' => 'language ba (long form)', '7' => 'ba0yba0y' ), |
| 264 |
); |
| 265 |
my $authid2 = AddAuthority( $auth2, undef, $authtype1 ); |
| 266 |
|
| 267 |
$marc = MARC::Record->new; |
| 268 |
$marc->append_fields( |
| 269 |
MARC::Field->new( '003', 'some_003' ), |
| 270 |
MARC::Field->new( '245', '', '', a => 'My title' ), |
| 271 |
MARC::Field->new( '609', '', '', a => 'language ba', '7' => 'ba', 9 => $authid2 ), |
| 272 |
); |
| 273 |
my ($biblionumber2) = C4::Biblio::AddBiblio( $marc, '' ); |
| 274 |
|
| 275 |
@linkedrecords = ($biblionumber2); |
| 276 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid2, MARCfrom => $auth2, mergeto => $authid2, MARCto => $auth2 } ); |
| 277 |
my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record; |
| 278 |
is( |
| 279 |
$biblio2->subfield( '609', 'a' ), 'language ba (long form)', |
| 280 |
'When LanguageToReportOnMerge is set, the field with the matching language in its long form is reported' |
| 281 |
); |
| 282 |
|
| 283 |
}; |
| 284 |
|
| 214 |
subtest 'Test merge A1 to B1 (changing authtype)' => sub { |
285 |
subtest 'Test merge A1 to B1 (changing authtype)' => sub { |
| 215 |
|
286 |
|
| 216 |
# Tests were aimed for bug 9988, moved to 17909 in adjusted form |
287 |
# Tests were aimed for bug 9988, moved to 17909 in adjusted form |
| 217 |
- |
|
|