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
=> 148;
27 use_ok
('C4::OAI::Sets');
28 use_ok
('MARC::Record');
51 my $dbh = C4
::Context
->dbh;
52 $dbh->{AutoCommit
} = 0;
53 $dbh->{RaiseError
} = 1;
54 $dbh->do('DELETE FROM oai_sets');
55 $dbh->do('DELETE FROM oai_sets_descriptions');
56 $dbh->do('DELETE FROM oai_sets_mappings');
57 $dbh->do('DELETE FROM oai_sets_biblios');
60 # ---------- Testing AddOAISet ------------------
61 ok
(!defined(AddOAISet
), 'AddOAISet without argument is undef');
63 my $set_without_spec_and_name_and_desc = {};
64 ok
(!defined(AddOAISet
($set_without_spec_and_name_and_desc)), 'AddOAISet without "field", "name" and "descriptions" fields is undef');
66 my $set_without_spec_and_name = {
67 'descriptions' => ['descNoSpecNoName'],
69 ok
(!defined(AddOAISet
($set_without_spec_and_name)), 'AddOAISet without "field" and "name" fields is undef');
71 my $set_without_spec = {
72 'name' => 'nameNoSpec',
73 'descriptions' => ['descNoSpec'],
75 ok
(!defined(AddOAISet
($set_without_spec)), 'AddOAISet without "field" field is undef');
77 my $set_without_name = {
78 'spec' => 'specNoName',
79 'descriptions' => ['descNoName'],
81 ok
(!defined(AddOAISet
($set_without_name)), 'AddOAISet without "name" field is undef');
83 #Test to enter in the 'else' case of 'AddOAISet' line 280
85 my $dbi_st = Test
::MockModule
->new('DBI::st', no_auto
=> 1); # ref($sth) == 'DBI::st'
86 $dbi_st->mock('execute', sub { return 0; });
89 'spec' => 'specWrong',
90 'name' => 'nameWrong',
93 warning_is
{ $setWrong_id = AddOAISet
($setWrong) }
95 'AddOAISet raises warning if there is a problem with SET spec or SET name';
97 ok
(!defined $setWrong_id, '$setWrong_id is not defined');
100 #Adding a Set without description
102 'spec' => 'specSet1',
103 'name' => 'nameSet1',
105 my $set1_id = AddOAISet
($set1);
106 isa_ok
(\
$set1_id, 'SCALAR', '$set1_id is a SCALAR');
108 my $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
110 my $setsCount = $sth->fetchrow_array;
111 is
($setsCount, 1, 'There is 1 set');
113 $sth = $dbh->prepare("SELECT spec, name FROM oai_sets");
115 my ($spec, $name) = $sth->fetchrow_array;
116 is
($spec, 'specSet1', 'spec field is "specSet1"');
117 is
($name, 'nameSet1', 'name field is "nameSet1"');
119 $sth = $dbh->prepare("SELECT description FROM oai_sets_descriptions");
121 my $desc = $sth -> rows
;
122 is
($desc, 0, 'There is NO set description');
124 #Adding a Set with a description
126 'spec' => 'specSet2',
127 'name' => 'nameSet2',
128 'descriptions' => ['descSet2'],
130 my $set2_id = AddOAISet
($set2);
131 isa_ok
(\
$set2_id, 'SCALAR', '$set2_id is a SCALAR');
133 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
135 $setsCount = $sth->fetchrow_array;
136 is
($setsCount, 2, 'There is 2 sets');
138 $sth = $dbh->prepare("SELECT spec, name FROM oai_sets ORDER BY id DESC");
140 ($spec, $name) = $sth->fetchrow_array;
141 is
($spec, 'specSet2', 'spec field is "specSet2"');
142 is
($name, 'nameSet2', 'name field is "nameSet2"');
144 $sth = $dbh->prepare("SELECT description FROM oai_sets_descriptions");
146 $desc = $sth->fetchrow_array;
147 is
($desc, 'descSet2', 'description field is "descSet2"');
150 # ---------- Testing GetOAISets -----------------
151 my $oai_sets = GetOAISets
;
152 isa_ok
($oai_sets, 'ARRAY', '$oai_sets is an array reference of hash reference describing the sets');
154 isa_ok
($oai_sets->[0], 'HASH', '$set1 is defined as a hash');
155 is
($oai_sets->[0]->{spec
}, 'specSet1', 'spec field is "specSet1"');
156 is
($oai_sets->[0]->{name
}, 'nameSet1', 'name field is "nameSet1"');
158 isa_ok
($oai_sets->[1], 'HASH', '$set2 is defined as a hash');
159 is
($oai_sets->[1]->{spec
}, 'specSet2', 'spec field is "specSet2"');
160 is
($oai_sets->[1]->{name
}, 'nameSet2', 'name field is "nameSet2"');
161 is_deeply
($oai_sets->[1]->{descriptions
}, ['descSet2'], 'description field is "descSet2"');
163 ok
(!defined($oai_sets->[2]), 'There are only 2 sets');
166 # ---------- Testing GetOAISet ------------------
167 ok
(!defined(GetOAISet
), 'GetOAISet without argument is undef');
169 my $set = GetOAISet
($set1_id);
170 isa_ok
($set, 'HASH', '$set is a hash reference describing the set with the given set_id');
171 is
($set->{spec
}, 'specSet1', 'spec field is "specSet1"');
172 is
($set->{name
}, 'nameSet1', 'name field is "nameSet1"');
174 $set = GetOAISet
($set2_id);
175 isa_ok
($set, 'HASH', '$set is a hash reference describing the set with the given set_id');
176 is
($set->{spec
}, 'specSet2', 'spec field is "specSet2"');
177 is
($set->{name
}, 'nameSet2', 'name field is "nameSet2"');
178 is_deeply
($set->{descriptions
}, ['descSet2'], 'description field is "descSet2"');
181 # ---------- Testing GetOAISetBySpec ------------
182 ok
(!defined(GetOAISetBySpec
), 'GetOAISetBySpec without argument is undef');
184 $set = GetOAISetBySpec
($set1->{spec
});
185 isa_ok
($set, 'HASH', '$set is a hash describing the set whose spec is $oai_sets->[0]->{spec}');
186 is
($set->{spec
}, 'specSet1', 'spec field is "specSet1"');
187 is
($set->{name
}, 'nameSet1', 'name field is "nameSet1"');
189 $set = GetOAISetBySpec
($set2->{spec
});
190 isa_ok
($set, 'HASH', '$set is a hash describing the set whose spec is $oai_sets->[1]->{spec}');
191 is
($set->{spec
}, 'specSet2', 'spec field is "specSet2"');
192 is
($set->{name
}, 'nameSet2', 'name field is "nameSet2"');
193 #GetOAISetBySpec does't return the description field.
196 # ---------- Testing ModOAISet ------------------
197 ok
(!defined(ModOAISet
), 'ModOAISet without argument is undef');
199 my $new_set_without_id = {
200 'spec' => 'specNoName',
201 'name' => 'nameNoSpec',
202 'descriptions' => ['descNoSpecNoName'],
205 warning_is
{ $res = ModOAISet
($new_set_without_id) }
206 'Set ID not defined, can\'t modify the set',
207 'ModOAISet raises warning if Set ID is not defined';
208 ok
(!defined($res), 'ModOAISet returns undef if Set ID is not defined');
210 my $new_set_without_spec_and_name = {
212 'descriptions' => ['descNoSpecNoName'],
214 ok
(!defined(ModOAISet
($new_set_without_spec_and_name)), 'ModOAISet without "field" and "name" fields is undef');
216 my $new_set_without_spec = {
218 'name' => 'nameNoSpec',
219 'descriptions' => ['descNoSpec'],
221 ok
(!defined(ModOAISet
($new_set_without_spec)), 'ModOAISet without "field" field is undef');
223 my $new_set_without_name = {
225 'spec' => 'specNoName',
226 'descriptions' => ['descNoName'],
228 ok
(!defined(ModOAISet
($new_set_without_name)), 'ModOAISet without "name" field is undef');
232 'spec' => 'new_specSet1',
233 'name' => 'new_nameSet1',
234 'descriptions' => ['new_descSet1'],
236 ModOAISet
($new_set1);
240 'spec' => 'new_specSet2',
241 'name' => 'new_nameSet2',
243 ModOAISet
($new_set2);
245 $set1 = GetOAISet
($set1_id);
246 isa_ok
($set1, 'HASH', '$set1 is defined as a hash');
247 is
($set1->{spec
}, 'new_specSet1', 'spec field is "new_specSet1"');
248 is
($set1->{name
}, 'new_nameSet1', 'name field is "new_nameSet1"');
249 is_deeply
($set1->{descriptions
}, ['new_descSet1'], 'description field is "new_descSet1"');
251 $set2 = GetOAISet
($set2_id);
252 isa_ok
($set2, 'HASH', '$new_set2 is defined as a hash');
253 is
($set2->{spec
}, 'new_specSet2', 'spec field is "new_specSet2"');
254 is
($set2->{name
}, 'new_nameSet2', 'name field is "new_nameSet2"');
257 # ---------- Testing ModOAISetMappings ----------
258 ok
(!defined(ModOAISetMappings
), 'ModOAISetMappings without argument is undef');
259 #Add 1st mapping for set1
265 marcvalue
=> 'myMarcValue'
268 ModOAISetMappings
($set1_id, $mapping1);
270 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_mappings");
272 my $mappingsCount = $sth->fetchrow_array;
273 is
($mappingsCount, 1, 'There is 1 mapping');
275 $sth = $dbh->prepare("SELECT marcfield, marcsubfield, operator, marcvalue FROM oai_sets_mappings");
277 my ($marcfield, $marcsubfield, $operator, $marcvalue) = $sth->fetchrow_array;
278 is
($marcfield, '206', 'marcfield field is "206"');
279 is
($marcsubfield, 'a', 'marcsubfield field is "a"');
280 is
($operator, 'equal', 'operator field is "equal"');
281 is
($marcvalue, 'myMarcValue', 'marcvalue field is "myMarcValue"');
283 #Mod 1st mapping of set1
288 operator
=> 'notequal',
289 marcvalue
=> 'myMarcValueBis'
292 ModOAISetMappings
($set1_id, $mapping1_bis);
294 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_mappings");
296 $mappingsCount = $sth->fetchrow_array;
297 is
($mappingsCount, 1, 'There is 1 mapping');
299 $sth = $dbh->prepare("SELECT marcfield, marcsubfield, operator, marcvalue FROM oai_sets_mappings");
301 ($marcfield, $marcsubfield, $operator, $marcvalue) = $sth->fetchrow_array;
302 is
($marcfield, '256', 'marcfield field is "256"');
303 is
($marcsubfield, 'b', 'marcsubfield field is "b"');
304 is
($operator, 'notequal', 'operator field is "notequal"');
305 is
($marcvalue, 'myMarcValueBis', 'marcvalue field is "myMarcValueBis"');
307 #Add 1st mapping of set2
313 marcvalue
=> 'myOtherMarcValue'
316 ModOAISetMappings
($set2_id, $mapping2);
318 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_mappings");
320 $mappingsCount = $sth->fetchrow_array;
321 is
($mappingsCount, 2, 'There is 2 mappings');
323 $sth = $dbh->prepare("SELECT marcfield, marcsubfield, operator, marcvalue FROM oai_sets_mappings ORDER BY set_id DESC LIMIT 1");
325 ($marcfield, $marcsubfield, $operator, $marcvalue) = $sth->fetchrow_array;
326 is
($marcfield, '306', 'marcfield field is "306"');
327 is
($marcsubfield, 'c', 'marcsubfield field is "c"');
328 is
($operator, 'equal', 'operator field is "equal"');
329 is
($marcvalue, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
332 # ---------- Testing GetOAISetsMappings ---------
333 my $mappings = GetOAISetsMappings
;
335 isa_ok
($mappings, 'HASH', '$mappings is a hashref of arrayrefs of hashrefs');
336 isa_ok
($mappings->{$set1_id}, 'ARRAY', '$mappings->{$set1_id} is a arrayrefs of hashrefs');
337 isa_ok
($mappings->{$set1_id}->[0], 'HASH', '$mappings->{$set1_id}->[0] is a hashrefs');
338 is
($mappings->{$set1_id}->[0]->{marcfield
}, '256', 'marcfield field is "256"');
339 is
($mappings->{$set1_id}->[0]->{marcsubfield
}, 'b', 'marcsubfield field is "b"');
340 is
($mappings->{$set1_id}->[0]->{operator
}, 'notequal', 'operator field is "notequal"');
341 is
($mappings->{$set1_id}->[0]->{marcvalue
}, 'myMarcValueBis', 'marcvalue field is "myMarcValueBis"');
343 isa_ok
($mappings->{$set2_id}, 'ARRAY', '$mappings->{$set2_id} is a arrayrefs of hashrefs');
344 isa_ok
($mappings->{$set2_id}, 'ARRAY', '$mappings->{$set2_id} is a arrayrefs of hashrefs');
345 isa_ok
($mappings->{$set2_id}->[0], 'HASH', '$mappings->{$set2_id}->[0] is a hashrefs');
346 is
($mappings->{$set2_id}->[0]->{marcfield
}, '306', 'marcfield field is "306"');
347 is
($mappings->{$set2_id}->[0]->{marcsubfield
}, 'c', 'marcsubfield field is "c"');
348 is
($mappings->{$set2_id}->[0]->{operator
}, 'equal', 'operator field is "equal"');
349 is
($mappings->{$set2_id}->[0]->{marcvalue
}, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
352 # ---------- Testing GetOAISetMappings ----------
353 ok
(!defined(GetOAISetMappings
), 'GetOAISetMappings without argument is undef');
355 my $set_mappings1 = GetOAISetMappings
($set1_id);
356 isa_ok
($set_mappings1->[0], 'HASH', '$set_mappings1->[0] is a hashref');
357 is
($set_mappings1->[0]->{marcfield
}, '256', 'marcfield field is "256"');
358 is
($set_mappings1->[0]->{marcsubfield
}, 'b', 'marcsubfield field is "b"');
359 is
($set_mappings1->[0]->{operator
}, 'notequal', 'operator field is "notequal"');
360 is
($set_mappings1->[0]->{marcvalue
}, 'myMarcValueBis', 'marcvalue field is "myMarcValueBis"');
362 my $set_mappings2 = GetOAISetMappings
($set2_id);
363 isa_ok
($mappings->{$set2_id}->[0], 'HASH', '$mappings->{$set2_id}->[0] is a hashref');
364 is
($mappings->{$set2_id}->[0]->{marcfield
}, '306', 'marcfield field is "306"');
365 is
($mappings->{$set2_id}->[0]->{marcsubfield
}, 'c', 'marcsubfield field is "c"');
366 is
($mappings->{$set2_id}->[0]->{operator
}, 'equal', 'operator field is "equal"');
367 is
($mappings->{$set2_id}->[0]->{marcvalue
}, 'myOtherMarcValue', 'marcvalue field is "myOtherMarcValue"');
370 # ---------- Testing AddOAISetsBiblios ----------
371 ok
(!defined(AddOAISetsBiblios
), 'AddOAISetsBiblios without argument is undef');
372 ok
(!defined(AddOAISetsBiblios
(my $arg=[])), 'AddOAISetsBiblios with a no HASH argument is undef');
373 ok
(defined(AddOAISetsBiblios
($arg={})), 'AddOAISetsBiblios with a HASH argument is def');
375 # Create a biblio instance for testing
376 my $biblionumber1 = create_helper_biblio
('Moffat, Steven');
377 isa_ok
(\
$biblionumber1, 'SCALAR', '$biblionumber1 is a SCALAR');
378 my $biblionumber2 = create_helper_biblio
('Moffat, Steven');
379 isa_ok
(\
$biblionumber2, 'SCALAR', '$biblionumber2 is a SCALAR');
381 my $oai_sets_biblios = {
382 $set1_id => [$biblionumber1, $biblionumber2], # key is the set_id, and value is an array ref of biblionumbers
385 AddOAISetsBiblios
($oai_sets_biblios);
387 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_biblios");
389 my $bibliosCount = $sth->fetchrow_array;
390 is
($bibliosCount, 2, 'There are 2 biblios in oai_sets_biblios');
392 #testing biblio for set1_id
393 $sth = $dbh->prepare("SELECT * FROM oai_sets_biblios WHERE set_id = ?");
394 $sth->execute($set1_id);
395 my $count = $sth->rows;
396 is
($count, '2', '$set_id1 has 2 biblio');
398 $sth->execute($set1_id);
399 my $line = ${ $sth->fetchall_arrayref( {} ) }[0];
400 is
($line->{set_id
}, $set1_id, "set_id is good");
401 is
($line->{biblionumber
}, $biblionumber1, "biblionumber is good");
403 $sth->execute($set1_id);
404 $line = ${ $sth->fetchall_arrayref( {} ) }[1];
405 is
($line->{set_id
}, $set1_id, "set_id is good");
406 is
($line->{biblionumber
}, $biblionumber2, "biblionumber is good");
408 #testing biblio for set2_id
409 $sth->execute($set2_id);
411 is
($count, '0', '$set_id2 has 0 biblio');
414 # ---------- Testing GetOAISetsBiblio -----------
415 $oai_sets = GetOAISetsBiblio
($biblionumber1);
416 isa_ok
($oai_sets, 'ARRAY', '$oai_sets is an arrayref of hashref where each element of the array is a set');
417 isa_ok
($oai_sets->[0], 'HASH', '$oai_sets->[0] is a hashrefs of $set1_id');
418 is
($oai_sets->[0]->{id
}, $set1_id, 'id is $set1_id');
419 is
($oai_sets->[0]->{spec
}, $set1->{spec
}, 'spec is new_specset1');
420 is
($oai_sets->[0]->{name
}, $set1->{name
}, 'name is new_specname1');
422 $oai_sets = GetOAISetsBiblio
($biblionumber2);
423 isa_ok
($oai_sets, 'ARRAY', '$oai_sets is an arrayref of hashref where each element of the array is a set');
424 isa_ok
($oai_sets->[0], 'HASH', '$oai_sets->[0] is a hashrefs of $set2_id');
425 is
($oai_sets->[0]->{id
}, $set1_id, 'id is $set1_id');
426 is
($oai_sets->[0]->{spec
}, $set1->{spec
}, 'spec is new_specset1');
427 is
($oai_sets->[0]->{name
}, $set1->{name
}, 'name is new_specname1');
430 # ---------- Testing ModOAISetsBiblios ----------
431 ok
(!defined(ModOAISetsBiblios
), 'ModOAISetsBiblios without argument is undef');
432 ok
(!defined(ModOAISetsBiblios
($arg=[])), 'ModOAISetsBiblios with a no HASH argument is undef');
433 ok
(defined(ModOAISetsBiblios
($arg={})), 'ModOAISetsBiblios with a HASH argument is def');
435 $oai_sets_biblios = {
436 $set1_id => [$biblionumber1],
437 $set2_id => [$biblionumber2],
439 ModOAISetsBiblios
($oai_sets_biblios);
441 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets_biblios");
443 $bibliosCount = $sth->fetchrow_array;
444 is
($bibliosCount, 2, 'There are 2 biblios in oai_sets_biblios');
446 #testing biblio for set1_id
447 $sth = $dbh->prepare("SELECT * FROM oai_sets_biblios WHERE set_id = ?");
448 $sth->execute($set1_id);
450 is
($count, '1', '$set_id1 has 2 biblio');
452 $sth->execute($set1_id);
453 $line = ${ $sth->fetchall_arrayref( {} ) }[0];
454 is
($line->{set_id
}, $set1_id, "set_id is good");
455 is
($line->{biblionumber
}, $biblionumber1, "biblionumber is good");
457 #testing biblio for set2_id
458 $sth->execute($set2_id);
460 is
($count, '1', '$set_id2 has 1 biblio');
462 $sth->execute($set2_id);
463 $line = ${ $sth->fetchall_arrayref( {} ) }[0];
464 is
($line->{set_id
}, $set2_id, "set_id is good");
465 is
($line->{biblionumber
}, $biblionumber2, "biblionumber is good");
468 # ---------- Testing DelOAISetsBiblio -----------
469 ok
(!defined(DelOAISetsBiblio
), 'DelOAISetsBiblio without argument is undef');
471 DelOAISetsBiblio
($biblionumber1);
472 is_deeply
(GetOAISetsBiblio
($biblionumber1), [], "no biblio1 appear in any OAI sets");
474 DelOAISetsBiblio
($biblionumber2);
475 is_deeply
(GetOAISetsBiblio
($biblionumber2), [], "no biblio2 appear in any OAI sets");
478 # ---------- Testing DelOAISet ------------------
479 ok
(!defined(DelOAISet
), 'DelOAISet without argument is undef');
482 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
484 $setsCount = $sth->fetchrow_array;
485 is
($setsCount, 1, 'There is 1 set left');
486 $set1 = GetOAISet
($set1_id);
487 is_deeply
($set1, {}, '$set1 is empty');
490 $sth = $dbh->prepare("SELECT count(*) FROM oai_sets");
492 $setsCount = $sth->fetchrow_array;
493 is
($setsCount, 0, 'There is no set anymore');
494 $set2 = GetOAISet
($set2_id);
495 is_deeply
($set2, {}, '$set2 is empty');
497 $oai_sets=GetOAISets
;
498 is_deeply
($oai_sets, [], '$oai_sets is empty');
501 # ---------- Testing UpdateOAISetsBiblio --------
502 ok
(!defined(UpdateOAISetsBiblio
), 'UpdateOAISetsBiblio without argument is undef');
503 ok
(!defined(UpdateOAISetsBiblio
($arg)), 'UpdateOAISetsBiblio with only 1 argument is undef');
507 'spec' => 'Set where Author is Victor Hugo',
510 my $setVH_id = AddOAISet
($setVH);
512 #Create mappings : 'author' should be 'Victor Hugo'
513 my $marcflavour = C4
::Context
->preference('marcflavour');
516 if ($marcflavour eq 'UNIMARC' ){
522 marcvalue
=> 'Victor Hugo'
532 marcvalue
=> 'Victor Hugo'
536 ModOAISetMappings
($setVH_id, $mappingsVH);
539 #Create a biblio notice corresponding at one of mappings
540 my $biblionumberVH = create_helper_biblio
('Victor Hugo');
543 my $record = GetMarcBiblio
($biblionumberVH);
544 UpdateOAISetsBiblio
($biblionumberVH, $record);
546 #is biblio attached to setVH ?
547 my $oai_setsVH = GetOAISetsBiblio
($biblionumberVH);
548 is
($oai_setsVH->[0]->{id
}, $setVH_id, 'id is ok');
549 is
($oai_setsVH->[0]->{spec
}, $setVH->{spec
}, 'id is ok');
550 is
($oai_setsVH->[0]->{name
}, $setVH->{name
}, 'id is ok');
553 # ---------- Testing CalcOAISetsBiblio ----------
554 ok
(!defined(CalcOAISetsBiblio
), 'CalcOAISetsBiblio without argument is undef');
556 my @setsEq = CalcOAISetsBiblio
($record);
557 is_deeply
(@setsEq, $setVH_id, 'The $record only belongs to $setVH');
559 #Testing CalcOAISetsBiblio for a mapping which operator is 'notequal'
562 'spec' => 'Set where Author is NOT Victor Hugo',
565 my $setNotVH_id = AddOAISet
($setNotVH);
567 #Create mappings : 'author' should NOT be 'Victor Hugo'
568 $marcflavour = C4
::Context
->preference('marcflavour');
571 if ($marcflavour eq 'UNIMARC' ){
576 operator
=> 'notequal',
577 marcvalue
=> 'Victor Hugo'
586 operator
=> 'notequal',
587 marcvalue
=> 'Victor Hugo'
591 ModOAISetMappings
($setNotVH_id, $mappingsNotVH);
594 #Create a biblio notice corresponding at one of mappings
595 my $biblionumberNotVH = create_helper_biblio
('Sponge, Bob');
598 $record = GetMarcBiblio
($biblionumberNotVH);
599 UpdateOAISetsBiblio
($biblionumberNotVH, $record);
601 my @setsNotEq = CalcOAISetsBiblio
($record);
602 is_deeply
(@setsNotEq, $setNotVH_id, 'The $record only belongs to $setNotVH');
606 # ---------- Subs --------------------------------
609 # Helper method to set up a Biblio.
610 sub create_helper_biblio
{
613 return unless (defined($author));
615 my $marcflavour = C4
::Context
->preference('marcflavour');
616 my $bib = MARC
::Record
->new();
617 my $title = 'Silence in the library';
619 if ($marcflavour eq 'UNIMARC' ){
621 MARC
::Field
->new('200', ' ', ' ', f
=> $author),
622 MARC
::Field
->new('200', ' ', ' ', a
=> $title),
627 MARC
::Field
->new('100', ' ', ' ', a
=> $author),
628 MARC
::Field
->new('245', ' ', ' ', a
=> $title),
631 my ($biblionumber)= AddBiblio
($bib, '');
632 return $biblionumber;