11 subtest
"_koha_marc_update_bib_ids basic Field", \
&_koha_marc_update_bib_ids_simple
;
12 sub _koha_marc_update_bib_ids_simple
{
13 my $module = Test
::MockModule
->new('C4::Biblio');
14 $module->mock('GetMarcFromKohaField', sub {
16 return ('999','c') if $source eq 'biblio.biblionumber';
17 return ('999','d') if $source eq 'biblioitems.biblioitemnumber';
21 my $r = MARC
::Record
->new();
22 C4
::Biblio
::_koha_marc_update_bib_ids
($r, undef, 10, 20);
23 is
($r->subfield('999', 'c'), 10, 'Biblionumber');
24 is
($r->subfield('999', 'd'), 20, 'Biblioitemnumber');
26 C4
::Biblio
::_koha_marc_update_bib_ids
($r, undef, 10, 20);
27 my @f = $r->field('999');
28 is
(scalar(@f), 1, 'Field not duplicated');
29 is
($r->subfield('999', 'c'), 10, 'Biblionumber');
30 is
($r->subfield('999', 'd'), 20, 'Biblioitemnumber');
33 subtest
"_koha_marc_update_bib_ids ControlField", \
&_koha_marc_update_bib_ids_control
;
34 sub _koha_marc_update_bib_ids_control
{
35 my $module = Test
::MockModule
->new('C4::Biblio');
36 $module->mock('GetMarcFromKohaField', sub {
38 return ('001',undef) if $source eq 'biblio.biblionumber';
39 return ('004',undef) if $source eq 'biblioitems.biblioitemnumber';
43 my $r = MARC
::Record
->new();
44 C4
::Biblio
::_koha_marc_update_bib_ids
($r, undef, 10, 20);
45 is
($r->field('001')->data(), 10, 'Biblionumber to control field');
46 is
($r->field('004')->data(), 20, 'Biblioitemnumber to control field');
48 C4
::Biblio
::_koha_marc_update_bib_ids
($r, undef, 10, 20);
49 my @f = $r->field('001');
50 is
(scalar(@f), 1, 'Control field not duplicated');
51 is
($r->field('001')->data(), 10, 'Biblionumber to control field');
52 is
($r->field('004')->data(), 20, 'Biblioitemnumber to control field');