Bug 13089 - Tab key triggers JavaScript error in the checkEnter function
[koha.git] / t / Biblio.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Test::More tests => 44;
21 use Test::Warn;
22
23 BEGIN {
24         use_ok('C4::Biblio');
25 }
26
27 my @arr;
28 my $ret;
29
30 warning_is { @arr = AddBiblio(undef, q{}) }
31            { carped => 'AddBiblio called with undefined record'},
32            "AddBiblio returns carped warning on undef record";
33
34 my $elements = @arr;
35
36 is($elements, 0, 'Add Biblio returns empty array for undef record');
37
38 warning_is { $ret = ModBiblio(undef, 0, '') }
39            { carped => 'No record passed to ModBiblio'},
40            "ModBiblio returns carped warning on undef record";
41
42 is( $ret, 0, 'ModBiblio returns zero if not passed rec');
43
44 warning_is { $ret = BiblioAutoLink(undef, q{}) }
45            { carped => 'Undefined record passed to BiblioAutoLink'},
46            "BiblioAutoLink returns carped warning on undef record";
47
48 is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
49
50 warning_is { $ret = GetRecordValue('100', undef, q{}) }
51            { carped => 'GetRecordValue called with undefined record'},
52            "GetRecordValue returns carped warning on undef record";
53
54 ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
55
56 warning_is { @arr = LinkBibHeadingsToAuthorities(q{}, q{}) }
57            { carped => 'LinkBibHeadingsToAuthorities called on undefined bib record'},
58            "LinkBibHeadingsToAuthorities returns carped warning on undef record";
59
60 is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
61
62 warning_is { $ret = GetCOinSBiblio() }
63            { carped => 'GetCOinSBiblio called with undefined record'},
64            "GetCOinSBiblio returns carped warning on undef record";
65
66 ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
67
68 warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
69            { carped => 'GetMarcPrice called on undefined record'},
70            "GetMarcPrice returns carped warning on undef record";
71
72 ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
73
74 warning_is { $ret = GetMarcQuantity(undef, 'MARC21') }
75            { carped => 'GetMarcQuantity called on undefined record'},
76            "GetMarcQuantity returns carped warning on undef record";
77
78 ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
79
80 warning_is { $ret = GetMarcControlnumber() }
81            { carped => 'GetMarcControlnumber called on undefined record'},
82            "GetMarcControlnumber returns carped warning on undef record";
83
84 ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
85
86 warning_is { $ret = GetMarcISBN() }
87            { carped => 'GetMarcISBN called on undefined record'},
88            "GetMarcISBN returns carped warning on undef record";
89
90 ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
91
92 warning_is { $ret = GetMarcISSN() }
93            { carped => 'GetMarcISSN called on undefined record'},
94            "GetMarcISSN returns carped warning on undef record";
95
96 ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
97
98 warning_is { $ret = GetMarcNotes() }
99            { carped => 'GetMarcNotes called on undefined record'},
100            "GetMarcNotes returns carped warning on undef record";
101
102 ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
103
104 warning_is { $ret = GetMarcSubjects() }
105            { carped => 'GetMarcSubjects called on undefined record'},
106            "GetMarcSubjects returns carped warning on undef record";
107
108 ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
109
110 warning_is { $ret = GetMarcAuthors() }
111            { carped => 'GetMarcAuthors called on undefined record'},
112            "GetMarcAuthors returns carped warning on undef record";
113
114 ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
115
116 warning_is { $ret = GetMarcUrls() }
117            { carped => 'GetMarcUrls called on undefined record'},
118            "GetMarcUrls returns carped warning on undef record";
119
120 ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
121
122 warning_is { $ret = GetMarcSeries() }
123            { carped => 'GetMarcSeries called on undefined record'},
124            "GetMarcSeries returns carped warning on undef record";
125
126 ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
127
128 warning_is { $ret = GetMarcHosts() }
129            { carped => 'GetMarcHosts called on undefined record'},
130            "GetMarcHosts returns carped warning on undef record";
131
132 ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
133
134 my $hash_ref;
135
136 warning_is { $hash_ref = TransformMarcToKoha(undef, undef) }
137            { carped => 'TransformMarcToKoha called with undefined record'},
138            "TransformMarcToKoha returns carped warning on undef record";
139
140 isa_ok( $hash_ref, 'HASH');
141
142 $elements = keys %{$hash_ref};
143
144 is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
145
146 warning_is { $ret = ModBiblioMarc() }
147            { carped => 'ModBiblioMarc passed an undefined record'},
148            "ModBiblioMarc returns carped warning on undef record";
149
150 ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
151
152 warning_is { $ret = RemoveAllNsb() }
153            { carped => 'RemoveAllNsb called with undefined record'},
154            "RemoveAllNsb returns carped warning on undef record";
155
156 ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
157
158 warning_is { $ret = UpdateTotalIssues() }
159            { carped => 'UpdateTotalIssues could not get biblio record'},
160            "UpdateTotalIssues returns carped warning if biblio record does not exist";
161
162 ok( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');
163
164 1;