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