3 # This Koha test module is a stub!
4 # Add more tests here!!!
8 use Test
::More tests
=> 3;
13 use C4
::Linker
::FirstMatch
;
19 my $dbh = C4
::Context
->dbh;
21 my $query = "SELECT authid, marc FROM auth_header LIMIT 1;";
22 my $sth = $dbh->prepare($query);
24 my ($authid, $marc) = $sth->fetchrow_array();
26 skip
"No authorities", 2 unless defined $authid;
27 my $linker = C4
::Linker
::FirstMatch
->new();
28 my $auth = MARC
::Record
->new_from_usmarc($marc);
30 if (C4
::Context
->preference('MARCFlavour') eq 'UNIMARC') {
35 my $bibfield = $auth->field($fieldmatch);
36 my $tag = $bibfield->tag();
38 $bibfield->update(tag
=> $tag);
40 ok
(defined ($heading = C4
::Heading
->new_from_bib_field($bibfield, '')), "Creating heading from bib field");
42 # If Zebra is not running, or authorities have not been indexed, test 3
43 # will fail. Skip it if we are unable to retrieve a list of headings from
45 my @authids = $heading->authorities(1);
46 skip
"Unable to search Zebra", 1 unless $#authids > 0;
50 ($authmatch, $fuzzy) = $linker->get_link($heading);
51 is
($authmatch, $authid, "Matched existing heading");