Bug 18639: (QA follow-up) Fix formatting of replacement cost when modifying an order
[koha.git] / t / Biblio.t
blob0d140bed60cd4b784cb9feb0a001c209dab12a8f
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;
21 use Test::MockModule;
22 use Test::Warn;
24 plan tests => 47;
26 use_ok('C4::Biblio');
28 my $db = Test::MockModule->new('Koha::Database');
29 $db->mock( _new_schema => sub { return Schema(); } );
31 my @arr;
32 my $ret;
34 warning_is { @arr = AddBiblio(undef, q{}) }
35 { carped => 'AddBiblio called with undefined record'},
36 "AddBiblio returns carped warning on undef record";
38 my $elements = @arr;
40 is($elements, 0, 'Add Biblio returns empty array for undef record');
42 warning_is { $ret = ModBiblio(undef, 0, '') }
43 { carped => 'No record passed to ModBiblio'},
44 "ModBiblio returns carped warning on undef record";
46 is( $ret, 0, 'ModBiblio returns zero if not passed rec');
48 warning_is { $ret = BiblioAutoLink(undef, q{}) }
49 { carped => 'Undefined record passed to BiblioAutoLink'},
50 "BiblioAutoLink returns carped warning on undef record";
52 is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
54 warning_is { $ret = GetRecordValue('100', undef, q{}) }
55 { carped => 'GetRecordValue called with undefined record'},
56 "GetRecordValue returns carped warning on undef record";
58 ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
60 warning_is { @arr = LinkBibHeadingsToAuthorities(q{}, q{}) }
61 { carped => 'LinkBibHeadingsToAuthorities called on undefined bib record'},
62 "LinkBibHeadingsToAuthorities returns carped warning on undef record";
64 is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
66 warning_is { $ret = GetCOinSBiblio() }
67 { carped => 'GetCOinSBiblio called with undefined record'},
68 "GetCOinSBiblio returns carped warning on undef record";
70 ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
72 warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
73 { carped => 'GetMarcPrice called on undefined record'},
74 "GetMarcPrice returns carped warning on undef record";
76 ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
78 warning_is { $ret = GetMarcQuantity(undef, 'MARC21') }
79 { carped => 'GetMarcQuantity called on undefined record'},
80 "GetMarcQuantity returns carped warning on undef record";
82 ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
84 warning_is { $ret = GetMarcControlnumber() }
85 { carped => 'GetMarcControlnumber called on undefined record'},
86 "GetMarcControlnumber returns carped warning on undef record";
88 ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
90 warning_is { $ret = GetMarcISBN() }
91 { carped => 'GetMarcISBN called on undefined record'},
92 "GetMarcISBN returns carped warning on undef record";
94 ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
96 warning_is { $ret = GetMarcISSN() }
97 { carped => 'GetMarcISSN called on undefined record'},
98 "GetMarcISSN returns carped warning on undef record";
100 ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
102 warning_is { $ret = GetMarcNotes() }
103 { carped => 'GetMarcNotes called on undefined record'},
104 "GetMarcNotes returns carped warning on undef record";
106 ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
108 warning_is { $ret = GetMarcSubjects() }
109 { carped => 'GetMarcSubjects called on undefined record'},
110 "GetMarcSubjects returns carped warning on undef record";
112 ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
114 warning_is { $ret = GetMarcAuthors() }
115 { carped => 'GetMarcAuthors called on undefined record'},
116 "GetMarcAuthors returns carped warning on undef record";
118 ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
120 warning_is { $ret = GetMarcUrls() }
121 { carped => 'GetMarcUrls called on undefined record'},
122 "GetMarcUrls returns carped warning on undef record";
124 ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
126 warning_is { $ret = GetMarcSeries() }
127 { carped => 'GetMarcSeries called on undefined record'},
128 "GetMarcSeries returns carped warning on undef record";
130 ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
132 warning_is { $ret = GetMarcHosts() }
133 { carped => 'GetMarcHosts called on undefined record'},
134 "GetMarcHosts returns carped warning on undef record";
136 ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
138 my $hash_ref;
140 warning_is { $hash_ref = TransformMarcToKoha( undef) }
141 { carped => 'TransformMarcToKoha called with undefined record'},
142 "TransformMarcToKoha returns carped warning on undef record";
144 isa_ok( $hash_ref, 'HASH');
146 $elements = keys %{$hash_ref};
148 is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
150 warning_is { $ret = ModBiblioMarc() }
151 { carped => 'ModBiblioMarc passed an undefined record'},
152 "ModBiblioMarc returns carped warning on undef record";
154 ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
156 warning_is { $ret = RemoveAllNsb() }
157 { carped => 'RemoveAllNsb called with undefined record'},
158 "RemoveAllNsb returns carped warning on undef record";
160 ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
162 warning_is { $ret = GetMarcBiblio() }
163 { carped => 'GetMarcBiblio called without parameters'},
164 "GetMarcBiblio returns carped warning on no parameters";
166 warning_is { $ret = GetMarcBiblio({ biblionumber => undef }) }
167 { carped => 'GetMarcBiblio called with undefined biblionumber'},
168 "GetMarcBiblio returns carped warning on undef biblionumber";
170 ok( !defined $ret, 'GetMarcBiblio returns undef if not passed a biblionumber');
172 warnings_like { $ret = UpdateTotalIssues() }
173 [ { carped => qr/GetMarcBiblio called with undefined biblionumber/ },
174 { carped => qr/UpdateTotalIssues could not get biblio record/ } ],
175 "UpdateTotalIssues returns carped warnings if biblio record does not exist";
177 ok( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');