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>.
20 use Test::More tests => 46;
28 use Test::DBIx::Class {
29 schema_class => 'Koha::Schema',
30 connect_info => ['dbi:SQLite:dbname=:memory:','',''],
31 connect_opts => { name_sep => '.', quote_char => '`', },
32 fixture_class => '::Populate',
39 [ qw/ biblionumber datecreated timestamp / ],
45 my $db = Test::MockModule->new('Koha::Database');
46 $db->mock( _new_schema => sub { return Schema(); } );
51 warning_is { @arr = AddBiblio(undef, q{}) }
52 { carped => 'AddBiblio called with undefined record'},
53 "AddBiblio returns carped warning on undef record";
57 is($elements, 0, 'Add Biblio returns empty array for undef record');
59 warning_is { $ret = ModBiblio(undef, 0, '') }
60 { carped => 'No record passed to ModBiblio'},
61 "ModBiblio returns carped warning on undef record";
63 is( $ret, 0, 'ModBiblio returns zero if not passed rec');
65 warning_is { $ret = BiblioAutoLink(undef, q{}) }
66 { carped => 'Undefined record passed to BiblioAutoLink'},
67 "BiblioAutoLink returns carped warning on undef record";
69 is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
71 warning_is { $ret = GetRecordValue('100', undef, q{}) }
72 { carped => 'GetRecordValue called with undefined record'},
73 "GetRecordValue returns carped warning on undef record";
75 ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
77 warning_is { @arr = LinkBibHeadingsToAuthorities(q{}, q{}) }
78 { carped => 'LinkBibHeadingsToAuthorities called on undefined bib record'},
79 "LinkBibHeadingsToAuthorities returns carped warning on undef record";
81 is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
83 warning_is { $ret = GetCOinSBiblio() }
84 { carped => 'GetCOinSBiblio called with undefined record'},
85 "GetCOinSBiblio returns carped warning on undef record";
87 ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
89 warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
90 { carped => 'GetMarcPrice called on undefined record'},
91 "GetMarcPrice returns carped warning on undef record";
93 ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
95 warning_is { $ret = GetMarcQuantity(undef, 'MARC21') }
96 { carped => 'GetMarcQuantity called on undefined record'},
97 "GetMarcQuantity returns carped warning on undef record";
99 ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
101 warning_is { $ret = GetMarcControlnumber() }
102 { carped => 'GetMarcControlnumber called on undefined record'},
103 "GetMarcControlnumber returns carped warning on undef record";
105 ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
107 warning_is { $ret = GetMarcISBN() }
108 { carped => 'GetMarcISBN called on undefined record'},
109 "GetMarcISBN returns carped warning on undef record";
111 ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
113 warning_is { $ret = GetMarcISSN() }
114 { carped => 'GetMarcISSN called on undefined record'},
115 "GetMarcISSN returns carped warning on undef record";
117 ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
119 warning_is { $ret = GetMarcNotes() }
120 { carped => 'GetMarcNotes called on undefined record'},
121 "GetMarcNotes returns carped warning on undef record";
123 ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
125 warning_is { $ret = GetMarcSubjects() }
126 { carped => 'GetMarcSubjects called on undefined record'},
127 "GetMarcSubjects returns carped warning on undef record";
129 ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
131 warning_is { $ret = GetMarcAuthors() }
132 { carped => 'GetMarcAuthors called on undefined record'},
133 "GetMarcAuthors returns carped warning on undef record";
135 ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
137 warning_is { $ret = GetMarcUrls() }
138 { carped => 'GetMarcUrls called on undefined record'},
139 "GetMarcUrls returns carped warning on undef record";
141 ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
143 warning_is { $ret = GetMarcSeries() }
144 { carped => 'GetMarcSeries called on undefined record'},
145 "GetMarcSeries returns carped warning on undef record";
147 ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
149 warning_is { $ret = GetMarcHosts() }
150 { carped => 'GetMarcHosts called on undefined record'},
151 "GetMarcHosts returns carped warning on undef record";
153 ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
157 warning_is { $hash_ref = TransformMarcToKoha(undef, undef) }
158 { carped => 'TransformMarcToKoha called with undefined record'},
159 "TransformMarcToKoha returns carped warning on undef record";
161 isa_ok( $hash_ref, 'HASH');
163 $elements = keys %{$hash_ref};
165 is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
167 warning_is { $ret = ModBiblioMarc() }
168 { carped => 'ModBiblioMarc passed an undefined record'},
169 "ModBiblioMarc returns carped warning on undef record";
171 ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
173 warning_is { $ret = RemoveAllNsb() }
174 { carped => 'RemoveAllNsb called with undefined record'},
175 "RemoveAllNsb returns carped warning on undef record";
177 ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
179 warning_is { $ret = GetMarcBiblio() }
180 { carped => 'GetMarcBiblio called with undefined biblionumber'},
181 "GetMarcBiblio returns carped warning on undef biblionumber";
183 ok( !defined $ret, 'GetMarcBiblio returns undef if not passed a biblionumber');
185 warnings_like { $ret = UpdateTotalIssues() }
186 [ { carped => qr/GetMarcBiblio called with undefined biblionumber/ },
187 { carped => qr/UpdateTotalIssues could not get biblio record/ } ],
188 "UpdateTotalIssues returns carped warnings if biblio record does not exist";
190 ok( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');