From 22b9e455aec968a0e5686732f08831956f50bd1e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 17 Jan 2022 13:50:34 +0000 Subject: [PATCH] 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 Signed-off-by: Jo Hunter --- t/db_dependent/Koha/Items/BatchUpdate.t | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Items/BatchUpdate.t b/t/db_dependent/Koha/Items/BatchUpdate.t index b07d0bf7cf..2a3811e141 100755 --- a/t/db_dependent/Koha/Items/BatchUpdate.t +++ b/t/db_dependent/Koha/Items/BatchUpdate.t @@ -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 { -- 2.30.2