Bug 15836: Handle non-existent regexs
For other types of split rules Sponsored-by: Goethe-Institut Signed-off-by: Christian Stelzenmüller <christian.stelzenmueller@bsz-bw.de> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
328046e59c
commit
bde9fb59f2
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,10 +37,14 @@ 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');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue