From a758264f385de9401c2924429bc3efebd718f3ba Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 3 Mar 2021 12:21:20 +0100 Subject: [PATCH] Bug 27842: Add tests Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart (cherry picked from commit 46b2f5b488c7a8879c3d457cf82ac7e0a1dfcc0e) Signed-off-by: Fridolin Somers --- t/db_dependent/Serials.t | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index ea9e5a972a..4ae33916cd 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -420,8 +420,8 @@ subtest "PreserveSerialNotes preference" => sub { }; -subtest "NewSubscription" => sub { - plan tests => 1; +subtest "NewSubscription|ModSubscription" => sub { + plan tests => 4; my $subscriptionid = NewSubscription( "", "", "", "", $budget_id, $biblionumber, '2013-01-01', $frequency_id, "", "", "", @@ -431,4 +431,25 @@ subtest "NewSubscription" => sub { "", "", 0, "", '2013-12-31', 0 ); ok($subscriptionid, "Sending empty string instead of undef to reflect use of the interface"); + + my $subscription = Koha::Subscriptions->find($subscriptionid); + my $serials = Koha::Serials->search({ subscriptionid => $subscriptionid }); + is( $serials->count, 1, "NewSubscription created a first serial" ); + + my $biblio_2 = $builder->build_sample_biblio; + my $subscription_info = $subscription->unblessed; + $subscription_info->{biblionumber} = $biblio_2->biblionumber; + ModSubscription( @$subscription_info{qw( + librarian branchcode aqbooksellerid cost aqbudgetid startdate + periodicity firstacquidate irregularity numberpattern locale + numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2 + innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes + letter manualhistory internalnotes serialsadditems staffdisplaycount + opacdisplaycount graceperiod location enddate subscriptionid + skip_serialseq + )} ); + + $serials = Koha::Serials->search({ subscriptionid => $subscriptionid }); + is( $serials->count, 1, "Still only one serial" ); + is( $serials->next->biblionumber, $biblio_2->biblionumber, 'ModSubscription should have updated serial.biblionumber'); }; -- 2.20.1