Lines 42-48
my $schema = $builder->schema();
Link Here
|
42 |
$schema->storage->txn_begin; |
42 |
$schema->storage->txn_begin; |
43 |
|
43 |
|
44 |
subtest 'Test caching in get_link and update_cache' => sub { |
44 |
subtest 'Test caching in get_link and update_cache' => sub { |
45 |
plan tests => 13; |
45 |
plan tests => 16; |
46 |
|
46 |
|
47 |
my @tags = C4::Context->preference('marcflavour') eq 'UNIMARC' ? (601,'j',602,'a') : (650,'a',655,'a'); |
47 |
my @tags = C4::Context->preference('marcflavour') eq 'UNIMARC' ? (601,'j',602,'a') : (650,'a',655,'a'); |
48 |
|
48 |
|
Lines 53-58
subtest 'Test caching in get_link and update_cache' => sub {
Link Here
|
53 |
my $subject_field5 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao'); |
53 |
my $subject_field5 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao'); |
54 |
my $subject_field6 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao'); |
54 |
my $subject_field6 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'sao'); |
55 |
my $subject_field7 = MARC::Field->new($tags[0],0,4,$tags[1]=>'Science fiction'); |
55 |
my $subject_field7 = MARC::Field->new($tags[0],0,4,$tags[1]=>'Science fiction'); |
|
|
56 |
my $subject_field8 = MARC::Field->new($tags[0],0,7,$tags[1]=>'Science fiction','2'=>'oth'); |
57 |
my $subject_field9 = MARC::Field->new($tags[0],0,3,$tags[1]=>'Science fiction'); |
56 |
my $genre_field = MARC::Field->new($tags[2],0,2,$tags[3]=>'Science fiction'); |
58 |
my $genre_field = MARC::Field->new($tags[2],0,2,$tags[3]=>'Science fiction'); |
57 |
# Can we build a heading from it? |
59 |
# Can we build a heading from it? |
58 |
my $subject_heading = C4::Heading->new_from_field( $subject_field, q{} ); |
60 |
my $subject_heading = C4::Heading->new_from_field( $subject_field, q{} ); |
Lines 62-69
subtest 'Test caching in get_link and update_cache' => sub {
Link Here
|
62 |
my $subject_heading5 = C4::Heading->new_from_field( $subject_field5, q{} ); |
64 |
my $subject_heading5 = C4::Heading->new_from_field( $subject_field5, q{} ); |
63 |
my $subject_heading6 = C4::Heading->new_from_field( $subject_field6, q{} ); |
65 |
my $subject_heading6 = C4::Heading->new_from_field( $subject_field6, q{} ); |
64 |
my $subject_heading7 = C4::Heading->new_from_field( $subject_field7, q{} ); |
66 |
my $subject_heading7 = C4::Heading->new_from_field( $subject_field7, q{} ); |
|
|
67 |
my $subject_heading8 = C4::Heading->new_from_field( $subject_field8, q{} ); |
68 |
my $subject_heading9 = C4::Heading->new_from_field( $subject_field9, q{} ); |
65 |
my $genre_heading = C4::Heading->new_from_field( $genre_field, q{} ); |
69 |
my $genre_heading = C4::Heading->new_from_field( $genre_field, q{} ); |
66 |
|
70 |
|
|
|
71 |
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',1); |
67 |
|
72 |
|
68 |
# Now test to see if C4::Linker can find it. |
73 |
# Now test to see if C4::Linker can find it. |
69 |
my $linker = C4::Linker::Default->new(); |
74 |
my $linker = C4::Linker::Default->new(); |
Lines 92-97
subtest 'Test caching in get_link and update_cache' => sub {
Link Here
|
92 |
$linker->get_link($subject_heading7); |
97 |
$linker->get_link($subject_heading7); |
93 |
is( keys %{$linker->{cache}},6, "Eighth (matching) term added to cache because of thesaurus source not specified (2nd indicator is 4)"); |
98 |
is( keys %{$linker->{cache}},6, "Eighth (matching) term added to cache because of thesaurus source not specified (2nd indicator is 4)"); |
94 |
|
99 |
|
|
|
100 |
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',0); |
101 |
|
102 |
$linker->get_link($subject_heading); |
103 |
is( keys %{$linker->{cache}},7, "First term added to cache because cache key now has 'notconsidered' for thesaurus"); |
104 |
|
105 |
$linker->get_link($subject_heading8); |
106 |
is( keys %{$linker->{cache}},7, "Ninth (matching) term not added to cache because thesaurus differs but is not considered"); |
107 |
|
108 |
$linker->get_link($subject_heading9); |
109 |
is( keys %{$linker->{cache}},7, "Tenth (matching) term not added to cache because thesaurus differs but is not considered"); |
110 |
|
111 |
t::lib::Mocks::mock_preference('LinkerConsiderThesaurus',1); |
112 |
|
95 |
$linker->update_cache($subject_heading,32); |
113 |
$linker->update_cache($subject_heading,32); |
96 |
is( $linker->{cache}->{$subject_heading->search_form.$subject_heading->auth_type.$subject_heading->{'thesaurus'}}->{authid}, 32, "Linker cache is correctly updated by 'update_cache'"); |
114 |
is( $linker->{cache}->{$subject_heading->search_form.$subject_heading->auth_type.$subject_heading->{'thesaurus'}}->{authid}, 32, "Linker cache is correctly updated by 'update_cache'"); |
97 |
my ( $authid, undef ) = $linker->get_link($subject_heading); |
115 |
my ( $authid, undef ) = $linker->get_link($subject_heading); |
98 |
- |
|
|