View | Details | Raw Unified | Return to bug 17913
Collapse All | Expand All

(-)a/t/db_dependent/Authorities/Merge.t (-5 / +14 lines)
Lines 10-15 use MARC::Record; Link Here
10
use Test::MockModule;
10
use Test::MockModule;
11
use Test::MockObject;
11
use Test::MockObject;
12
12
13
use t::lib::Mocks;
13
use t::lib::TestBuilder;
14
use t::lib::TestBuilder;
14
15
15
use C4::Biblio;
16
use C4::Biblio;
Lines 81-87 subtest 'Test merge A1 to A2 (withing same authtype)' => sub { Link Here
81
82
82
subtest 'Test merge A1 to modified A1' => sub {
83
subtest 'Test merge A1 to modified A1' => sub {
83
# Tests originate from bug 11700
84
# Tests originate from bug 11700
84
    plan tests => 8;
85
    plan tests => 9;
85
86
86
    # Simulate modifying an authority from auth1old to auth1new
87
    # Simulate modifying an authority from auth1old to auth1new
87
    my $auth1old = MARC::Record->new;
88
    my $auth1old = MARC::Record->new;
Lines 103-108 subtest 'Test merge A1 to modified A1' => sub { Link Here
103
    # Time to merge
104
    # Time to merge
104
    @zebrarecords = ( $MARC1, $MARC2 );
105
    @zebrarecords = ( $MARC1, $MARC2 );
105
    $index = 0;
106
    $index = 0;
107
    t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose');
106
    my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new );
108
    my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new );
107
    is( $rv, 2, 'Both records are updated now' );
109
    is( $rv, 2, 'Both records are updated now' );
108
110
Lines 115-124 subtest 'Test merge A1 to modified A1' => sub { Link Here
115
    compare_field_count( $MARC2, $biblio2, 1 );
117
    compare_field_count( $MARC2, $biblio2, 1 );
116
    compare_field_order( $MARC2, $biblio2, 1 );
118
    compare_field_order( $MARC2, $biblio2, 1 );
117
    is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' );
119
    is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' );
120
    # This is only true in loose mode:
121
    is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Subfield not overwritten in loose mode');
118
122
119
    # TODO Following test will change when we improve merge
123
    # Merge again in strict mode
120
    # Will depend on a preference
124
    t::lib::Mocks::mock_preference('AuthorityMergeMode', 'strict');
121
    is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Record not overwritten while merging');
125
    ModBiblio( $MARC1, $biblionumber1, '' );
126
    @zebrarecords = ( $MARC1 );
127
    $index = 0;
128
    $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new );
129
    $biblio1 = GetMarcBiblio($biblionumber1);
130
    is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' );
131
    t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose');
122
};
132
};
123
133
124
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
134
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
125
- 

Return to bug 17913