From 614bfb432c9cf8763b5955b4715fff298394897d Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= Date: Thu, 1 Dec 2022 23:32:15 +0100 Subject: [PATCH] Bug 32392: Tests for changes in C4::Serials::GetNextSeq Content-Type: text/plain; charset=utf-8 Signed-off-by: Marcel de Rooy --- t/Serials/GetNextSeq.t | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/t/Serials/GetNextSeq.t b/t/Serials/GetNextSeq.t index c1cf423f3d..63a7f3c73e 100755 --- a/t/Serials/GetNextSeq.t +++ b/t/Serials/GetNextSeq.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 43; +use Test::More tests => 46; use C4::Serials qw( GetNextSeq ); # TEST CASE 1 - 1 variable, from 1 to 4 @@ -222,13 +222,38 @@ is($seq, 'Z: 12, Y: 8, X: 4'); $seq = _next_seq($subscription, $pattern); is($seq, 'Z: 1, Y: 1, X: 1'); +# TEST CASE 7 . Specify how many issues to count forward, 1 variable, from 1 to 4 + +$subscription = { + lastvalue1 => 1, lastvalue2 => 1, lastvalue3 => 1, + innerloop1 => 0, innerloop2 => 0, innerloop3 => 0, + skip_serialseq => 0, + irregularity => '', + locale => 'en', +}; +$pattern = { + add1 => 1, add2 => 0, add3 => 0, + every1 => 1, every2 => 0, every3 => 0, + whenmorethan1 => 4, whenmorethan2 => 0, whenmorethan3 => 0, + setto1 => 1, setto2 => 0, setto3 => 0, + numberingmethod => 'X: {X}', + numbering1 => '', + numbering2 => '', + numbering3 => '', +}; +$seq = _next_seq($subscription, $pattern, 1); +is($seq, 'X: 2'); +$seq = _next_seq($subscription, $pattern, 2); +is($seq, 'X: 4'); +$seq = _next_seq($subscription, $pattern, 2); +is($seq, 'X: 2'); sub _next_seq { - my ($subscription, $pattern) = @_; + my ($subscription, $pattern, $count_forward) = @_; my $seq; ($seq, $subscription->{lastvalue1}, $subscription->{lastvalue2}, $subscription->{lastvalue3}, $subscription->{innerloop1}, $subscription->{innerloop2}, $subscription->{innerloop3}) = - GetNextSeq($subscription, $pattern); + GetNextSeq($subscription, $pattern, undef, undef, $count_forward); return $seq; } -- 2.30.2