3 # Copyright 2015 BibLibre
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
21 use Test::More tests => 144;
30 my $schema = Koha::Database->new->schema;
31 $schema->storage->txn_begin;
32 my $dbh = C4::Context->dbh;
34 $dbh->do('DELETE FROM oai_sets');
35 $dbh->do('DELETE FROM oai_sets_descriptions');
36 $dbh->do('DELETE FROM oai_sets_mappings');
37 $dbh->do('DELETE FROM oai_sets_biblios');
40 # ---------- Testing AddOAISet ------------------
41 ok (!defined(AddOAISet), 'AddOAISet without argument is undef');
43 my $set_without_spec_and_name_and_desc = {};
44 ok (!defined(AddOAISet($set_without_spec_and_name_and_desc)), 'AddOAISet without "field", "name" and "descriptions" fields is undef');
46 my $set_without_spec_and_name = {
47 'descriptions' => ['descNoSpecNoName'],
49 ok (!defined(AddOAISet($set_without_spec_and_name)), 'AddOAISet without "field" and "name" fields is undef');
51 my $set_without_spec = {
52 'name' => 'nameNoSpec',
53 'descriptions' => ['descNoSpec'],
55 ok (!defined(AddOAISet($set_without_spec)), 'AddOAISet without "field" field is undef');
57 my $set_without_name = {
58 'spec' => 'specNoName',
59 'descriptions' => ['descNoName'],
61 ok (!defined(AddOAISet($set_without_name)), 'AddOAISet without "name" field is undef');
63 #Test to enter in the 'else' case of 'AddOAISet' line 280
65 my $dbi_st = Test::MockModule->new('DBI::st', no_auto => 1); # ref($sth) == 'DBI::st'
66 $dbi_st->mock('execute', sub { return 0; });
69 'spec' => 'specWrong',
70 'name' => 'nameWrong',
73 warning_is { $setWrong_id = AddOAISet($setWrong) }
75 'AddOAISet raises warning if there is a problem with SET spec or SET name';
77 ok(!defined $setWrong_id, '$setWrong_id is not defined');
80 #Adding a Set without description
85 my $set1_id = AddOAISet($set1);
86 isa_ok(\$set1_id, 'SCALAR', '$set1_id is a SCALAR');
88 my $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
90 my $setsCount = $sth->fetchrow_array;
91 is ($setsCount, 1, 'There is 1 set');
93 $sth = $dbh->prepare("SELECT spec, name FROM oai_sets");
95 my ($spec, $name) = $sth->fetchrow_array;
96 is ($spec, 'specSet1', 'spec field is "specSet1"');
97 is ($name, 'nameSet1', 'name field is "nameSet1"');
99 $sth = $dbh->prepare("SELECT description FROM oai_sets_descriptions");
101 my $desc = $sth -> rows;
102 is ($desc, 0, 'There is NO set description');
104 #Adding a Set with a description
106 'spec' => 'specSet2',
107 'name' => 'nameSet2',
108 'descriptions' => ['descSet2'],
110 my $set2_id = AddOAISet($set2);
111 isa_ok(\$set2_id, 'SCALAR', '$set2_id is a SCALAR');
113 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
115 $setsCount = $sth->fetchrow_array;
116 is ($setsCount, 2, 'There is 2 sets');
118 $sth = $dbh->prepare("SELECT spec, name FROM oai_sets ORDER BY id DESC");
120 ($spec, $name) = $sth->fetchrow_array;
121 is ($spec, 'specSet2', 'spec field is "specSet2"');
122 is ($name, 'nameSet2', 'name field is "nameSet2"');
124 $sth = $dbh->prepare("SELECT description FROM oai_sets_descriptions");
126 $desc = $sth->fetchrow_array;
127 is ($desc, 'descSet2', 'description field is "descSet2"');
130 # ---------- Testing GetOAISets -----------------
131 my $oai_sets = GetOAISets;
132 isa_ok($oai_sets, 'ARRAY', '$oai_sets is an array reference of hash reference describing the sets');
134 isa_ok($oai_sets->[0], 'HASH', '$set1 is defined as a hash');
135 is ($oai_sets->[0]->{spec}, 'specSet1', 'spec field is "specSet1"');
136 is ($oai_sets->[0]->{name}, 'nameSet1', 'name field is "nameSet1"');
138 isa_ok($oai_sets->[1], 'HASH', '$set2 is defined as a hash');
139 is ($oai_sets->[1]->{spec}, 'specSet2', 'spec field is "specSet2"');
140 is ($oai_sets->[1]->{name}, 'nameSet2', 'name field is "nameSet2"');
141 is_deeply ($oai_sets->[1]->{descriptions}, ['descSet2'], 'description field is "descSet2"');
143 ok(!defined($oai_sets->[2]), 'There are only 2 sets');
146 # ---------- Testing GetOAISet ------------------
147 ok (!defined(GetOAISet), 'GetOAISet without argument is undef');
149 my $set = GetOAISet($set1_id);
150 isa_ok($set, 'HASH', '$set is a hash reference describing the set with the given set_id');
151 is ($set->{spec}, 'specSet1', 'spec field is "specSet1"');
152 is ($set->{name}, 'nameSet1', 'name field is "nameSet1"');
154 $set = GetOAISet($set2_id);
155 isa_ok($set, 'HASH', '$set is a hash reference describing the set with the given set_id');
156 is ($set->{spec}, 'specSet2', 'spec field is "specSet2"');
157 is ($set->{name}, 'nameSet2', 'name field is "nameSet2"');
158 is_deeply ($set->{descriptions}, ['descSet2'], 'description field is "descSet2"');
161 # ---------- Testing GetOAISetBySpec ------------
162 ok (!defined(GetOAISetBySpec), 'GetOAISetBySpec without argument is undef');
164 $set = GetOAISetBySpec($set1->{spec});
165 isa_ok($set, 'HASH', '$set is a hash describing the set whose spec is $oai_sets->[0]->{spec}');
166 is ($set->{spec}, 'specSet1', 'spec field is "specSet1"');
167 is ($set->{name}, 'nameSet1', 'name field is "nameSet1"');
169 $set = GetOAISetBySpec($set2->{spec});
170 isa_ok($set, 'HASH', '$set is a hash describing the set whose spec is $oai_sets->[1]->{spec}');
171 is ($set->{spec}, 'specSet2', 'spec field is "specSet2"');
172 is ($set->{name}, 'nameSet2', 'name field is "nameSet2"');
173 #GetOAISetBySpec does't return the description field.
176 # ---------- Testing ModOAISet ------------------
177 ok (!defined(ModOAISet), 'ModOAISet without argument is undef');
179 my $new_set_without_id = {
180 'spec' => 'specNoName',
181 'name' => 'nameNoSpec',
182 'descriptions' => ['descNoSpecNoName'],
185 warning_is { $res = ModOAISet($new_set_without_id) }
186 'Set ID not defined, can\'t modify the set',
187 'ModOAISet raises warning if Set ID is not defined';
188 ok(!defined($res), 'ModOAISet returns undef if Set ID is not defined');
190 my $new_set_without_spec_and_name = {
192 'descriptions' => ['descNoSpecNoName'],
194 ok (!defined(ModOAISet($new_set_without_spec_and_name)), 'ModOAISet without "field" and "name" fields is undef');
196 my $new_set_without_spec = {
198 'name' => 'nameNoSpec',
199 'descriptions' => ['descNoSpec'],
201 ok (!defined(ModOAISet($new_set_without_spec)), 'ModOAISet without "field" field is undef');
203 my $new_set_without_name = {
205 'spec' => 'specNoName',
206 'descriptions' => ['descNoName'],
208 ok (!defined(ModOAISet($new_set_without_name)), 'ModOAISet without "name" field is undef');
212 'spec' => 'new_specSet1',
213 'name' => 'new_nameSet1',
214 'descriptions' => ['new_descSet1'],
216 ModOAISet($new_set1);
220 'spec' => 'new_specSet2',
221 'name' => 'new_nameSet2',
223 ModOAISet($new_set2);
225 $set1 = GetOAISet($set1_id);
226 isa_ok($set1, 'HASH', '$set1 is defined as a hash');
227 is ($set1->{spec}, 'new_specSet1', 'spec field is "new_specSet1"');
228 is ($set1->{name}, 'new_nameSet1', 'name field is "new_nameSet1"');
229 is_deeply ($set1->{descriptions}, ['new_descSet1'], 'description field is "new_descSet1"');
231 $set2 = GetOAISet($set2_id);
232 isa_ok($set2, 'HASH', '$new_set2 is defined as a hash');
233 is ($set2->{spec}, 'new_specSet2', 'spec field is "new_specSet2"');
234 is ($set2->{name}, 'new_nameSet2', 'name field is "new_nameSet2"');
237 # ---------- Testing ModOAISetMappings ----------
238 ok (!defined(ModOAISetMappings), 'ModOAISetMappings without argument is undef');
239 #Add 1st mapping for set1
245 marcvalue => 'myMarcValue'
248 ModOAISetMappings($set1_id, $mapping1);
250 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_mappings");
252 my $mappingsCount = $sth->fetchrow_array;
253 is ($mappingsCount, 1, 'There is 1 mapping');
255 $sth = $dbh->prepare("SELECT marcfield, marcsubfield, operator, marcvalue FROM oai_sets_mappings");
257 my ($marcfield, $marcsubfield, $operator, $marcvalue) = $sth->fetchrow_array;
258 is ($marcfield, '206', 'marcfield field is "206"');
259 is ($marcsubfield, 'a', 'marcsubfield field is "a"');
260 is ($operator, 'equal', 'operator field is "equal"');
261 is ($marcvalue, 'myMarcValue', 'marcvalue field is "myMarcValue"');
263 #Mod 1st mapping of set1
268 operator => 'notequal',
269 marcvalue => 'myMarcValueBis'
272 ModOAISetMappings($set1_id, $mapping1_bis);
274 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_mappings");
276 $mappingsCount = $sth->fetchrow_array;
277 is ($mappingsCount, 1, 'There is 1 mapping');
279 $sth = $dbh->prepare("SELECT marcfield, marcsubfield, operator, marcvalue FROM oai_sets_mappings");
281 ($marcfield, $marcsubfield, $operator, $marcvalue) = $sth->fetchrow_array;
282 is ($marcfield, '256', 'marcfield field is "256"');
283 is ($marcsubfield, 'b', 'marcsubfield field is "b"');
284 is ($operator, 'notequal', 'operator field is "notequal"');
285 is ($marcvalue, 'myMarcValueBis', 'marcvalue field is "myMarcValueBis"');
287 #Add 1st mapping of set2
293 marcvalue => 'myOtherMarcValue'
296 ModOAISetMappings($set2_id, $mapping2);
298 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_mappings");
300 $mappingsCount = $sth->fetchrow_array;
301 is ($mappingsCount, 2, 'There is 2 mappings');
303 $sth = $dbh->prepare("SELECT marcfield, marcsubfield, operator, marcvalue FROM oai_sets_mappings ORDER BY set_id DESC LIMIT 1");
305 ($marcfield, $marcsubfield, $operator, $marcvalue) = $sth->fetchrow_array;
306 is ($marcfield, '306', 'marcfield field is "306"');
307 is ($marcsubfield, 'c', 'marcsubfield field is "c"');
308 is ($operator, 'equal', 'operator field is "equal"');
309 is ($marcvalue, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
312 # ---------- Testing GetOAISetsMappings ---------
313 my $mappings = GetOAISetsMappings;
315 isa_ok($mappings, 'HASH', '$mappings is a hashref of arrayrefs of hashrefs');
316 isa_ok($mappings->{$set1_id}, 'ARRAY', '$mappings->{$set1_id} is a arrayrefs of hashrefs');
317 isa_ok($mappings->{$set1_id}->[0], 'HASH', '$mappings->{$set1_id}->[0] is a hashrefs');
318 is ($mappings->{$set1_id}->[0]->{marcfield}, '256', 'marcfield field is "256"');
319 is ($mappings->{$set1_id}->[0]->{marcsubfield}, 'b', 'marcsubfield field is "b"');
320 is ($mappings->{$set1_id}->[0]->{operator}, 'notequal', 'operator field is "notequal"');
321 is ($mappings->{$set1_id}->[0]->{marcvalue}, 'myMarcValueBis', 'marcvalue field is "myMarcValueBis"');
323 isa_ok($mappings->{$set2_id}, 'ARRAY', '$mappings->{$set2_id} is a arrayrefs of hashrefs');
324 isa_ok($mappings->{$set2_id}, 'ARRAY', '$mappings->{$set2_id} is a arrayrefs of hashrefs');
325 isa_ok($mappings->{$set2_id}->[0], 'HASH', '$mappings->{$set2_id}->[0] is a hashrefs');
326 is ($mappings->{$set2_id}->[0]->{marcfield}, '306', 'marcfield field is "306"');
327 is ($mappings->{$set2_id}->[0]->{marcsubfield}, 'c', 'marcsubfield field is "c"');
328 is ($mappings->{$set2_id}->[0]->{operator}, 'equal', 'operator field is "equal"');
329 is ($mappings->{$set2_id}->[0]->{marcvalue}, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
332 # ---------- Testing GetOAISetMappings ----------
333 ok (!defined(GetOAISetMappings), 'GetOAISetMappings without argument is undef');
335 my $set_mappings1 = GetOAISetMappings($set1_id);
336 isa_ok($set_mappings1->[0], 'HASH', '$set_mappings1->[0] is a hashref');
337 is ($set_mappings1->[0]->{marcfield}, '256', 'marcfield field is "256"');
338 is ($set_mappings1->[0]->{marcsubfield}, 'b', 'marcsubfield field is "b"');
339 is ($set_mappings1->[0]->{operator}, 'notequal', 'operator field is "notequal"');
340 is ($set_mappings1->[0]->{marcvalue}, 'myMarcValueBis', 'marcvalue field is "myMarcValueBis"');
342 my $set_mappings2 = GetOAISetMappings($set2_id);
343 isa_ok($mappings->{$set2_id}->[0], 'HASH', '$mappings->{$set2_id}->[0] is a hashref');
344 is ($mappings->{$set2_id}->[0]->{marcfield}, '306', 'marcfield field is "306"');
345 is ($mappings->{$set2_id}->[0]->{marcsubfield}, 'c', 'marcsubfield field is "c"');
346 is ($mappings->{$set2_id}->[0]->{operator}, 'equal', 'operator field is "equal"');
347 is ($mappings->{$set2_id}->[0]->{marcvalue}, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
350 # ---------- Testing AddOAISetsBiblios ----------
351 ok (!defined(AddOAISetsBiblios), 'AddOAISetsBiblios without argument is undef');
352 ok (!defined(AddOAISetsBiblios(my $arg=[])), 'AddOAISetsBiblios with a no HASH argument is undef');
353 ok (defined(AddOAISetsBiblios($arg={})), 'AddOAISetsBiblios with a HASH argument is def');
355 # Create a biblio instance for testing
356 my $biblionumber1 = create_helper_biblio('Moffat, Steven');
357 isa_ok(\$biblionumber1, 'SCALAR', '$biblionumber1 is a SCALAR');
358 my $biblionumber2 = create_helper_biblio('Moffat, Steven');
359 isa_ok(\$biblionumber2, 'SCALAR', '$biblionumber2 is a SCALAR');
361 my $oai_sets_biblios = {
362 $set1_id => [$biblionumber1, $biblionumber2], # key is the set_id, and value is an array ref of biblionumbers
365 AddOAISetsBiblios($oai_sets_biblios);
367 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_biblios");
369 my $bibliosCount = $sth->fetchrow_array;
370 is ($bibliosCount, 2, 'There are 2 biblios in oai_sets_biblios');
372 #testing biblio for set1_id
373 $sth = $dbh->prepare("SELECT * FROM oai_sets_biblios WHERE set_id = ?");
374 $sth->execute($set1_id);
375 my $count = $sth->rows;
376 is ($count, '2', '$set_id1 has 2 biblio');
378 $sth->execute($set1_id);
379 my $line = ${ $sth->fetchall_arrayref( {} ) }[0];
380 is($line->{set_id}, $set1_id, "set_id is good");
381 is($line->{biblionumber}, $biblionumber1, "biblionumber is good");
383 $sth->execute($set1_id);
384 $line = ${ $sth->fetchall_arrayref( {} ) }[1];
385 is($line->{set_id}, $set1_id, "set_id is good");
386 is($line->{biblionumber}, $biblionumber2, "biblionumber is good");
388 #testing biblio for set2_id
389 $sth->execute($set2_id);
391 is ($count, '0', '$set_id2 has 0 biblio');
394 # ---------- Testing GetOAISetsBiblio -----------
395 $oai_sets = GetOAISetsBiblio($biblionumber1);
396 isa_ok($oai_sets, 'ARRAY', '$oai_sets is an arrayref of hashref where each element of the array is a set');
397 isa_ok($oai_sets->[0], 'HASH', '$oai_sets->[0] is a hashrefs of $set1_id');
398 is($oai_sets->[0]->{id}, $set1_id, 'id is $set1_id');
399 is($oai_sets->[0]->{spec}, $set1->{spec}, 'spec is new_specset1');
400 is($oai_sets->[0]->{name}, $set1->{name}, 'name is new_specname1');
402 $oai_sets = GetOAISetsBiblio($biblionumber2);
403 isa_ok($oai_sets, 'ARRAY', '$oai_sets is an arrayref of hashref where each element of the array is a set');
404 isa_ok($oai_sets->[0], 'HASH', '$oai_sets->[0] is a hashrefs of $set2_id');
405 is($oai_sets->[0]->{id}, $set1_id, 'id is $set1_id');
406 is($oai_sets->[0]->{spec}, $set1->{spec}, 'spec is new_specset1');
407 is($oai_sets->[0]->{name}, $set1->{name}, 'name is new_specname1');
410 # ---------- Testing ModOAISetsBiblios ----------
411 ok (!defined(ModOAISetsBiblios), 'ModOAISetsBiblios without argument is undef');
412 ok (!defined(ModOAISetsBiblios($arg=[])), 'ModOAISetsBiblios with a no HASH argument is undef');
413 ok (defined(ModOAISetsBiblios($arg={})), 'ModOAISetsBiblios with a HASH argument is def');
415 $oai_sets_biblios = {
416 $set1_id => [$biblionumber1],
417 $set2_id => [$biblionumber2],
419 ModOAISetsBiblios($oai_sets_biblios);
421 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_biblios");
423 $bibliosCount = $sth->fetchrow_array;
424 is ($bibliosCount, 2, 'There are 2 biblios in oai_sets_biblios');
426 #testing biblio for set1_id
427 $sth = $dbh->prepare("SELECT * FROM oai_sets_biblios WHERE set_id = ?");
428 $sth->execute($set1_id);
430 is ($count, '1', '$set_id1 has 2 biblio');
432 $sth->execute($set1_id);
433 $line = ${ $sth->fetchall_arrayref( {} ) }[0];
434 is($line->{set_id}, $set1_id, "set_id is good");
435 is($line->{biblionumber}, $biblionumber1, "biblionumber is good");
437 #testing biblio for set2_id
438 $sth->execute($set2_id);
440 is ($count, '1', '$set_id2 has 1 biblio');
442 $sth->execute($set2_id);
443 $line = ${ $sth->fetchall_arrayref( {} ) }[0];
444 is($line->{set_id}, $set2_id, "set_id is good");
445 is($line->{biblionumber}, $biblionumber2, "biblionumber is good");
448 # ---------- Testing DelOAISetsBiblio -----------
449 ok (!defined(DelOAISetsBiblio), 'DelOAISetsBiblio without argument is undef');
451 DelOAISetsBiblio($biblionumber1);
452 is_deeply(GetOAISetsBiblio($biblionumber1), [], "no biblio1 appear in any OAI sets");
454 DelOAISetsBiblio($biblionumber2);
455 is_deeply(GetOAISetsBiblio($biblionumber2), [], "no biblio2 appear in any OAI sets");
458 # ---------- Testing DelOAISet ------------------
459 ok (!defined(DelOAISet), 'DelOAISet without argument is undef');
462 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
464 $setsCount = $sth->fetchrow_array;
465 is ($setsCount, 1, 'There is 1 set left');
466 $set1 = GetOAISet($set1_id);
467 is_deeply ($set1, {}, '$set1 is empty');
470 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
472 $setsCount = $sth->fetchrow_array;
473 is ($setsCount, 0, 'There is no set anymore');
474 $set2 = GetOAISet($set2_id);
475 is_deeply ($set2, {}, '$set2 is empty');
477 $oai_sets=GetOAISets;
478 is_deeply ($oai_sets, [], '$oai_sets is empty');
481 # ---------- Testing UpdateOAISetsBiblio --------
482 ok (!defined(UpdateOAISetsBiblio), 'UpdateOAISetsBiblio without argument is undef');
483 ok (!defined(UpdateOAISetsBiblio($arg)), 'UpdateOAISetsBiblio with only 1 argument is undef');
487 'spec' => 'Set where Author is Victor Hugo',
490 my $setVH_id = AddOAISet($setVH);
492 #Create mappings : 'author' should be 'Victor Hugo'
493 my $marcflavour = C4::Context->preference('marcflavour');
496 if ($marcflavour eq 'UNIMARC' ){
502 marcvalue => 'Victor Hugo'
512 marcvalue => 'Victor Hugo'
516 ModOAISetMappings($setVH_id, $mappingsVH);
519 #Create a biblio notice corresponding at one of mappings
520 my $biblionumberVH = create_helper_biblio('Victor Hugo');
523 my $record = GetMarcBiblio($biblionumberVH);
524 UpdateOAISetsBiblio($biblionumberVH, $record);
526 #is biblio attached to setVH ?
527 my $oai_setsVH = GetOAISetsBiblio($biblionumberVH);
528 is($oai_setsVH->[0]->{id}, $setVH_id, 'id is ok');
529 is($oai_setsVH->[0]->{spec}, $setVH->{spec}, 'id is ok');
530 is($oai_setsVH->[0]->{name}, $setVH->{name}, 'id is ok');
533 # ---------- Testing CalcOAISetsBiblio ----------
534 ok (!defined(CalcOAISetsBiblio), 'CalcOAISetsBiblio without argument is undef');
536 my @setsEq = CalcOAISetsBiblio($record);
537 is_deeply(@setsEq, $setVH_id, 'The $record only belongs to $setVH');
539 #Testing CalcOAISetsBiblio for a mapping which operator is 'notequal'
542 'spec' => 'Set where Author is NOT Victor Hugo',
545 my $setNotVH_id = AddOAISet($setNotVH);
547 #Create mappings : 'author' should NOT be 'Victor Hugo'
548 $marcflavour = C4::Context->preference('marcflavour');
551 if ($marcflavour eq 'UNIMARC' ){
556 operator => 'notequal',
557 marcvalue => 'Victor Hugo'
566 operator => 'notequal',
567 marcvalue => 'Victor Hugo'
571 ModOAISetMappings($setNotVH_id, $mappingsNotVH);
574 #Create a biblio notice corresponding at one of mappings
575 my $biblionumberNotVH = create_helper_biblio('Sponge, Bob');
578 $record = GetMarcBiblio($biblionumberNotVH);
579 UpdateOAISetsBiblio($biblionumberNotVH, $record);
581 my @setsNotEq = CalcOAISetsBiblio($record);
582 is_deeply(@setsNotEq, $setNotVH_id, 'The $record only belongs to $setNotVH');
586 # ---------- Subs --------------------------------
589 # Helper method to set up a Biblio.
590 sub create_helper_biblio {
593 return unless (defined($author));
595 my $marcflavour = C4::Context->preference('marcflavour');
596 my $bib = MARC::Record->new();
597 my $title = 'Silence in the library';
599 if ($marcflavour eq 'UNIMARC' ){
601 MARC::Field->new('200', ' ', ' ', f => $author),
602 MARC::Field->new('200', ' ', ' ', a => $title),
607 MARC::Field->new('100', ' ', ' ', a => $author),
608 MARC::Field->new('245', ' ', ' ', a => $title),
611 my ($biblionumber)= AddBiblio($bib, '');
612 return $biblionumber;
615 $schema->storage->txn_rollback;