|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 25; |
20 |
use Test::More tests => 26; |
|
|
21 |
use Test::NoWarnings; |
| 21 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
23 |
use Test::Warn; |
| 23 |
use List::MoreUtils qw( uniq ); |
24 |
use List::MoreUtils qw( uniq ); |
|
Lines 293-303
subtest "Test caching of authority types in LinkBibHeadingsToAuthorities" => sub
Link Here
|
| 293 |
} |
294 |
} |
| 294 |
); |
295 |
); |
| 295 |
my $authorities_type = Test::MockModule->new('Koha::Authority::Types'); |
296 |
my $authorities_type = Test::MockModule->new('Koha::Authority::Types'); |
|
|
297 |
my $found_auth_type = {}; |
| 296 |
$authorities_type->mock( |
298 |
$authorities_type->mock( |
| 297 |
'find', |
299 |
'find', |
| 298 |
sub { |
300 |
sub { |
| 299 |
my ( $self, $params ) = @_; |
301 |
my ( $self, $params ) = @_; |
| 300 |
warn "Finding auth type $params"; |
302 |
$found_auth_type->{$params}++; |
| 301 |
return $authorities_type->original("find")->( $self, $params ); |
303 |
return $authorities_type->original("find")->( $self, $params ); |
| 302 |
} |
304 |
} |
| 303 |
); |
305 |
); |
|
Lines 305-321
subtest "Test caching of authority types in LinkBibHeadingsToAuthorities" => sub
Link Here
|
| 305 |
my $field1 = MARC::Field->new( 655, ' ', ' ', 'a' => 'Magical realism' ); |
307 |
my $field1 = MARC::Field->new( 655, ' ', ' ', 'a' => 'Magical realism' ); |
| 306 |
my $field2 = MARC::Field->new( 655, ' ', ' ', 'a' => 'Magical falsism' ); |
308 |
my $field2 = MARC::Field->new( 655, ' ', ' ', 'a' => 'Magical falsism' ); |
| 307 |
$marc_record->append_fields( ( $field1, $field2 ) ); |
309 |
$marc_record->append_fields( ( $field1, $field2 ) ); |
| 308 |
my ( $num_changed, $results ); |
310 |
my ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ); |
| 309 |
warning_like { ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ) } |
311 |
is_deeply( $found_auth_type, { "GENRE/FORM" => 1 }, "Type fetched only once" ); |
| 310 |
qr/Finding auth type GENRE\/FORM/, |
|
|
| 311 |
"Type fetched only once"; |
| 312 |
my $gf_type = $cache->get_from_cache("LinkBibHeadingsToAuthorities:AuthorityType:GENRE/FORM"); |
312 |
my $gf_type = $cache->get_from_cache("LinkBibHeadingsToAuthorities:AuthorityType:GENRE/FORM"); |
| 313 |
ok( $gf_type, "GENRE/FORM type is found in cache" ); |
313 |
ok( $gf_type, "GENRE/FORM type is found in cache" ); |
| 314 |
|
314 |
|
| 315 |
warning_like { ( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ) } |
315 |
( $num_changed, $results ) = LinkBibHeadingsToAuthorities( $linker, $marc_record, "", undef ); |
| 316 |
undef, |
316 |
is_deeply( $found_auth_type, { "GENRE/FORM" => 1 }, "Type not fetched a second time" ); |
| 317 |
"Type not fetched a second time"; |
|
|
| 318 |
|
| 319 |
}; |
317 |
}; |
| 320 |
|
318 |
|
| 321 |
# Mocking variables |
319 |
# Mocking variables |
| 322 |
- |
|
|