added unit tests for C4/Serials.pm
[koha.git] / t / db_dependent / Serials.t
1 #!/usr/bin/perl
2 #
3 # This Koha test module is a stub!
4 # Add more tests here!!!
5
6 use strict;
7 use warnings;
8 use YAML;
9
10 use C4::Serials;
11 use C4::Debug;
12 use Test::More tests => 33;
13
14 BEGIN {
15     use_ok('C4::Serials');
16 }
17
18 my $subscriptionid = 1;
19 my $subscriptioninformation = GetSubscription( $subscriptionid );
20 $debug && warn Dump($subscriptioninformation);
21 my @subscriptions = GetSubscriptions( $$subscriptioninformation{bibliotitle} );
22 isa_ok( \@subscriptions, 'ARRAY' );
23 $debug && warn scalar(@subscriptions);
24 @subscriptions = GetSubscriptions( undef, $$subscriptioninformation{issn} );
25 isa_ok( \@subscriptions, 'ARRAY' );
26 $debug && warn scalar(@subscriptions);
27 @subscriptions = GetSubscriptions( undef,undef ,$$subscriptioninformation{bibnum} );
28 isa_ok( \@subscriptions, 'ARRAY' );
29 $debug && warn scalar(@subscriptions);
30 if ($subscriptioninformation->{periodicity} % 16==0){
31         $subscriptioninformation->{periodicity}=7;
32         ModSubscription(@$subscriptioninformation{qw(librarian,           branchcode,      aqbooksellerid,    cost,             aqbudgetid,    startdate,   periodicity,   firstacquidate,
33         dow,             irregularity,    numberpattern,     numberlength,     weeklength,    monthlength, add1,          every1,
34         whenmorethan1,   setto1,          lastvalue1,        innerloop1,       add2,          every2,      whenmorethan2, setto2,
35         lastvalue2,      innerloop2,      add3,              every3,           whenmorethan3, setto3,      lastvalue3,    innerloop3,
36         numberingmethod, status,          biblionumber,      callnumber,       notes,         letter,      hemisphere,    manualhistory,
37         internalnotes,   serialsadditems, staffdisplaycount, opacdisplaycount, graceperiod,   location,    enddate,       subscriptionid
38 )});
39 }
40 my $expirationdate = GetExpirationDate(1) ;
41 ok( $expirationdate, "not NULL" );
42 $debug && warn "$expirationdate";
43
44 is(C4::Serials::GetLateIssues(),"0", 'test getting late issues');
45
46 ok(C4::Serials::GetSubscriptionHistoryFromSubscriptionId(), 'test getting history from sub-scription');
47
48 ok(C4::Serials::GetSerialStatusFromSerialId(), 'test getting Serial Status From Serial Id');
49
50 ok(C4::Serials::GetSerialInformation(), 'test getting Serial Information');
51
52 ok(C4::Serials::AddItem2Serial(), 'test adding item to serial');
53
54 ok(C4::Serials::UpdateClaimdateIssues(), 'test updating claim date');
55
56 ok(C4::Serials::GetFullSubscription(), 'test getting full subscription');
57
58 ok(C4::Serials::PrepareSerialsData(), 'test preparing serial data');
59
60 ok(C4::Serials::GetSubscriptionsFromBiblionumber(), 'test getting subscriptions form biblio number');
61
62 is(C4::Serials::GetSerials(),"0", 'test getting serials when you enter nothing');
63 is(C4::Serials::GetSerials2(),"0", 'test getting serials when you enter nothing');
64
65 ok(C4::Serials::GetLatestSerials(), 'test getting lastest serials');
66
67 is(C4::Serials::GetDistributedTo(),"0", 'test getting distributed when nothing is entered');
68
69 is(C4::Serials::GetNextSeq(),"0", 'test getting next seq when you enter nothing');
70
71 is(C4::Serials::GetSeq(),undef, 'test getting seq when you enter nothing');
72
73 is(C4::Serials::CountSubscriptionFromBiblionumber(),"0", 'test counting subscription when nothing is entered');
74
75 is(C4::Serials::ModSubscriptionHistory(),"0", 'test modding subscription history');
76
77 is(C4::Serials::ModSerialStatus(),undef, 'test modding serials');
78
79 is(C4::Serials::NewIssue(),"0", 'test getting 0 when nothing is entered');
80
81 is(C4::Serials::ItemizeSerials(),undef, 'test getting nothing when nothing is entered');
82
83 ok(C4::Serials::HasSubscriptionStrictlyExpired(), 'test if the subscriptions has expired');
84 is(C4::Serials::HasSubscriptionExpired(),"0", 'test if the subscriptions has expired');
85
86 is(C4::Serials::GetLateOrMissingIssues(),"0", 'test getting last or missing issues');
87
88 is(C4::Serials::removeMissingIssue(),undef, 'test removing a missing issue');
89
90 is(C4::Serials::updateClaim(),undef, 'test updating claim');
91
92 is(C4::Serials::getsupplierbyserialid(),undef, 'test getting supplier idea');
93
94 is(C4::Serials::check_routing(),"0", 'test checking route');
95
96 is(C4::Serials::addroutingmember(),undef, 'test adding route member');