Bug 29781: Unit test

This patch adds a unit test for capture groups support in Koha::Items

Test plan
1) Run the test prior to applying the capture groups fix, note it fails.
2) Apply the capture groups fix patch
3) Run the test again, it should now pass

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Jo Hunter <jhunter@clicweb.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2022-01-17 13:50:34 +00:00 committed by Fridolin Somers
parent 0a91f3c700
commit 1516514f1a

View file

@ -155,7 +155,7 @@ subtest 'blank' => sub {
};
subtest 'regex' => sub {
plan tests => 6;
plan tests => 12;
$items->batch_update(
{
@ -203,6 +203,41 @@ subtest 'regex' => sub {
['awesome yyy 1|new yyy 2'],
'y is not repeatable'
);
$re = {
search => '(awesome)',
replace => '$1ness',
modifiers => '',
};
$items->batch_update(
{
regex_mod =>
{ itemnotes => $re, copynumber => $re, x => $re, y => $re }
}
)->reset;
$item = $item->get_from_storage;
is( $item->itemnotes, 'awesomeness notes 1|new notes 2' );
is_deeply(
[ $item->as_marc_field->subfield('z') ],
[ 'awesomeness notes 1', 'new notes 2' ],
'z is repeatable'
);
is( $item->copynumber, 'awesomeness cn 1|new cn 2' );
is_deeply( [ $item->as_marc_field->subfield('t') ],
['awesomeness cn 1|new cn 2'], 't is not repeatable' );
is_deeply(
[ $item->as_marc_field->subfield('x') ],
[ 'awesomeness xxx 1', 'new xxx 2' ],
'i is repeatable'
);
is_deeply(
[ $item->as_marc_field->subfield('y') ],
['awesomeness yyy 1|new yyy 2'],
'y is not repeatable'
);
};
subtest 'encoding' => sub {