View | Details | Raw Unified | Return to bug 15836
Collapse All | Expand All

(-)a/Koha/ClassSplitRule.pm (-1 / +1 lines)
Lines 64-70 sub regexs { Link Here
64
    my ( $self, $regexs ) = @_;
64
    my ( $self, $regexs ) = @_;
65
    return $regexs
65
    return $regexs
66
      ? $self->split_regex( to_json($regexs) )
66
      ? $self->split_regex( to_json($regexs) )
67
      : from_json( $self->split_regex );
67
      : from_json( $self->split_regex || '[]' );
68
}
68
}
69
69
70
=head3 type
70
=head3 type
(-)a/t/db_dependent/Koha/ClassSplitRules.t (-3 / +6 lines)
Lines 28-34 use t::lib::TestBuilder; Link Here
28
my $schema = Koha::Database->new->schema;
28
my $schema = Koha::Database->new->schema;
29
29
30
subtest 'store + regexs' => sub {
30
subtest 'store + regexs' => sub {
31
    plan tests => 1;
31
    plan tests => 2;
32
    $schema->storage->txn_begin;
32
    $schema->storage->txn_begin;
33
33
34
    my @regexs = ('s/\s/\n/g', 's/(\s?=)/\n=/g', 's/^(J|K)\n/$1 /');
34
    my @regexs = ('s/\s/\n/g', 's/(\s?=)/\n=/g', 's/^(J|K)\n/$1 /');
Lines 37-46 subtest 'store + regexs' => sub { Link Here
37
            class_split_rule => 'split_rule',
37
            class_split_rule => 'split_rule',
38
            description     => 'a_split_test_1',
38
            description     => 'a_split_test_1',
39
            split_routine   => 'regex',
39
            split_routine   => 'regex',
40
            regexs          => \@regexs,
41
        }
40
        }
42
    )->store;
41
    )->store;
43
42
43
    $rule = Koha::ClassSplitRules->find("split_rule");
44
    is_deeply($rule->regexs, [], '->regexs return an empty array when no regex is defined');
45
46
    $rule->regexs(\@regexs)->store;
47
44
    $rule = Koha::ClassSplitRules->find("split_rule");
48
    $rule = Koha::ClassSplitRules->find("split_rule");
45
    is_deeply($rule->regexs, \@regexs, '->new and ->regexs correctly serialized/deserialized the regexs');
49
    is_deeply($rule->regexs, \@regexs, '->new and ->regexs correctly serialized/deserialized the regexs');
46
50
47
- 

Return to bug 15836