@@ -, +, @@ --- Koha/ClassSplitRule.pm | 2 +- t/db_dependent/Koha/ClassSplitRules.t | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) --- a/Koha/ClassSplitRule.pm +++ a/Koha/ClassSplitRule.pm @@ -64,7 +64,7 @@ sub regexs { my ( $self, $regexs ) = @_; return $regexs ? $self->split_regex( to_json($regexs) ) - : from_json( $self->split_regex ); + : from_json( $self->split_regex || '[]' ); } =head3 type --- a/t/db_dependent/Koha/ClassSplitRules.t +++ a/t/db_dependent/Koha/ClassSplitRules.t @@ -28,7 +28,7 @@ use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; subtest 'store + regexs' => sub { - plan tests => 1; + plan tests => 2; $schema->storage->txn_begin; my @regexs = ('s/\s/\n/g', 's/(\s?=)/\n=/g', 's/^(J|K)\n/$1 /'); @@ -37,11 +37,15 @@ subtest 'store + regexs' => sub { class_split_rule => 'split_rule', description => 'a_split_test_1', split_routine => 'regex', - regexs => \@regexs, } )->store; $rule = Koha::ClassSplitRules->find("split_rule"); + is_deeply($rule->regexs, [], '->regexs return an empty array when no regex is defined'); + + $rule->regexs(\@regexs)->store; + + $rule = Koha::ClassSplitRules->find("split_rule"); is_deeply($rule->regexs, \@regexs, '->new and ->regexs correctly serialized/deserialized the regexs'); $schema->storage->txn_rollback; --