3 # This Koha test module is a stub!
4 # Add more tests here!!!
11 use C4
::Serials
::Frequency
;
12 use C4
::Serials
::Numberpattern
;
17 use Test
::More tests
=> 35;
20 use_ok
('C4::Serials');
23 my $dbh = C4
::Context
->dbh;
26 $dbh->{AutoCommit
} = 0;
27 $dbh->{RaiseError
} = 1;
29 my $booksellerid = C4
::Bookseller
::AddBookseller
(
32 address1
=> "bookseller's address",
38 my ($biblionumber, $biblioitemnumber) = AddBiblio
(MARC
::Record
->new, '');
41 my $bpid = AddBudgetPeriod
({
42 budget_period_startdate
=> '01-01-2015',
43 budget_period_enddate
=> '12-31-2015',
44 budget_description
=> "budget desc"
47 my $budget_id = AddBudget
({
48 budget_code
=> "ABCD",
49 budget_amount
=> "123.132",
50 budget_name
=> "Périodiques",
51 budget_notes
=> "This is a note",
52 budget_description
=> "Serials",
54 budget_period_id
=> $bpid
57 my $frequency_id = AddSubscriptionFrequency
({ description
=> "Test frequency 1" });
58 my $pattern_id = AddSubscriptionNumberpattern
({
59 label
=> 'Test numberpattern 1',
60 numberingmethod
=> '{X}'
63 my $subscriptionid = NewSubscription
(
64 undef, "", undef, undef, $budget_id, $biblionumber,
65 '2013-01-01', $frequency_id, undef, undef, undef,
66 undef, undef, undef, undef, undef, undef,
67 1, "notes",undef, '2013-01-01', undef, $pattern_id,
68 undef, undef, 0, "intnotes", 0,
69 undef, undef, 0, undef, '2013-12-31', 0
72 my $subscriptioninformation = GetSubscription
( $subscriptionid );
74 my @subscriptions = GetSubscriptions
( $$subscriptioninformation{bibliotitle
} );
75 isa_ok
( \
@subscriptions, 'ARRAY' );
77 @subscriptions = GetSubscriptions
( undef, $$subscriptioninformation{issn
} );
78 isa_ok
( \
@subscriptions, 'ARRAY' );
80 @subscriptions = GetSubscriptions
( undef, undef, $$subscriptioninformation{ean
} );
81 isa_ok
( \
@subscriptions, 'ARRAY' );
83 @subscriptions = GetSubscriptions
( undef, undef, undef, $$subscriptioninformation{bibnum
} );
84 isa_ok
( \
@subscriptions, 'ARRAY' );
86 my $frequency = GetSubscriptionFrequency
($subscriptioninformation->{periodicity
});
88 if (not $frequency->{unit
}) {
89 $old_frequency = $frequency->{id
};
90 $frequency->{unit
} = "month";
91 $frequency->{unitsperissue
} = 1;
92 $frequency->{issuesperunit
} = 1;
93 $frequency->{description
} = "Frequency created by t/db_dependant/Serials.t";
94 $subscriptioninformation->{periodicity
} = AddSubscriptionFrequency
($frequency);
96 ModSubscription
( @
$subscriptioninformation{qw(
97 librarian branchcode aqbooksellerid cost aqbudgetid startdate
98 periodicity firstacquidate irregularity numberpattern locale
99 numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2
100 innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes
101 letter manualhistory internalnotes serialsadditems staffdisplaycount
102 opacdisplaycount graceperiod location enddate subscriptionid
106 my $expirationdate = GetExpirationDate
($subscriptionid) ;
107 ok
( $expirationdate, "expiration date is not NULL" );
109 is
(C4
::Serials
::GetLateIssues
(), undef, 'test getting late issues');
111 ok
(C4
::Serials
::GetSubscriptionHistoryFromSubscriptionId
($subscriptionid), 'test getting history from sub-scription');
113 my ($serials_count, @serials) = GetSerials
($subscriptionid);
114 ok
($serials_count > 0, 'Subscription has at least one serial');
115 my $serial = $serials[0];
117 ok
(C4
::Serials
::GetSerialStatusFromSerialId
($serial->{serialid
}), 'test getting Serial Status From Serial Id');
119 isa_ok
(C4
::Serials
::GetSerialInformation
($serial->{serialid
}), 'HASH', 'test getting Serial Information');
121 # Delete created frequency
122 if ($old_frequency) {
123 my $freq_to_delete = $subscriptioninformation->{periodicity
};
124 $subscriptioninformation->{periodicity
} = $old_frequency;
126 ModSubscription
( @
$subscriptioninformation{qw(
127 librarian branchcode aqbooksellerid cost aqbudgetid startdate
128 periodicity firstacquidate irregularity numberpattern locale
129 numberlength weeklength monthlength lastvalue1 innerloop1 lastvalue2
130 innerloop2 lastvalue3 innerloop3 status biblionumber callnumber notes
131 letter manualhistory internalnotes serialsadditems staffdisplaycount
132 opacdisplaycount graceperiod location enddate subscriptionid
136 DelSubscriptionFrequency
($freq_to_delete);
140 # Test calling subs without parameters
141 is
(C4
::Serials
::AddItem2Serial
(), undef, 'test adding item to serial');
142 is
(C4
::Serials
::UpdateClaimdateIssues
(), undef, 'test updating claim date');
143 is
(C4
::Serials
::GetFullSubscription
(), undef, 'test getting full subscription');
144 is
(C4
::Serials
::PrepareSerialsData
(), undef, 'test preparing serial data');
145 is
(C4
::Serials
::GetSubscriptionsFromBiblionumber
(), undef, 'test getting subscriptions form biblio number');
147 is
(C4
::Serials
::GetSerials
(), undef, 'test getting serials when you enter nothing');
148 is
(C4
::Serials
::GetSerials2
(), undef, 'test getting serials when you enter nothing');
150 is
(C4
::Serials
::GetLatestSerials
(), undef, 'test getting lastest serials');
152 is
(C4
::Serials
::GetDistributedTo
(), undef, 'test getting distributed when nothing is entered');
154 is
(C4
::Serials
::GetNextSeq
(), undef, 'test getting next seq when you enter nothing');
156 is
(C4
::Serials
::GetSeq
(), undef, 'test getting seq when you enter nothing');
158 is
(C4
::Serials
::CountSubscriptionFromBiblionumber
(), undef, 'test counting subscription when nothing is entered');
160 is
(C4
::Serials
::ModSubscriptionHistory
(), undef, 'test modding subscription history');
162 is
(C4
::Serials
::ModSerialStatus
(),undef, 'test modding serials');
164 is
(C4
::Serials
::NewIssue
(), undef, 'test getting 0 when nothing is entered');
166 is
(C4
::Serials
::ItemizeSerials
(),undef, 'test getting nothing when nothing is entered');
168 is
(C4
::Serials
::HasSubscriptionStrictlyExpired
(), undef, 'test if the subscriptions has expired');
169 is
(C4
::Serials
::HasSubscriptionExpired
(), undef, 'test if the subscriptions has expired');
171 is
(C4
::Serials
::GetLateOrMissingIssues
(), undef, 'test getting last or missing issues');
173 is
(C4
::Serials
::removeMissingIssue
(), undef, 'test removing a missing issue');
175 is
(C4
::Serials
::updateClaim
(),undef, 'test updating claim');
177 is
(C4
::Serials
::getsupplierbyserialid
(),undef, 'test getting supplier idea');
179 is
(C4
::Serials
::check_routing
(), undef, 'test checking route');
181 is
(C4
::Serials
::addroutingmember
(),undef, 'test adding route member');