From ff0da796f4ae228ec76b052fad38fa8a511e98ea Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Tue, 6 Jun 2023 17:42:42 +0000 Subject: [PATCH] Bug 29522 - Adding unit Test --- t/AuthoritiesMarc_MARC21.t | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/t/AuthoritiesMarc_MARC21.t b/t/AuthoritiesMarc_MARC21.t index 4ed2e1dfb3..f640affbdd 100755 --- a/t/AuthoritiesMarc_MARC21.t +++ b/t/AuthoritiesMarc_MARC21.t @@ -8,11 +8,11 @@ use warnings; use Test::MockModule; use Test::MockObject; -use Test::More tests => 5; +use Test::More tests => 6; use t::lib::Mocks; use MARC::Record; -use C4::AuthoritiesMarc qw( FindDuplicateAuthority ); +use C4::AuthoritiesMarc qw( FindDuplicateAuthority isAuthorityDuplicated ); BEGIN { use_ok('C4::AuthoritiesMarc::MARC21', qw( default_auth_type_location fix_marc21_auth_type_location )); @@ -60,3 +60,27 @@ subtest "FindDuplicateAuthority tests" => sub { is( $query, q{at:"GENRE/FORM" AND he:"Potato"}, "Query formed correctly for Elasticsearch"); }; + +subtest "isAuthorityDuplicated tests" => sub { + plan tests => 2; + my $record1 = MARC::Record->new; + $record1->append_fields( + MARC::Field->new('110', '', '', a => 'Potato' ), + ); + + my $record2 = MARC::Record->new; + $record2->append_fields( + MARC::Field->new('110', '', '', a => 'Potato' ), + ); + + my $duplicate = isAuthorityDuplicated( $record1, $record2, "CORPO_NAME" ); + is( $duplicate, 1 ); + + $record2->delete_fields($record2->field('110')); + $record2->append_fields( + MARC::Field->new('110', '', '', a => 'Newvalue' ), + ); + + $duplicate = isAuthorityDuplicated( $record1, $record2, "CORPO_NAME" ); + is( $duplicate, 0 ); +}; -- 2.34.1