Bug 12987: The new format_price include file should be include on using datatables
[koha.git] / t / Biblio.t
blobcec30a9a73ab428c74b3a4119a3fc218ef266f2b
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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>.
18 use Modern::Perl;
20 use Test::More tests => 44;
21 use Test::MockModule;
22 use Test::Warn;
23 use DBD::Mock;
25 BEGIN {
26 use_ok('C4::Biblio');
29 my $context = new Test::MockModule('C4::Context');
30 $context->mock(
31 '_new_dbh',
32 sub {
33 my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
34 || die "Cannot create handle: $DBI::errstr\n";
35 return $dbh;
39 my @arr;
40 my $ret;
42 warning_is { @arr = AddBiblio(undef, q{}) }
43 { carped => 'AddBiblio called with undefined record'},
44 "AddBiblio returns carped warning on undef record";
46 my $elements = @arr;
48 is($elements, 0, 'Add Biblio returns empty array for undef record');
50 warning_is { $ret = ModBiblio(undef, 0, '') }
51 { carped => 'No record passed to ModBiblio'},
52 "ModBiblio returns carped warning on undef record";
54 is( $ret, 0, 'ModBiblio returns zero if not passed rec');
56 warning_is { $ret = BiblioAutoLink(undef, q{}) }
57 { carped => 'Undefined record passed to BiblioAutoLink'},
58 "BiblioAutoLink returns carped warning on undef record";
60 is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
62 warning_is { $ret = GetRecordValue('100', undef, q{}) }
63 { carped => 'GetRecordValue called with undefined record'},
64 "GetRecordValue returns carped warning on undef record";
66 ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
68 warning_is { @arr = LinkBibHeadingsToAuthorities(q{}, q{}) }
69 { carped => 'LinkBibHeadingsToAuthorities called on undefined bib record'},
70 "LinkBibHeadingsToAuthorities returns carped warning on undef record";
72 is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
74 warning_is { $ret = GetCOinSBiblio() }
75 { carped => 'GetCOinSBiblio called with undefined record'},
76 "GetCOinSBiblio returns carped warning on undef record";
78 ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
80 warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
81 { carped => 'GetMarcPrice called on undefined record'},
82 "GetMarcPrice returns carped warning on undef record";
84 ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
86 warning_is { $ret = GetMarcQuantity(undef, 'MARC21') }
87 { carped => 'GetMarcQuantity called on undefined record'},
88 "GetMarcQuantity returns carped warning on undef record";
90 ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
92 warning_is { $ret = GetMarcControlnumber() }
93 { carped => 'GetMarcControlnumber called on undefined record'},
94 "GetMarcControlnumber returns carped warning on undef record";
96 ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
98 warning_is { $ret = GetMarcISBN() }
99 { carped => 'GetMarcISBN called on undefined record'},
100 "GetMarcISBN returns carped warning on undef record";
102 ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
104 warning_is { $ret = GetMarcISSN() }
105 { carped => 'GetMarcISSN called on undefined record'},
106 "GetMarcISSN returns carped warning on undef record";
108 ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
110 warning_is { $ret = GetMarcNotes() }
111 { carped => 'GetMarcNotes called on undefined record'},
112 "GetMarcNotes returns carped warning on undef record";
114 ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
116 warning_is { $ret = GetMarcSubjects() }
117 { carped => 'GetMarcSubjects called on undefined record'},
118 "GetMarcSubjects returns carped warning on undef record";
120 ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
122 warning_is { $ret = GetMarcAuthors() }
123 { carped => 'GetMarcAuthors called on undefined record'},
124 "GetMarcAuthors returns carped warning on undef record";
126 ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
128 warning_is { $ret = GetMarcUrls() }
129 { carped => 'GetMarcUrls called on undefined record'},
130 "GetMarcUrls returns carped warning on undef record";
132 ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
134 warning_is { $ret = GetMarcSeries() }
135 { carped => 'GetMarcSeries called on undefined record'},
136 "GetMarcSeries returns carped warning on undef record";
138 ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
140 warning_is { $ret = GetMarcHosts() }
141 { carped => 'GetMarcHosts called on undefined record'},
142 "GetMarcHosts returns carped warning on undef record";
144 ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
146 my $hash_ref;
148 warning_is { $hash_ref = TransformMarcToKoha(undef, undef) }
149 { carped => 'TransformMarcToKoha called with undefined record'},
150 "TransformMarcToKoha returns carped warning on undef record";
152 isa_ok( $hash_ref, 'HASH');
154 $elements = keys %{$hash_ref};
156 is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
158 warning_is { $ret = ModBiblioMarc() }
159 { carped => 'ModBiblioMarc passed an undefined record'},
160 "ModBiblioMarc returns carped warning on undef record";
162 ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
164 warning_is { $ret = RemoveAllNsb() }
165 { carped => 'RemoveAllNsb called with undefined record'},
166 "RemoveAllNsb returns carped warning on undef record";
168 ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
170 warning_is { $ret = UpdateTotalIssues() }
171 { carped => 'UpdateTotalIssues could not get biblio record'},
172 "UpdateTotalIssues returns carped warning if biblio record does not exist";
174 ok( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');