From 3d6ab09eae95c4d68de5d583ab69301df8495650 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 11 Aug 2020 09:32:10 -0300 Subject: [PATCH] Bug 25313: (QA follow-up) DelAuthority tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/AuthoritiesMarc.t | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t index 384a905298..ea9740e236 100755 --- a/t/db_dependent/AuthoritiesMarc.t +++ b/t/db_dependent/AuthoritiesMarc.t @@ -5,7 +5,7 @@ use Modern::Perl; -use Test::More tests => 10; +use Test::More tests => 11; use Test::MockModule; use Test::Warn; use MARC::Record; @@ -248,3 +248,36 @@ subtest 'ModAuthority() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'DelAuthority() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $auth_type = 'GEOGR_NAME'; + my $record = MARC::Record->new; + $record->add_fields( + [ '001', '1' ], + [ '151', ' ', ' ', a => 'United States' ] + ); +; + my $auth_id = AddAuthority( $record, undef, $auth_type ); + + my $mocked_authorities_marc = Test::MockModule->new('C4::AuthoritiesMarc'); + $mocked_authorities_marc->mock( 'merge', sub { warn 'merge called'; } ); + + warning_is + { DelAuthority({ authid => $auth_id }); } + 'merge called', + 'No param, merge called'; + + $auth_id = AddAuthority( $record, undef, $auth_type ); + + warning_is + { DelAuthority({ authid => $auth_id, skip_merge => 1 }); } + undef, + 'skip_merge passed, merge not called'; + + $schema->storage->txn_rollback; +}; -- 2.28.0