Lines 4-10
Link Here
|
4 |
|
4 |
|
5 |
use Modern::Perl; |
5 |
use Modern::Perl; |
6 |
|
6 |
|
7 |
use Test::More tests => 12; |
7 |
use Test::More tests => 13; |
8 |
|
8 |
|
9 |
use Getopt::Long; |
9 |
use Getopt::Long; |
10 |
use MARC::Record; |
10 |
use MARC::Record; |
Lines 187-192
subtest 'Test merge A1 to modified A1, test strict mode' => sub {
Link Here
|
187 |
# Note: the +1 comes from the added subfield $9 in the biblio |
187 |
# Note: the +1 comes from the added subfield $9 in the biblio |
188 |
}; |
188 |
}; |
189 |
|
189 |
|
|
|
190 |
subtest 'Test merge A1 to B1 (choosing language)' => sub { |
191 |
plan tests => 4; |
192 |
|
193 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', '' ); |
194 |
|
195 |
my $auth1 = MARC::Record->new; |
196 |
$auth1->append_fields( |
197 |
MARC::Field->new( '109', '0', '0', 'a' => 'language da', '7' => 'da' ), |
198 |
MARC::Field->new( '109', '0', '0', 'a' => 'language ba', '7' => 'ba' ), |
199 |
); |
200 |
my $authid1 = AddAuthority( $auth1, undef, $authtype1 ); |
201 |
|
202 |
my $marc = MARC::Record->new; |
203 |
$marc->append_fields( |
204 |
MARC::Field->new( '003', 'some_003' ), |
205 |
MARC::Field->new( '245', '', '', a => 'My title' ), |
206 |
MARC::Field->new( '609', '', '', a => 'language ba', '7' => 'ba', 9 => $authid1 ), |
207 |
); |
208 |
my ($biblionumber) = C4::Biblio::AddBiblio( $marc, '' ); |
209 |
|
210 |
@linkedrecords = ($biblionumber); |
211 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } ); |
212 |
my $biblio = Koha::Biblios->find($biblionumber)->metadata->record; |
213 |
|
214 |
is( |
215 |
$biblio->subfield( '609', 'a' ), 'language da', |
216 |
'When LanguageToReportOnMerge is not set, the first authority field is used' |
217 |
); |
218 |
|
219 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' ); |
220 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } ); |
221 |
$biblio = Koha::Biblios->find($biblionumber)->metadata->record; |
222 |
is( |
223 |
$biblio->subfield( '609', 'a' ), 'language ba', |
224 |
'When LanguageToReportOnMerge is set, the field with the matching language is reported' |
225 |
); |
226 |
|
227 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'xx' ); |
228 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } ); |
229 |
$biblio = Koha::Biblios->find($biblionumber)->metadata->record; |
230 |
is( |
231 |
$biblio->subfield( '609', 'a' ), 'language da', |
232 |
'When LanguageToReportOnMerge is set to a value that does not exist in the authority, the first authority field is used' |
233 |
); |
234 |
|
235 |
# Long form of lang code |
236 |
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' ); |
237 |
my $auth2 = MARC::Record->new; |
238 |
$auth2->append_fields( |
239 |
MARC::Field->new( '109', '0', '0', 'a' => 'language da (long form)', '7' => 'ba0yda0y' ), |
240 |
MARC::Field->new( '109', '0', '0', 'a' => 'language ba (long form)', '7' => 'ba0yba0y' ), |
241 |
); |
242 |
my $authid2 = AddAuthority( $auth2, undef, $authtype1 ); |
243 |
|
244 |
$marc = MARC::Record->new; |
245 |
$marc->append_fields( |
246 |
MARC::Field->new( '003', 'some_003' ), |
247 |
MARC::Field->new( '245', '', '', a => 'My title' ), |
248 |
MARC::Field->new( '609', '', '', a => 'language ba', '7' => 'ba', 9 => $authid2 ), |
249 |
); |
250 |
my ($biblionumber2) = C4::Biblio::AddBiblio( $marc, '' ); |
251 |
|
252 |
@linkedrecords = ($biblionumber2); |
253 |
C4::AuthoritiesMarc::merge( { mergefrom => $authid2, MARCfrom => $auth2, mergeto => $authid2, MARCto => $auth2 } ); |
254 |
my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record; |
255 |
is( |
256 |
$biblio2->subfield( '609', 'a' ), 'language ba (long form)', |
257 |
'When LanguageToReportOnMerge is set, the field with the matching language in its long form is reported' |
258 |
); |
259 |
|
260 |
}; |
261 |
|
190 |
subtest 'Test merge A1 to B1 (changing authtype)' => sub { |
262 |
subtest 'Test merge A1 to B1 (changing authtype)' => sub { |
191 |
# Tests were aimed for bug 9988, moved to 17909 in adjusted form |
263 |
# Tests were aimed for bug 9988, moved to 17909 in adjusted form |
192 |
# Would not encourage this type of merge, but we should test what we offer |
264 |
# Would not encourage this type of merge, but we should test what we offer |
193 |
- |
|
|