From a0573988aebe627023339cfe8f5d6ca825cee00c Mon Sep 17 00:00:00 2001 From: Laura Escamilla Date: Tue, 2 Apr 2024 13:43:00 +0000 Subject: [PATCH] Bug 36473: Unit tests Content-Type: text/plain; charset=utf-8 Signed-off-by: Marcel de Rooy [EDIT] Tidied. --- t/db_dependent/Biblio.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 4f096f7fe1..c2cdd30e7a 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 20; +use Test::More tests => 21; use Test::MockModule; use Test::Warn; use List::MoreUtils qw( uniq ); @@ -1022,6 +1022,27 @@ subtest 'ModBiblio on invalid record' => sub { ); }; +subtest 'UpdateTotalIssues on Invalid record' => sub { + plan tests => 2; + + my $return_record = Test::MockModule->new('Koha::Biblio::Metadata'); + $return_record->mock( 'record', sub { Koha::Exceptions::Metadata::Invalid->throw() } ); + + my $biblio = $builder->build_sample_biblio; + + my $increase = 1; + + my $success; + warning_is { + $success = C4::Biblio::UpdateTotalIssues( $biblio->biblionumber, $increase, '' ); + } + "UpdateTotalIssues could not get biblio record", "Expected warning found"; + + ok( !$success, 'UpdateTotalIssues fails gracefully for invalid record' ); + +}; + + # Cleanup Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); $schema->storage->txn_rollback; -- 2.30.2