Koha/t/Biblio2.t
Jonathan Druart f1f9c6dc74 Bug 26384: Fix executable flags
.pm must not have -x
.t must have -x
.pl must have -x

Test plan:
Apply only the first patch, run the tests and confirm that the failures
make sense
Apply this patch and confirm that the test now returns green

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-11 09:56:56 +02:00

55 lines
1.9 KiB
Perl
Executable file

#!/usr/bin/perl
use Modern::Perl;
use Test::More;
use Test::MockModule;
use MARC::Record;
use C4::Biblio;
subtest "_koha_marc_update_bib_ids basic Field", \&_koha_marc_update_bib_ids_simple;
sub _koha_marc_update_bib_ids_simple {
my $module = Test::MockModule->new('C4::Biblio');
$module->mock('GetMarcFromKohaField', sub {
my ($source) = @_;
return ('999','c') if $source eq 'biblio.biblionumber';
return ('999','d') if $source eq 'biblioitems.biblioitemnumber';
}
);
my $r = MARC::Record->new();
C4::Biblio::_koha_marc_update_bib_ids($r, undef, 10, 20);
is($r->subfield('999', 'c'), 10, 'Biblionumber');
is($r->subfield('999', 'd'), 20, 'Biblioitemnumber');
C4::Biblio::_koha_marc_update_bib_ids($r, undef, 10, 20);
my @f = $r->field('999');
is(scalar(@f), 1, 'Field not duplicated');
is($r->subfield('999', 'c'), 10, 'Biblionumber');
is($r->subfield('999', 'd'), 20, 'Biblioitemnumber');
}
subtest "_koha_marc_update_bib_ids ControlField", \&_koha_marc_update_bib_ids_control;
sub _koha_marc_update_bib_ids_control {
my $module = Test::MockModule->new('C4::Biblio');
$module->mock('GetMarcFromKohaField', sub {
my ($source) = @_;
return ('001',undef) if $source eq 'biblio.biblionumber';
return ('004',undef) if $source eq 'biblioitems.biblioitemnumber';
}
);
my $r = MARC::Record->new();
C4::Biblio::_koha_marc_update_bib_ids($r, undef, 10, 20);
is($r->field('001')->data(), 10, 'Biblionumber to control field');
is($r->field('004')->data(), 20, 'Biblioitemnumber to control field');
C4::Biblio::_koha_marc_update_bib_ids($r, undef, 10, 20);
my @f = $r->field('001');
is(scalar(@f), 1, 'Control field not duplicated');
is($r->field('001')->data(), 10, 'Biblionumber to control field');
is($r->field('004')->data(), 20, 'Biblioitemnumber to control field');
}
done_testing();