Bug 25008: Regression tests

This patch highlights a behaviour of Koha::RecordProcessor that is
unexpected: if you change the original options using ->options, the
loaded filters don't pick the change. That's because the filter objects
are loaded on ->new, and they are never updated.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/RecordProcessor.t
=> FAIL: Test prove ->options doesn't update the filters!

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2020-03-27 17:53:32 -03:00 committed by Martin Renvoize
parent 7d9842a7cc
commit 12243e3596
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 51 additions and 0 deletions

View File

@ -149,4 +149,55 @@ subtest 'new() tests' => sub {
is_deeply( $filter_params, $parameters, 'Initialization parameters' );
};
subtest 'options() tests' => sub {
plan tests => 4;
# Create a processor with some options
my $record_processor = Koha::RecordProcessor->new(
{
filters => ['EmbedSeeFromHeadings','Null'],
options => {
dummy => 'something'
}
}
);
my $filter = $record_processor->filters->[0];
is(
ref( $filter ),
'Koha::Filter::MARC::EmbedSeeFromHeadings',
'Correct second filter initialized'
);
is_deeply(
$filter->params->{options},
{ dummy => 'something' },
'Options are set correctly'
);
# Update the chosen options
$record_processor->options(
{
dummy => 'something else'
}
);
# Re-fetch the filter
$filter = $record_processor->filters->[0];
is(
ref( $filter ),
'Koha::Filter::MARC::EmbedSeeFromHeadings',
'Correct second filter initialized'
);
is_deeply(
$filter->params->{options},
{ dummy => 'something else' },
'Options are updated correctly'
);
};
done_testing();