Bug 27577: Unit test

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2021-05-05 18:20:05 +00:00 committed by Jonathan Druart
parent 640ba470cf
commit 9fab281e54
1 changed files with 14 additions and 1 deletions

View File

@ -44,7 +44,7 @@ Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
my $builder = t::lib::TestBuilder->new;
subtest 'AddBiblio' => sub {
plan tests => 4;
plan tests => 5;
my $marcflavour = 'MARC21';
t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour );
@ -67,6 +67,19 @@ subtest 'AddBiblio' => sub {
);
is( Koha::Biblios->count, $nb_biblios,
'No biblio should have been added if something went wrong' );
t::lib::Mocks::mock_preference( 'BiblioAddsAuthorities', $marcflavour );
t::lib::Mocks::mock_preference( 'AutoCreateAuthorities', $marcflavour );
my $mock_biblio = Test::MockModule->new("C4::Biblio");
$mock_biblio->mock( BiblioAutoLink => sub {
my $record = shift;
my $frameworkcode = shift;
warn "My biblionumber is ".$record->subfield('999','c')." and my frameworkcode is $frameworkcode";
});
warning_like { $builder->build_sample_biblio(); }
qr/My biblionumber is \d+ and my frameworkcode is /, "The biblionumber is correctly passed to BiblioAutoLink";
};
subtest 'GetMarcSubfieldStructureFromKohaField' => sub {