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>.
28 my $db = Test
::MockModule
->new('Koha::Database');
29 $db->mock( _new_schema
=> sub { return Schema
(); } );
34 warning_is
{ @arr = AddBiblio
(undef, q{}) }
35 { carped
=> 'AddBiblio called with undefined record'},
36 "AddBiblio returns carped warning on undef record";
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 = GetMarcPrice
(undef, 'MARC21') }
67 { carped
=> 'GetMarcPrice called on undefined record'},
68 "GetMarcPrice returns carped warning on undef record";
70 ok
( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
72 warning_is
{ $ret = GetMarcQuantity
(undef, 'MARC21') }
73 { carped
=> 'GetMarcQuantity called on undefined record'},
74 "GetMarcQuantity returns carped warning on undef record";
76 ok
( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
78 warning_is
{ $ret = GetMarcControlnumber
() }
79 { carped
=> 'GetMarcControlnumber called on undefined record'},
80 "GetMarcControlnumber returns carped warning on undef record";
82 ok
( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
84 warning_is
{ $ret = GetMarcISBN
() }
85 { carped
=> 'GetMarcISBN called on undefined record'},
86 "GetMarcISBN returns carped warning on undef record";
88 ok
( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
90 warning_is
{ $ret = GetMarcISSN
() }
91 { carped
=> 'GetMarcISSN called on undefined record'},
92 "GetMarcISSN returns carped warning on undef record";
94 ok
( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
96 warning_is
{ $ret = GetMarcNotes
() }
97 { carped
=> 'GetMarcNotes called on undefined record'},
98 "GetMarcNotes returns carped warning on undef record";
100 ok
( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
102 warning_is
{ $ret = GetMarcSubjects
() }
103 { carped
=> 'GetMarcSubjects called on undefined record'},
104 "GetMarcSubjects returns carped warning on undef record";
106 ok
( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
108 warning_is
{ $ret = GetMarcAuthors
() }
109 { carped
=> 'GetMarcAuthors called on undefined record'},
110 "GetMarcAuthors returns carped warning on undef record";
112 ok
( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
114 warning_is
{ $ret = GetMarcUrls
() }
115 { carped
=> 'GetMarcUrls called on undefined record'},
116 "GetMarcUrls returns carped warning on undef record";
118 ok
( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
120 warning_is
{ $ret = GetMarcSeries
() }
121 { carped
=> 'GetMarcSeries called on undefined record'},
122 "GetMarcSeries returns carped warning on undef record";
124 ok
( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
126 warning_is
{ $ret = GetMarcHosts
() }
127 { carped
=> 'GetMarcHosts called on undefined record'},
128 "GetMarcHosts returns carped warning on undef record";
130 ok
( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
134 warning_is
{ $hash_ref = TransformMarcToKoha
( undef) }
135 { carped
=> 'TransformMarcToKoha called with undefined record'},
136 "TransformMarcToKoha returns carped warning on undef record";
138 isa_ok
( $hash_ref, 'HASH');
140 $elements = keys %{$hash_ref};
142 is
($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
144 warning_is
{ $ret = ModBiblioMarc
() }
145 { carped
=> 'ModBiblioMarc passed an undefined record'},
146 "ModBiblioMarc returns carped warning on undef record";
148 ok
( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
150 warning_is
{ $ret = RemoveAllNsb
() }
151 { carped
=> 'RemoveAllNsb called with undefined record'},
152 "RemoveAllNsb returns carped warning on undef record";
154 ok
( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
156 warning_is
{ $ret = GetMarcBiblio
() }
157 { carped
=> 'GetMarcBiblio called without parameters'},
158 "GetMarcBiblio returns carped warning on no parameters";
160 warning_is
{ $ret = GetMarcBiblio
({ biblionumber
=> undef }) }
161 { carped
=> 'GetMarcBiblio called with undefined biblionumber'},
162 "GetMarcBiblio returns carped warning on undef biblionumber";
164 ok
( !defined $ret, 'GetMarcBiblio returns undef if not passed a biblionumber');
166 warnings_like
{ $ret = UpdateTotalIssues
() }
167 [ { carped
=> qr/GetMarcBiblio called with undefined biblionumber/ },
168 { carped
=> qr/UpdateTotalIssues could not get biblio record/ } ],
169 "UpdateTotalIssues returns carped warnings if biblio record does not exist";
171 ok
( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');