From 8ca6ef256484ba47e566cae11b73ba8454713c68 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 27 Mar 2020 17:53:32 -0300 Subject: [PATCH] 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 --- t/RecordProcessor.t | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/t/RecordProcessor.t b/t/RecordProcessor.t index 63683c1b23..aab2b3c0f5 100755 --- a/t/RecordProcessor.t +++ b/t/RecordProcessor.t @@ -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(); -- 2.20.1