From c8aa806042ee44af252f584c77b185a9e07df8d5 Mon Sep 17 00:00:00 2001 From: mbeaulieu Date: Mon, 18 Aug 2014 10:04:55 -0400 Subject: [PATCH] [SIGNED-OFF] Bug 17913: Adjust merge test for AuthorityMergeMode Original fix from a patch on bug 11315. Amended by Marcel de Rooy January 2017. Test plan: Run t/db_dependent/Authorities/Merge.t in both loose and strict mode. Should no longer make a difference. Signed-off-by: Marcel de Rooy Signed-off-by: Josef Moravec --- t/db_dependent/Authorities/Merge.t | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t index 55470cc..8d1d106 100755 --- a/t/db_dependent/Authorities/Merge.t +++ b/t/db_dependent/Authorities/Merge.t @@ -10,6 +10,7 @@ use MARC::Record; use Test::MockModule; use Test::MockObject; +use t::lib::Mocks; use t::lib::TestBuilder; use C4::Biblio; @@ -81,7 +82,7 @@ subtest 'Test merge A1 to A2 (within same authtype)' => sub { subtest 'Test merge A1 to modified A1' => sub { # Tests originate from bug 11700 - plan tests => 8; + plan tests => 9; # Simulate modifying an authority from auth1old to auth1new my $auth1old = MARC::Record->new; @@ -103,6 +104,7 @@ subtest 'Test merge A1 to modified A1' => sub { # Time to merge @zebrarecords = ( $MARC1, $MARC2 ); $index = 0; + t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new ); is( $rv, 2, 'Both records are updated now' ); @@ -115,10 +117,18 @@ subtest 'Test merge A1 to modified A1' => sub { compare_field_count( $MARC2, $biblio2, 1 ); compare_field_order( $MARC2, $biblio2, 1 ); is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' ); + # This is only true in loose mode: + is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Subfield not overwritten in loose mode'); - # TODO Following test will change when we improve merge - # Will depend on a preference - is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Record not overwritten while merging'); + # Merge again in strict mode + t::lib::Mocks::mock_preference('AuthorityMergeMode', 'strict'); + ModBiblio( $MARC1, $biblionumber1, '' ); + @zebrarecords = ( $MARC1 ); + $index = 0; + $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new ); + $biblio1 = GetMarcBiblio($biblionumber1); + is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' ); + t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); }; subtest 'Test merge A1 to B1 (changing authtype)' => sub { -- 2.1.4