3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test
::More tests
=> 12;
22 use List
::MoreUtils
qw( uniq );
25 use t
::lib
::Mocks
qw( mock_preference );
26 use t
::lib
::TestBuilder
;
30 use Koha
::MarcSubfieldStructures
;
36 my $schema = Koha
::Database
->new->schema;
37 $schema->storage->txn_begin;
38 my $dbh = C4
::Context
->dbh;
39 Koha
::Caches
->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
41 subtest
'GetMarcSubfieldStructureFromKohaField' => sub {
45 tagfield tagsubfield liblibrarian libopac repeatable mandatory kohafield tab
46 authorised_value authtypecode value_builder isurl hidden frameworkcode
47 seealso link defaultvalue maxlength
50 # biblio.biblionumber must be mapped so this should return something
51 my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField
('biblio.biblionumber');
53 ok
(defined $marc_subfield_structure, "There is a result");
54 is
(ref $marc_subfield_structure, "HASH", "Result is a hashref");
55 foreach my $col (@columns) {
56 ok
(exists $marc_subfield_structure->{$col}, "Hashref contains key '$col'");
58 is
($marc_subfield_structure->{kohafield
}, 'biblio.biblionumber', "Result is the good result");
59 like
($marc_subfield_structure->{tagfield
}, qr/^\d{3}$/, "tagfield is a valid tagfield");
61 # Add a test for list context (BZ 10306)
62 my @results = GetMarcSubfieldStructureFromKohaField
('biblio.biblionumber');
63 is
( @results, 1, 'We expect only one mapping' );
64 is_deeply
( $results[0], $marc_subfield_structure,
65 'The first entry should be the same hashref as we had before' );
67 # foo.bar does not exist so this should return undef
68 $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField
('foo.bar');
69 is
($marc_subfield_structure, undef, "invalid kohafield returns undef");
73 subtest
"GetMarcSubfieldStructure" => sub {
76 # Add multiple Koha to Marc mappings
77 Koha
::MarcSubfieldStructures
->search({ frameworkcode
=> '', tagfield
=> '399', tagsubfield
=> [ 'a', 'b' ] })->delete;
78 Koha
::MarcSubfieldStructure
->new({ frameworkcode
=> '', tagfield
=> '399', tagsubfield
=> 'a', kohafield
=> "mytable.nicepages" })->store;
79 Koha
::MarcSubfieldStructure
->new({ frameworkcode
=> '', tagfield
=> '399', tagsubfield
=> 'b', kohafield
=> "mytable.nicepages" })->store;
80 Koha
::Caches
->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
81 my $structure = C4
::Biblio
::GetMarcSubfieldStructure
('');
83 is
( @
{ $structure->{"mytable.nicepages"} }, 2,
84 'GetMarcSubfieldStructure should return two entries for nicepages' );
85 is
( $structure->{"mytable.nicepages"}->[0]->{tagfield
}, '399',
86 'Check tagfield for first entry' );
87 is
( $structure->{"mytable.nicepages"}->[0]->{tagsubfield
}, 'a',
88 'Check tagsubfield for first entry' );
89 is
( $structure->{"mytable.nicepages"}->[1]->{tagfield
}, '399',
90 'Check tagfield for second entry' );
91 is
( $structure->{"mytable.nicepages"}->[1]->{tagsubfield
}, 'b',
92 'Check tagsubfield for second entry' );
95 subtest
"GetMarcFromKohaField" => sub {
98 #NOTE: We are building on data from the previous subtest
99 # With: field 399 / mytable.nicepages
101 # Check call in list context for multiple mappings
102 my @retval = C4
::Biblio
::GetMarcFromKohaField
('mytable.nicepages');
103 is
( @retval, 4, 'Should return two tags and subfields' );
104 is
( $retval[0], '399', 'Check first tag' );
105 is
( $retval[1], 'a', 'Check first subfield' );
106 is
( $retval[2], '399', 'Check second tag' );
107 is
( $retval[3], 'b', 'Check second subfield' );
109 # Check same call in scalar context
110 is
( C4
::Biblio
::GetMarcFromKohaField
('mytable.nicepages'), '399',
111 'GetMarcFromKohaField returns first tag in scalar context' );
113 # Bug 19096 Default is authoritative
114 # If we add a new empty framework, we should still get the mappings
115 # from Default. CAUTION: This test passes intentionally the obsoleted
116 # framework parameter.
117 my $new_fw = t
::lib
::TestBuilder
->new->build({source
=> 'BiblioFramework'});
118 @retval = C4
::Biblio
::GetMarcFromKohaField
(
119 'mytable.nicepages', $new_fw->{frameworkcode
},
121 is
( @retval, 4, 'Still got two pairs of tags/subfields' );
122 is
( $retval[0].$retval[1], '399a', 'Including 399a' );
126 my $biblio_module = new Test
::MockModule
('C4::Biblio');
127 $biblio_module->mock(
128 'GetMarcSubfieldStructure',
132 my ( $title_field, $title_subfield ) = get_title_field
();
133 my ( $isbn_field, $isbn_subfield ) = get_isbn_field
();
134 my ( $issn_field, $issn_subfield ) = get_issn_field
();
135 my ( $biblionumber_field, $biblionumber_subfield ) = ( '999', 'c' );
136 my ( $biblioitemnumber_field, $biblioitemnumber_subfield ) = ( '999', '9' );
137 my ( $itemnumber_field, $itemnumber_subfield ) = get_itemnumber_field
();
140 'biblio.title' => [ { tagfield
=> $title_field, tagsubfield
=> $title_subfield } ],
141 'biblio.biblionumber' => [ { tagfield
=> $biblionumber_field, tagsubfield
=> $biblionumber_subfield } ],
142 'biblioitems.isbn' => [ { tagfield
=> $isbn_field, tagsubfield
=> $isbn_subfield } ],
143 'biblioitems.issn' => [ { tagfield
=> $issn_field, tagsubfield
=> $issn_subfield } ],
144 'biblioitems.biblioitemnumber' => [ { tagfield
=> $biblioitemnumber_field, tagsubfield
=> $biblioitemnumber_subfield } ],
145 'items.itemnumber' => [ { tagfield
=> $itemnumber_subfield, tagsubfield
=> $itemnumber_subfield } ],
150 my $currency = new Test
::MockModule
('Koha::Acquisition::Currencies');
154 return Koha
::Acquisition
::Currency
->new(
166 my $marcflavour = shift;
167 t
::lib
::Mocks
::mock_preference
('marcflavour', $marcflavour);
169 my $isbn = '0590353403';
170 my $title = 'Foundation';
172 # Generate a record with just the ISBN
173 my $marc_record = MARC
::Record
->new;
174 $marc_record->append_fields( create_isbn_field
( $isbn, $marcflavour ) );
176 # Add the record to the DB
177 my( $biblionumber, $biblioitemnumber ) = AddBiblio
( $marc_record, '' );
178 my $data = GetBiblioData
( $biblionumber );
179 is
( $data->{ isbn
}, $isbn,
180 '(GetBiblioData) ISBN correctly retireved.');
181 is
( $data->{ title
}, undef,
182 '(GetBiblioData) Title field is empty in fresh biblio.');
184 my ( $isbn_field, $isbn_subfield ) = get_isbn_field
();
185 my $marc = GetMarcBiblio
({ biblionumber
=> $biblionumber });
186 is
( $marc->subfield( $isbn_field, $isbn_subfield ), $isbn, );
189 my $field = create_title_field
( $title, $marcflavour );
190 $marc_record->append_fields( $field );
191 ModBiblio
( $marc_record, $biblionumber ,'' );
192 $data = GetBiblioData
( $biblionumber );
193 is
( $data->{ title
}, $title,
194 'ModBiblio correctly added the title field, and GetBiblioData.');
195 is
( $data->{ isbn
}, $isbn, '(ModBiblio) ISBN is still there after ModBiblio.');
196 $marc = GetMarcBiblio
({ biblionumber
=> $biblionumber });
197 my ( $title_field, $title_subfield ) = get_title_field
();
198 is
( $marc->subfield( $title_field, $title_subfield ), $title, );
200 my $biblioitem = Koha
::Biblioitems
->find( $biblioitemnumber );
201 is
( $biblioitem->_result->biblio->title, $title, # Should be $biblioitem->biblio instead, but not needed elsewhere for now
202 'Do not know if this makes sense - compare result of previous two GetBiblioData tests.');
203 is
( $biblioitem->isbn, $isbn,
204 'Second test checking it returns the correct isbn.');
207 $field = MARC
::Field
->new(
209 'a' => 'Auction catalogs',
213 $marc_record->append_fields($field);
214 $success = ModBiblio
($marc_record,$biblionumber,'');
219 ok
($success, "ModBiblio handles authority-linked 655");
222 $field->delete_subfields('a');
223 $marc_record->append_fields($field);
224 $success = ModBiblio
($marc_record,$biblionumber,'');
229 ok
($success, "ModBiblio handles 655 with authority link but no heading");
232 $field->delete_subfields('9');
233 $marc_record->append_fields($field);
234 $success = ModBiblio
($marc_record,$biblionumber,'');
239 ok
($success, "ModBiblio handles 655 with no subfields");
241 ## Testing GetMarcISSN
243 $issns = GetMarcISSN
( $marc_record, $marcflavour );
244 is
( $issns->[0], undef,
245 'GetMarcISSN handles records without the ISSN field (list is empty)' );
246 is
( scalar @
$issns, 0,
247 'GetMarcISSN handles records without the ISSN field (count is 0)' );
249 my $issn = '1234-1234';
250 $field = create_issn_field
( $issn, $marcflavour );
251 $marc_record->append_fields($field);
252 $issns = GetMarcISSN
( $marc_record, $marcflavour );
253 is
( $issns->[0], $issn,
254 'GetMarcISSN handles records with a single ISSN field (first element is correct)' );
255 is
( scalar @
$issns, 1,
256 'GetMARCISSN handles records with a single ISSN field (count is 1)');
257 # Add multiple ISSN field
258 my @more_issns = qw
/1111-1111 2222-2222 3333-3333/;
259 foreach (@more_issns) {
260 $field = create_issn_field
( $_, $marcflavour );
261 $marc_record->append_fields($field);
263 $issns = GetMarcISSN
( $marc_record, $marcflavour );
264 is
( scalar @
$issns, 4,
265 'GetMARCISSN handles records with multiple ISSN fields (count correct)');
266 # Create an empty ISSN
267 $field = create_issn_field
( "", $marcflavour );
268 $marc_record->append_fields($field);
269 $issns = GetMarcISSN
( $marc_record, $marcflavour );
270 is
( scalar @
$issns, 4,
271 'GetMARCISSN skips empty ISSN fields (Bug 12674)');
273 ## Testing GetMarcControlnumber
275 $controlnumber = GetMarcControlnumber
( $marc_record, $marcflavour );
276 is
( $controlnumber, '', 'GetMarcControlnumber handles records without 001' );
278 $field = MARC
::Field
->new( '001', '' );
279 $marc_record->append_fields($field);
280 $controlnumber = GetMarcControlnumber
( $marc_record, $marcflavour );
281 is
( $controlnumber, '', 'GetMarcControlnumber handles records with empty 001' );
283 $field = $marc_record->field('001');
284 $field->update('123456789X');
285 $controlnumber = GetMarcControlnumber
( $marc_record, $marcflavour );
286 is
( $controlnumber, '123456789X', 'GetMarcControlnumber handles records with 001' );
288 ## Testing GetMarcISBN
289 my $record_for_isbn = MARC
::Record
->new();
290 my $isbns = GetMarcISBN
( $record_for_isbn, $marcflavour );
291 is
( scalar @
$isbns, 0, '(GetMarcISBN) The record contains no ISBN');
294 $isbn_field = create_isbn_field
( $isbn, $marcflavour );
295 $record_for_isbn->append_fields( $isbn_field );
296 $isbns = GetMarcISBN
( $record_for_isbn, $marcflavour );
297 is
( scalar @
$isbns, 1, '(GetMarcISBN) The record contains one ISBN');
298 is
( $isbns->[0], $isbn, '(GetMarcISBN) The record contains our ISBN');
300 # We add 3 more ISBNs
301 $record_for_isbn = MARC
::Record
->new();
302 my @more_isbns = qw
/1111111111 2222222222 3333333333 444444444/;
303 foreach (@more_isbns) {
304 $field = create_isbn_field
( $_, $marcflavour );
305 $record_for_isbn->append_fields($field);
307 $isbns = GetMarcISBN
( $record_for_isbn, $marcflavour );
308 is
( scalar @
$isbns, 4, '(GetMarcISBN) The record contains 4 ISBNs');
309 for my $i (0 .. $#more_isbns) {
310 is
( $isbns->[$i], $more_isbns[$i],
311 "(GetMarcISBN) Correctly retrieves ISBN #". ($i + 1));
314 is
( GetMarcPrice
( $record_for_isbn, $marcflavour ), 100,
315 "GetMarcPrice returns the correct value");
316 my $newincbiblioitemnumber=$biblioitemnumber+1;
317 $dbh->do("UPDATE biblioitems SET biblioitemnumber = ? WHERE biblionumber = ?;", undef, $newincbiblioitemnumber, $biblionumber );
318 my $updatedrecord = GetMarcBiblio
({
319 biblionumber
=> $biblionumber,
321 my $frameworkcode = GetFrameworkCode
($biblionumber);
322 my ( $biblioitem_tag, $biblioitem_subfield ) = GetMarcFromKohaField
( "biblioitems.biblioitemnumber" );
323 die qq{No biblioitemnumber tag
for framework
"$frameworkcode"} unless $biblioitem_tag;
324 my $biblioitemnumbertotest;
325 if ( $biblioitem_tag < 10 ) {
326 $biblioitemnumbertotest = $updatedrecord->field($biblioitem_tag)->data();
328 $biblioitemnumbertotest = $updatedrecord->field($biblioitem_tag)->subfield($biblioitem_subfield);
330 is
($newincbiblioitemnumber, $biblioitemnumbertotest, 'Check newincbiblioitemnumber');
332 # test for GetMarcNotes
333 my $a1= GetMarcNotes
( $marc_record, $marcflavour );
334 my $field2 = MARC
::Field
->new( $marcflavour eq 'UNIMARC'?
300: 555, 0, '', a
=> 'Some text', u
=> 'http://url-1.com', u
=> 'nohttp://something_else' );
335 $marc_record->append_fields( $field2 );
336 my $a2= GetMarcNotes
( $marc_record, $marcflavour );
337 is
( ( $marcflavour eq 'UNIMARC' && @
$a2 == @
$a1 + 1 ) ||
338 ( $marcflavour ne 'UNIMARC' && @
$a2 == @
$a1 + 3 ), 1,
339 'Check the number of returned notes of GetMarcNotes' );
341 # test for GetMarcUrls
342 $marc_record->append_fields(
343 MARC
::Field
->new( '856', '', '', u
=> ' https://koha-community.org ' ),
344 MARC
::Field
->new( '856', '', '', u
=> 'koha-community.org' ),
346 my $marcurl = GetMarcUrls
( $marc_record, $marcflavour );
347 is
( @
$marcurl, 2, 'GetMarcUrls returns two URLs' );
348 like
( $marcurl->[0]->{MARCURL
}, qr/^https/, 'GetMarcUrls did not stumble over a preceding space' );
349 ok
( $marcflavour ne 'MARC21' || $marcurl->[1]->{MARCURL
} =~ /^http:\/\
//,
350 'GetMarcUrls prefixed a MARC21 URL with http://' );
352 # Automatic authority creation
353 t
::lib
::Mocks
::mock_preference
('BiblioAddsAuthorities', 1);
354 t
::lib
::Mocks
::mock_preference
('AutoCreateAuthorities', 1);
355 my $authorities_mod = Test
::MockModule
->new( 'C4::AuthoritiesMarc' );
356 $authorities_mod->mock(
364 $field = create_author_field
('Author Name');
366 $marc_record->append_fields($field);
367 $success = ModBiblio
($marc_record,$biblionumber,'');
372 ok
($success, "ModBiblio handles authority addition for author");
374 my ($author_field, $author_subfield, $author_relator_subfield) = get_author_field
();
375 $field = $marc_record->field($author_field);
376 ok
($field->subfield($author_subfield), "ModBiblio keeps $author_field$author_subfield intact");
378 my $authid = $field->subfield('9');
379 ok
($authid, 'ModBiblio adds authority id');
381 use_ok
('C4::AuthoritiesMarc');
382 my $auth_record = C4
::AuthoritiesMarc
::GetAuthority
($authid);
383 ok
($auth_record, 'Authority record successfully retrieved');
386 my ($auth_author_field, $auth_author_subfield) = get_auth_author_field
();
387 $field = $auth_record->field($auth_author_field);
388 ok
($field, "Authority record contains field $auth_author_field");
390 $field->subfield($auth_author_subfield),
392 'Authority $auth_author_field$auth_author_subfield contains author name'
394 is
($field->subfield($author_relator_subfield), undef, 'Authority does not contain relator subfield');
397 t
::lib
::Mocks
::mock_preference
('BiblioAddsAuthorities', 0);
398 t
::lib
::Mocks
::mock_preference
('AutoCreateAuthorities', 0);
401 sub get_title_field
{
402 my $marc_flavour = C4
::Context
->preference('marcflavour');
403 return ( $marc_flavour eq 'UNIMARC' ) ?
( '200', 'a' ) : ( '245', 'a' );
407 my $marc_flavour = C4
::Context
->preference('marcflavour');
408 return ( $marc_flavour eq 'UNIMARC' ) ?
( '010', 'a' ) : ( '020', 'a' );
412 my $marc_flavour = C4
::Context
->preference('marcflavour');
413 return ( $marc_flavour eq 'UNIMARC' ) ?
( '011', 'a' ) : ( '022', 'a' );
416 sub get_itemnumber_field
{
417 my $marc_flavour = C4
::Context
->preference('marcflavour');
418 return ( $marc_flavour eq 'UNIMARC' ) ?
( '995', '9' ) : ( '952', '9' );
421 sub get_author_field
{
422 my $marc_flavour = C4
::Context
->preference('marcflavour');
423 return ( $marc_flavour eq 'UNIMARC' ) ?
( '700', 'a', '4' ) : ( '100', 'a', 'e' );
426 sub get_auth_author_field
{
427 my $marc_flavour = C4
::Context
->preference('marcflavour');
428 return ( $marc_flavour eq 'UNIMARC' ) ?
( '106', 'a' ) : ( '100', 'a' );
431 sub create_title_field
{
432 my ( $title, $marcflavour ) = @_;
434 my ( $title_field, $title_subfield ) = get_title_field
();
435 my $field = MARC
::Field
->new( $title_field, '', '', $title_subfield => $title );
440 sub create_isbn_field
{
441 my ( $isbn, $marcflavour ) = @_;
443 my ( $isbn_field, $isbn_subfield ) = get_isbn_field
();
444 my $field = MARC
::Field
->new( $isbn_field, '', '', $isbn_subfield => $isbn );
446 # Add the price subfield
447 my $price_subfield = ( $marcflavour eq 'UNIMARC' ) ?
'd' : 'c';
448 $field->add_subfields( $price_subfield => '$100' );
453 sub create_issn_field
{
454 my ( $issn, $marcflavour ) = @_;
456 my ( $issn_field, $issn_subfield ) = get_issn_field
();
457 my $field = MARC
::Field
->new( $issn_field, '', '', $issn_subfield => $issn );
462 sub create_author_field
{
465 my ( $author_field, $author_subfield, $author_relator_subfield ) = get_author_field
();
466 my $field = MARC
::Field
->new(
467 $author_field, '', '',
468 $author_subfield => $author,
469 $author_relator_subfield => 'aut'
475 subtest
'MARC21' => sub {
478 $schema->storage->txn_rollback;
479 $schema->storage->txn_begin;
482 subtest
'UNIMARC' => sub {
485 # Mock the auth type data for UNIMARC
486 $dbh->do("UPDATE auth_types SET auth_tag_to_report = '106' WHERE auth_tag_to_report = '100'") or die $dbh->errstr;
488 run_tests
('UNIMARC');
489 $schema->storage->txn_rollback;
490 $schema->storage->txn_begin;
493 subtest
'NORMARC' => sub {
495 run_tests
('NORMARC');
496 $schema->storage->txn_rollback;
497 $schema->storage->txn_begin;
500 subtest
'IsMarcStructureInternal' => sub {
502 my $tagslib = GetMarcStructure
();
504 for my $tag ( sort keys %$tagslib ) {
506 for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
507 push @internals, $subfield if IsMarcStructureInternal
($tagslib->{$tag}{$subfield});
510 @internals = uniq
@internals;
511 is
( scalar(@internals), 6, 'expect 6 internals');
512 is
( grep( /^lib$/, @internals ), 1, 'check lib' );
513 is
( grep( /^tab$/, @internals ), 1, 'check tab' );
514 is
( grep( /^mandatory$/, @internals ), 1, 'check mandatory' );
515 is
( grep( /^repeatable$/, @internals ), 1, 'check repeatable' );
516 is
( grep( /^a$/, @internals ), 0, 'no subfield a' );
517 is
( grep( /^ind1_defaultvalue$/, @internals ), 1, 'check indicator 1 default value' );
518 is
( grep( /^ind2_defaultvalue$/, @internals ), 1, 'check indicator 2 default value' );
521 subtest
'deletedbiblio_metadata' => sub {
524 my ($biblionumber, $biblioitemnumber) = AddBiblio
(MARC
::Record
->new, '');
525 my $biblio_metadata = C4
::Biblio
::GetXmlBiblio
( $biblionumber );
526 C4
::Biblio
::DelBiblio
( $biblionumber );
527 my ( $moved ) = $dbh->selectrow_array(q
|SELECT biblionumber FROM deletedbiblio WHERE biblionumber
=?
|, undef, $biblionumber);
528 is
( $moved, $biblionumber, 'Found in deletedbiblio' );
529 ( $moved ) = $dbh->selectrow_array(q
|SELECT biblionumber FROM deletedbiblio_metadata WHERE biblionumber
=?
|, undef, $biblionumber);
530 is
( $moved, $biblionumber, 'Found in deletedbiblio_metadata' );
533 subtest
'DelBiblio' => sub {
536 my ($biblionumber, $biblioitemnumber) = C4
::Biblio
::AddBiblio
(MARC
::Record
->new, '');
537 my $deleted = C4
::Biblio
::DelBiblio
( $biblionumber );
538 is
( $deleted, undef, 'DelBiblio returns undef is the biblio has been deleted correctly - Must be 1 instead'); # FIXME We should return 1 instead!
540 $deleted = C4
::Biblio
::DelBiblio
( $biblionumber );
541 is
( $deleted, undef, 'DelBiblo should return undef is the record did not exist');
544 subtest
'MarcFieldForCreatorAndModifier' => sub {
547 t
::lib
::Mocks
::mock_preference
('MarcFieldForCreatorId', '998$a');
548 t
::lib
::Mocks
::mock_preference
('MarcFieldForCreatorName', '998$b');
549 t
::lib
::Mocks
::mock_preference
('MarcFieldForModifierId', '998$c');
550 t
::lib
::Mocks
::mock_preference
('MarcFieldForModifierName', '998$d');
551 my $c4_context = Test
::MockModule
->new('C4::Context');
552 $c4_context->mock('userenv', sub { return { number
=> 123, firstname
=> 'John', surname
=> 'Doe'}; });
554 my $record = MARC
::Record
->new();
555 my ($biblionumber) = C4
::Biblio
::AddBiblio
($record, '');
557 $record = GetMarcBiblio
({biblionumber
=> $biblionumber});
558 is
($record->subfield('998', 'a'), 123, '998$a = 123');
559 is
($record->subfield('998', 'b'), 'John Doe', '998$b = John Doe');
560 is
($record->subfield('998', 'c'), 123, '998$c = 123');
561 is
($record->subfield('998', 'd'), 'John Doe', '998$d = John Doe');
563 $c4_context->mock('userenv', sub { return { number
=> 321, firstname
=> 'Jane', surname
=> 'Doe'}; });
564 C4
::Biblio
::ModBiblio
($record, $biblionumber, '');
566 $record = GetMarcBiblio
({biblionumber
=> $biblionumber});
567 is
($record->subfield('998', 'a'), 123, '998$a = 123');
568 is
($record->subfield('998', 'b'), 'John Doe', '998$b = John Doe');
569 is
($record->subfield('998', 'c'), 321, '998$c = 321');
570 is
($record->subfield('998', 'd'), 'Jane Doe', '998$d = Jane Doe');
573 subtest
'ModBiblio called from linker test' => sub {
576 t
::lib
::Mocks
::mock_preference
('BiblioAddsAuthorities', 1);
577 my $biblio_mod = Test
::MockModule
->new( 'C4::Biblio' );
578 $biblio_mod->mock( 'LinkBibHeadingsToAuthorities', sub {
581 my $record = MARC
::Record
->new();
582 my ($biblionumber) = C4
::Biblio
::AddBiblio
($record,'');
583 C4
::Biblio
::ModBiblio
($record,$biblionumber,'');
584 is
($called,1,"We called to link bibs because not from linker");
586 C4
::Biblio
::ModBiblio
($record,$biblionumber,'',1);
587 is
($called,0,"We didn't call to link bibs because from linker");
591 Koha
::Caches
->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
592 $schema->storage->txn_rollback;