Bug 17909: Adding tests from bug 11315
Based on original patch from Maxime Beaulieu on bug 11315.
Amended by Marcel de Rooy on report 17909.
EDIT:
Original tests have been adjusted in view of:
[1] Test on bug 11315 heavily leaned on DBD::Mock. Since we are
using Test::DBIx::Class on such tests now, this would need attention.
Moreover, the advantage of mocking the database in this case is at
least arguable.
[2] Matching the first (somewhat older) subtest of 11700.
[3] Simplification and readability.
Look e.g. at the use of $MARCto and $MARCfrom on 11315.
This made me merge them in the db_dependent counterpart.
Also note that this subtest adds another needed test case: the merge from
auth1 to modified auth1, while 11700 tested auth1 to auth2.
Test plan:
Just run t/db_dependent/Authorities/Merge.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Mason James <mtj@kohaaloha.com>
This commit is contained in:
parent
1fb7d9a869
commit
7859ea37b2
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 2;
|
||||
use Test::More tests => 3;
|
||||
|
||||
use MARC::Record;
|
||||
use Test::MockModule;
|
||||
|
|
@ -77,6 +77,46 @@ subtest 'Test merge A1 to A2 (withing same authtype)' => sub {
|
|||
'Check biblio2 609$a' );
|
||||
};
|
||||
|
||||
subtest 'Test merge A1 to modified A1' => sub {
|
||||
# Tests originate from bug 11700
|
||||
plan tests => 4;
|
||||
|
||||
$dbh->do("INSERT IGNORE INTO marc_subfield_structure(tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES('109', 'a', 'Personal name', 'Personal name', 0, 0, '', 6, '', 'TEST_PERSO', '', NULL, 0, '', '', '', NULL)");
|
||||
$dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'TEST_PERSO' WHERE tagfield='109' AND tagsubfield='a' AND frameworkcode='';");
|
||||
|
||||
my $auth1old = MARC::Record->new;
|
||||
$auth1old->append_fields( MARC::Field->new( '109', '0', '0', 'a' => 'Bruce Wayne' ));
|
||||
my $auth1new = $auth1old->clone;
|
||||
$auth1new->field('109')->update( a => 'Batman' );
|
||||
my $authid1 = AddAuthority( $auth1new, undef, 'TEST_PERSO' );
|
||||
|
||||
my $MARC1 = MARC::Record->new();
|
||||
$MARC1->append_fields( MARC::Field->new( '245', '', '', 'a' => 'From the depths' ));
|
||||
$MARC1->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Bruce Wayne', 'b' => '2014', '9' => $authid1 ));
|
||||
my $MARC2 = MARC::Record->new();
|
||||
$MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' ));
|
||||
$MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 ));
|
||||
my ( $biblionumber1 ) = AddBiblio( $MARC1, '');
|
||||
my ( $biblionumber2 ) = AddBiblio( $MARC2, '');
|
||||
|
||||
@zebrarecords = ( $MARC1, $MARC2 );
|
||||
$index = 0;
|
||||
|
||||
my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new );
|
||||
is( $rv, 2, 'Both records are updated now' );
|
||||
|
||||
my $biblio1 = GetMarcBiblio($biblionumber1);
|
||||
my $biblio2 = GetMarcBiblio($biblionumber1);
|
||||
|
||||
my $auth_field = $auth1new->field(109)->subfield('a');
|
||||
is( $auth_field, $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' );
|
||||
is( $auth_field, $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' );
|
||||
|
||||
# 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');
|
||||
};
|
||||
|
||||
sub set_mocks {
|
||||
# Mock ZOOM objects: They do nothing actually
|
||||
# Get new_record_from_zebra to return the records
|
||||
|
|
|
|||
Loading…
Reference in New Issue