From d6f7fa2d80392639e435250eec62e6d2ac8aa34b Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 14 Aug 2019 04:01:02 +0000 Subject: [PATCH] Bug 22188: Tests This patch fixes the t/db_dependent/Serials.t test which fails with this feature (without this fix). Ensure all other tests that use NewSubscription, ModSubscription, GetNextSeq, GetSeq still pass. db_dependent/Acquisition/OrderFromSubscription.t db_dependent/Bookseller.t db_dependent/Koha/Acquisition/Booksellers.t db_dependent/Letters.t db_dependent/Serials.t db_dependent/Serials/Claims.t db_dependent/Serials/ReNewSubscription.t db_dependent/Serials_2.t db_dependent/Serials/Frequency.t db_dependent/Serials/Numberpattern.t db_dependent/Serials/GetNextSeq.t Serials/GetNextSeq.t This patch also adds tests to db_dependent/Serials_2.t so check these tests pass prove -v t/db_dependent/Serials_2.t Sponsored-by: Brimbank Libraries Australia --- C4/Serials.pm | 2 +- t/db_dependent/Serials.t | 3 ++- t/db_dependent/Serials_2.t | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index b4de5a8baa7..2945c233c46 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -936,7 +936,7 @@ the sequence in string format sub GetSeq { my ($subscription, $pattern) = @_; - if ($pattern->{numberingmethod} eq ''){ + if ( !defined($pattern->{numberingmethod}) ){ return "pubdate"; } diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index eb432dc9144..8bc45356992 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -229,7 +229,8 @@ is(C4::Serials::GetLatestSerials(), undef, 'test getting lastest serials'); is(C4::Serials::GetNextSeq(), undef, 'test getting next seq when you enter nothing'); -is(C4::Serials::GetSeq(), undef, 'test getting seq when you enter nothing'); +is(C4::Serials::GetSeq(), 'pubdate', 'test getting seq when you enter nothing'); +# no input means assume using publication date as numbering pattern is(C4::Serials::CountSubscriptionFromBiblionumber(), undef, 'test counting subscription when nothing is entered'); diff --git a/t/db_dependent/Serials_2.t b/t/db_dependent/Serials_2.t index d0a1b7a6157..a2d72ceeeb4 100755 --- a/t/db_dependent/Serials_2.t +++ b/t/db_dependent/Serials_2.t @@ -1,13 +1,14 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 50; +use Test::More tests => 52; use MARC::Record; use C4::Biblio qw( AddBiblio ); use Koha::Database; use Koha::Patrons; +use Koha::DateUtils qw( dt_from_string ); use t::lib::Mocks; use t::lib::TestBuilder; use_ok('C4::Serials', qw( NewSubscription GetSubscription NewIssue GetPreviousSerialid )); @@ -291,3 +292,37 @@ sub set_flags { ); } } + +# test publication date as numbering pattern + +my $subscriptionid_pubdatenumpattern = NewSubscription( + undef, $my_branch, undef, undef, $budget_id, $biblionumber, + '2013-01-01', undef, undef, undef, undef, + undef, undef, undef, undef, undef, + undef, 1, "notes", undef, '2013-01-01', undef, + undef, undef, undef, 0, "intnotes", + 0, undef, undef, 0, + undef, '2013-12-31', 0, undef, undef, undef, + 'dmy' +); + +my $serial_pubdatenumpattern = Koha::Serials->find({ subscriptionid => $subscriptionid_pubdatenumpattern }); + +is( $serial_pubdatenumpattern->serialseq, '01 January 2013', 'serialseq should be set to first acuisition date in the date format specified' ); + +ModSubscription( + undef, $my_branch, undef, undef, $budget_id, '2013-01-01', + undef, '2013-01-01', undef, undef, undef, + undef, undef, undef, undef, undef, + undef, undef, undef, undef, 1, + $biblionumber, undef, "notes", undef, 0, + "intnotes", 0, undef, undef, + 0, undef, '2013-12-31', $subscriptionid_pubdatenumpattern, 0, + undef, undef, undef, 'ydm' +); + +my $serialid_pubdatenumpattern = NewIssue( "pubdate", $subscriptionid_pubdatenumpattern, $biblionumber, 1 ); + +my $serial_pubdatenumpattern_2 = Koha::Serials->find( $serialid_pubdatenumpattern ); + +is( $serial_pubdatenumpattern_2->serialseq, dt_from_string( $serial_pubdatenumpattern_2->publisheddate )->strftime('%Y %d %B'), 'receive new issue with new pub date num pattern format' ); -- 2.30.2