|
Lines 18-28
Link Here
|
| 18 |
use strict; |
18 |
use strict; |
| 19 |
use warnings; |
19 |
use warnings; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 4; |
21 |
use Test::More tests => 5; |
| 22 |
|
22 |
|
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
|
25 |
|
|
|
26 |
use MARC::Record; |
| 27 |
use MARC::Field; |
| 28 |
use utf8; |
| 29 |
use C4::AuthoritiesMarc qw/ AddAuthority /; |
| 30 |
|
| 26 |
BEGIN { |
31 |
BEGIN { |
| 27 |
use_ok('C4::Heading', qw( field valid_heading_subfield )); |
32 |
use_ok('C4::Heading', qw( field valid_heading_subfield )); |
| 28 |
} |
33 |
} |
|
Lines 195-197
subtest "_search tests" => sub {
Link Here
|
| 195 |
is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled"); |
200 |
is_deeply( $terms, $expected_terms, "When thesaurus in subfield 2, and nothing is found, we don't search again if LinkerConsiderThesaurusDisabled"); |
| 196 |
|
201 |
|
| 197 |
}; |
202 |
}; |
| 198 |
- |
203 |
|
|
|
204 |
subtest "authorities exact match tests" => sub { |
| 205 |
|
| 206 |
plan tests => 2; |
| 207 |
|
| 208 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
| 209 |
|
| 210 |
my $schema = Koha::Database->new->schema; |
| 211 |
$schema->storage->txn_begin; |
| 212 |
|
| 213 |
my $authrec1 = MARC::Record->new; |
| 214 |
$authrec1->leader(' nz a22 o 4500'); |
| 215 |
$authrec1->insert_fields_ordered( MARC::Field->new( '100', '1', ' ', a => 'Rakowski, Albin', x => 'poetry' ) ); |
| 216 |
my $authid1 = AddAuthority( $authrec1, undef, 'PERSO_NAME' ); |
| 217 |
|
| 218 |
my $authrec2 = MARC::Record->new; |
| 219 |
$authrec2->leader(' nz a22 o 4500'); |
| 220 |
$authrec2->insert_fields_ordered( MARC::Field->new( '100', '1', ' ', a => 'Rąkowski, Albin', x => 'poetry' ) ); |
| 221 |
my $authid2 = AddAuthority( $authrec2, undef, 'PERSO_NAME' ); |
| 222 |
|
| 223 |
my $heading = Test::MockModule->new('C4::Heading'); |
| 224 |
$heading->mock( |
| 225 |
'_search', |
| 226 |
sub { |
| 227 |
my $self = shift; |
| 228 |
return ( [ { authid => $authid1 }, { authid => $authid2 } ], 2 ); |
| 229 |
} |
| 230 |
); |
| 231 |
|
| 232 |
my $biblio_field = MARC::Field->new( '600', '1', '1', a => 'Rakowski, Albin', x => 'poetry' ); |
| 233 |
my $biblio_heading = C4::Heading->new_from_field($biblio_field); |
| 234 |
|
| 235 |
my $authorities = $biblio_heading->authorities(1); |
| 236 |
is_deeply( |
| 237 |
$authorities, [ { authid => $authid1 } ], |
| 238 |
"Authorities filter OK - remained authority 'Rakowski' for biblio 'Rakowski'" |
| 239 |
); |
| 240 |
|
| 241 |
my $authrec3 = MARC::Record->new; |
| 242 |
$authrec3->leader(' nz a22 o 4500'); |
| 243 |
$authrec3->insert_fields_ordered( MARC::Field->new( '100', '1', ' ', a => 'Bruckner, Karl' ) ); |
| 244 |
my $authid3 = AddAuthority( $authrec3, undef, 'PERSO_NAME' ); |
| 245 |
|
| 246 |
$heading->mock( |
| 247 |
'_search', |
| 248 |
sub { |
| 249 |
my $self = shift; |
| 250 |
return ( [ { authid => $authid3 } ], 1 ); |
| 251 |
} |
| 252 |
); |
| 253 |
|
| 254 |
$biblio_field = MARC::Field->new( '700', '1', ' ', a => 'Brückner, Karl' ); |
| 255 |
$biblio_heading = C4::Heading->new_from_field($biblio_field); |
| 256 |
|
| 257 |
$authorities = $biblio_heading->authorities(1); |
| 258 |
is_deeply( $authorities, [], "Authorities filter OK - 'Brückner' not matched with 'Bruckner'" ); |
| 259 |
|
| 260 |
$schema->storage->txn_rollback; |
| 261 |
|
| 262 |
}; |