From 6f7645c556f85019e403432a945589e789a1eda0 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 13 Aug 2019 13:52:35 +1200 Subject: [PATCH] Bug 23352: Changes to unit tests Changes to t/db_dependent/Serials.t unit tests to capture and test the changes to NewSubscription() and ModSubscription() in C4/Serials.pm Test plan: 1. Follow test plan in first commit 2. From Koha home directory enter Koha shell and run: prove t/db_dependent/Serials.t Sponsored-By: Brimbank Library, Australia --- C4/Items.pm | 8 ++++---- t/db_dependent/Serials.t | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 6dbe0e7..5030eef 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2177,7 +2177,7 @@ sub _SearchItems_build_where_fragment { my ($items, $total) = SearchItems($filter, $params); -Perform ubscriptionCurrentlyOnOrder search among items +Perform a search among items $filter is a reference to a hash which can be a filter, or a combination of filters. @@ -2364,10 +2364,10 @@ sub PrepareItemrecordDisplay { #If the subscription is on order (i.e. aqorders.datereceived is NULL then call GetLastOrderNotReceviedFromSubscription() which #retrieves the last order for the subscriptionid with a datereceived also equalling NULL - if ( subscriptionCurrentlyOnOrder($subscriptionid) ) { - $lastOrder = GetLastOrderNotReceivedFromSubscriptionid( $subscriptionid ); + if ( C4::Serials::subscriptionCurrentlyOnOrder($subscriptionid)) { + $lastOrder = C4::Acquisition::GetLastOrderNotReceivedFromSubscriptionid( $subscriptionid ); } else { #Otherwise the subscription has already arrived so retrieve the last order for the subscriptionid where datereceived is not null - $lastOrder = GetLastOrderReceivedFromSubscriptionid( $subscriptionid ); + $lastOrder = C4::Acquisition::GetLastOrderReceivedFromSubscriptionid( $subscriptionid ); } my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 735af75..a4f0fa6 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -18,7 +18,7 @@ use Koha::DateUtils; use Koha::Acquisition::Booksellers; use t::lib::Mocks; use t::lib::TestBuilder; -use Test::More tests => 49; +use Test::More tests => 51; BEGIN { use_ok('C4::Serials'); @@ -83,15 +83,18 @@ my $subscriptionid = NewSubscription( undef, undef, undef, undef, undef, undef, 1, $notes, ,undef, '2013-01-01', undef, $pattern_id, undef, undef, 0, $internalnotes, 0, - undef, undef, 0, undef, '2013-12-31', 0 + undef, undef, 0, undef, '2013-12-31', 0, + undef, undef, undef, 'ccodevalue' ); my $subscriptioninformation = GetSubscription( $subscriptionid ); is( $subscriptioninformation->{notes}, $notes, 'NewSubscription should set notes' ); is( $subscriptioninformation->{internalnotes}, $internalnotes, 'NewSubscription should set internalnotes' ); +is( $subscriptioninformation->{ccode}, 'ccodevalue', 'NewSubscription ccode should be "ccodevalue"' ); my $subscription_history = C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid); + is( $subscription_history->{opacnote}, undef, 'NewSubscription should not set subscriptionhistory opacnotes' ); is( $subscription_history->{librariannote}, undef, 'NewSubscription should not set subscriptionhistory librariannotes' ); @@ -117,6 +120,7 @@ if (not $frequency->{unit}) { $frequency->{description} = "Frequency created by t/db_dependant/Serials.t"; $subscriptioninformation->{periodicity} = AddSubscriptionFrequency($frequency); $subscriptioninformation->{serialsadditems} = 1; + $subscriptioninformation->{ccode} = 'ccodevalue2'; ModSubscription( @$subscriptioninformation{qw( librarian branchcode aqbooksellerid cost aqbudgetid startdate @@ -125,12 +129,16 @@ if (not $frequency->{unit}) { innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes letter manualhistory internalnotes serialsadditems staffdisplaycount opacdisplaycount graceperiod location enddate subscriptionid - skip_serialseq + skip_serialseq itemtype previousitemtype mana_id ccode )} ); } my $expirationdate = GetExpirationDate($subscriptionid) ; ok( $expirationdate, "expiration date is not NULL" ); +#Check if ccode has changed +my $subscriptioninformation2 = GetSubscription( $subscriptionid ); +is( $subscriptioninformation2->{ccode}, 'ccodevalue2', 'ModifiedSubscription ccode should be "ccodevalue2"' ); + ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId($subscriptionid), 'test getting history from sub-scription'); my ($serials_count, @serials) = GetSerials($subscriptionid); @@ -183,7 +191,7 @@ if ($old_frequency) { innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes letter manualhistory internalnotes serialsadditems staffdisplaycount opacdisplaycount graceperiod location enddate subscriptionid - skip_serialseq + skip_serialseq itemtype previousitemtype mana_id ccode )} ); DelSubscriptionFrequency($freq_to_delete); @@ -296,7 +304,8 @@ $subscriptionid = NewSubscription( undef, undef, undef, undef, undef, undef, 1, $notes,undef, '2013-01-01', undef, $pattern_id, undef, undef, 0, $internalnotes, 0, - undef, undef, 0, undef, '2013-12-31', 0 + undef, undef, 0, undef, '2013-12-31', 0, + undef, undef, undef, 'ccode' ); my $total_issues; ( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid ); @@ -396,7 +405,8 @@ subtest "NewSubscription" => sub { "", "", "", "", "", "", 1, $notes,"", '2013-01-01', "", $pattern_id, "", "", 0, $internalnotes, 0, - "", "", 0, "", '2013-12-31', 0 + "", "", 0, "", '2013-12-31', 0, "", + "", "", "ccode" ); ok($subscriptionid, "Sending empty string instead of undef to reflect use of the interface"); }; -- 2.1.4