From 57f82d49489f9422246de13d8f24bf0de9a198d3 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 Signed-off-by: Lucas Gass --- 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 65c563d164..1c1d906555 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -16,7 +16,7 @@ use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Acquisition::Booksellers; use t::lib::Mocks; use t::lib::TestBuilder; -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 )); @@ -547,6 +547,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