Koha/t/db_dependent/Koha_Authority.t
Jared Camins-Esakov b5bd2b7586 Bug 5202: merge authorities from the authority file and reservoir
This patch gives Koha the ability to merge authority records using the
same interface used by bibliographic records, though slightly different
methods for selecting which records to merge. The two ways to select
records are as follows:

1) Records can be selected from authority search results by clicking
   the "Merge" link for two records.
2) Authority records can be merged from the reservoir by clicking the
   merge-related links in the Manage staged MARC batch screen.

To test:
1) Apply patch.
2) Do a search for an authority record that will turn up multiple
   identical records (or at least two records that you don't mind
   merging).
3) Click the "Merge" link for the first record.
4) Click the "Merge" link for the second record.
5) Choose which fields from which record you want to appear in the
   resulting record.
6) Confirm that those are the fields that exist in the resulting record.
7) Stage an authority record (for example, an authority record you
   saved from your catalog.
8) Search for a record to merge with it using the "Search for a record
   to merge in a new window" link.
9) Merge these records, confirming that the resulting record (after
   going through the entire merging process) matches your expectations.
10) Set up a matching rule for authorities, and export an authority from
    your catalog that will match based on that rule. For MARC21, the
    following is a good choice for a rule:
    Matching rule code:  AUTHPER
    Description:         Personal name main entry
    Match threshold:     999
    Record type:         Authority record
    [Match point 1:]
    Search index:   mainmainentry
    Score:          1000
    Tag:            100
    Subfields:      a
11) Stage the record you just exported, choosing the matching rule you
    just created.
12) Merge the record using the "Merge" link, confirming that the
    resulting record (after going through the entire merging process)
    matches your expectations.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Testing notes on last patch in series.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-10-10 21:32:27 +00:00

92 lines
2.8 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2012 C & P Bibliography Services
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use C4::Context;
use Test::More;
BEGIN {
use_ok('Koha::Authority');
}
my $record = MARC::Record->new;
$record->add_fields(
[ '001', '1234' ],
[ '150', ' ', ' ', a => 'Cooking' ],
[ '450', ' ', ' ', a => 'Cookery' ],
);
my $authority = Koha::Authority->new($record);
is(ref($authority), 'Koha::Authority', 'Created valid Koha::Authority object');
is($authority->authorized_heading(), 'Cooking', 'Authorized heading was correct');
is_deeply($authority->record, $record, 'Saved record');
SKIP:
{
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT authid FROM auth_header LIMIT 1;");
$sth->execute();
my $authid;
for my $row ($sth->fetchrow_hashref) {
$authid = $row->{'authid'};
}
skip 'No authorities', 3 unless $authid;
$authority = Koha::Authority->get_from_authid($authid);
is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
is($authority->authid, $authid, 'Object authid is correct');
is($authority->record->field('001')->data(), $authid, 'Retrieved correct record');
$authority = Koha::Authority->get_from_authid('alphabetsoup');
is($authority, undef, 'No invalid record is retrieved');
}
SKIP:
{
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT import_record_id FROM import_records WHERE record_type = 'auth' LIMIT 1;");
$sth->execute();
my $import_record_id;
for my $row ($sth->fetchrow_hashref) {
$import_record_id = $row->{'import_record_id'};
}
skip 'No authorities in reservoir', 3 unless $import_record_id;
$authority = Koha::Authority->get_from_breeding($import_record_id);
is(ref($authority), 'Koha::Authority', 'Retrieved valid Koha::Authority object');
is($authority->authid, undef, 'Records in reservoir do not have an authid');
is(ref($authority->record), 'MARC::Record', 'MARC record attached to authority');
$authority = Koha::Authority->get_from_breeding('alphabetsoup');
is($authority, undef, 'No invalid record is retrieved from reservoir');
}
done_testing();