Lines 23-29
Link Here
|
23 |
|
23 |
|
24 |
use Modern::Perl; |
24 |
use Modern::Perl; |
25 |
|
25 |
|
26 |
use Test::More tests => 3; |
26 |
use Test::More tests => 4; |
27 |
|
27 |
|
28 |
use List::MoreUtils qw/any/; |
28 |
use List::MoreUtils qw/any/; |
29 |
use MARC::Record; |
29 |
use MARC::Record; |
Lines 33-38
use C4::Biblio;
Link Here
|
33 |
use Koha::Caches; |
33 |
use Koha::Caches; |
34 |
use Koha::Database; |
34 |
use Koha::Database; |
35 |
|
35 |
|
|
|
36 |
use t::lib::TestBuilder; |
37 |
|
36 |
BEGIN { |
38 |
BEGIN { |
37 |
use_ok('Koha::RecordProcessor'); |
39 |
use_ok('Koha::RecordProcessor'); |
38 |
} |
40 |
} |
Lines 41-46
my $dbh = C4::Context->dbh;
Link Here
|
41 |
|
43 |
|
42 |
my $database = Koha::Database->new(); |
44 |
my $database = Koha::Database->new(); |
43 |
my $schema = $database->schema(); |
45 |
my $schema = $database->schema(); |
|
|
46 |
my $builder = t::lib::TestBuilder->new; |
44 |
|
47 |
|
45 |
sub run_hiding_tests { |
48 |
sub run_hiding_tests { |
46 |
|
49 |
|
Lines 205-207
subtest 'Koha::Filter::MARC::ViewPolicy intranet tests' => sub {
Link Here
|
205 |
$schema->storage->txn_rollback(); |
208 |
$schema->storage->txn_rollback(); |
206 |
}; |
209 |
}; |
207 |
|
210 |
|
208 |
- |
211 |
subtest 'caching tests' => sub { |
|
|
212 |
|
213 |
plan tests => 3; |
214 |
|
215 |
$schema->storage->txn_begin; |
216 |
|
217 |
my $fw_1 = $builder->build_object( { class => 'Koha::BiblioFrameworks' } ); |
218 |
my $fw_2 = $builder->build_object( { class => 'Koha::BiblioFrameworks' } ); |
219 |
my $mss_1 = $builder->build_object( |
220 |
{ |
221 |
class => 'Koha::MarcSubfieldStructures', |
222 |
value => { frameworkcode => $fw_1->frameworkcode } |
223 |
} |
224 |
); |
225 |
my $mss_2 = $builder->build_object( |
226 |
{ |
227 |
class => 'Koha::MarcSubfieldStructures', |
228 |
value => { frameworkcode => $fw_2->frameworkcode } |
229 |
} |
230 |
); |
231 |
|
232 |
my $biblio = $builder->build_sample_biblio; |
233 |
my $record = $biblio->metadata->record; |
234 |
|
235 |
my $processor = Koha::RecordProcessor->new( |
236 |
{ |
237 |
schema => 'MARC', |
238 |
filters => ('ViewPolicy'), |
239 |
} |
240 |
); |
241 |
|
242 |
$processor->options( |
243 |
{ |
244 |
frameworkcode => $fw_1->frameworkcode |
245 |
} |
246 |
); |
247 |
|
248 |
$processor->process($record); |
249 |
|
250 |
ok( |
251 |
exists $processor->filters->[0]->{_cached_frameworks} |
252 |
->{ $fw_1->frameworkcode }, |
253 |
'First framework is cached' |
254 |
); |
255 |
|
256 |
$processor->options( |
257 |
{ |
258 |
frameworkcode => $fw_2->frameworkcode |
259 |
} |
260 |
); |
261 |
|
262 |
$processor->process($record); |
263 |
|
264 |
ok( |
265 |
exists $processor->filters->[0]->{_cached_frameworks} |
266 |
->{ $fw_1->frameworkcode }, |
267 |
'First framework is cached' |
268 |
); |
269 |
ok( |
270 |
exists $processor->filters->[0]->{_cached_frameworks} |
271 |
->{ $fw_2->frameworkcode }, |
272 |
'Second framework is cached' |
273 |
); |
274 |
|
275 |
$schema->storage->txn_rollback; |
276 |
}; |