From c6dc44603bbe8907fd114a367e69f849798bdee4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 22 Dec 2023 18:52:57 +0000 Subject: [PATCH] Bug 35646: Unit tests Content-Type: text/plain; charset=utf-8 Signed-off-by: Lucas Gass Signed-off-by: Marcel de Rooy --- t/db_dependent/Serials.t | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 7a431c1edd..8f91362696 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -17,7 +17,7 @@ use Koha::Acquisition::Booksellers; use t::lib::Mocks; use t::lib::TestBuilder; use Test::MockModule; -use Test::More tests => 54; +use Test::More tests => 55; BEGIN { use_ok('C4::Serials', qw( updateClaim NewSubscription GetSubscription GetSubscriptionHistoryFromSubscriptionId SearchSubscriptions ModSubscription GetExpirationDate GetSerials GetSerialInformation NewIssue AddItem2Serial DelSubscription GetFullSubscription PrepareSerialsData GetSubscriptionsFromBiblionumber ModSubscriptionHistory GetSerials2 GetLatestSerials GetNextSeq GetSeq CountSubscriptionFromBiblionumber ModSerialStatus findSerialsByStatus HasSubscriptionStrictlyExpired HasSubscriptionExpired GetLateOrMissingIssues check_routing addroutingmember GetNextDate )); @@ -552,6 +552,43 @@ subtest "NewSubscription|ModSubscription" => sub { is( $serials->next->biblionumber, $biblio_2->biblionumber, 'ModSubscription should have updated serial.biblionumber'); }; +subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub { + plan tests => 4; + $subscription = { + lastvalue1 => 1, lastvalue2 => 1, lastvalue3 => 1, + innerloop1 => 0, innerloop2 => 0, innerloop3 => 0, + skip_serialseq => 0, + irregularity => '', + locale => 'C', # locale set to 'C' to ensure we'll have english strings + firstaquidate => '1970-11-01', + }; + $pattern = { + numberingmethod => '{Year} {Day} {DayName} {Month} {MonthName}', + }; + + my $numbering = GetSeq( $subscription, $pattern ); + is( $numbering, '1970 1 Sunday 11 November', 'GetSeq correctly calculates numbering from first aqui date' ); + $subscription->{firstaquidate} = '2024-02-29'; + + $numbering = GetSeq( $subscription, $pattern ); + is( + $numbering, '2024 29 Thursday 2 February', + 'GetSeq correctly calculates numbering from first aqui date, leap year' + ); + + my $planneddate = '1970-11-01'; + ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate ); + is( $numbering, '1970 1 Sunday 11 November', 'GetNextSeq correctly calculates numbering from planned date' ); + $planneddate = '2024-02-29'; + ($numbering) = GetNextSeq( $subscription, $pattern, undef, $planneddate ); + is( + $numbering, '2024 29 Thursday 2 February', + 'GetNextSeq correctly calculates numbering from planned date, leap year' + ); + +}; + + subtest "_numeration" => sub { plan tests => 6; -- 2.30.2