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>.
24 use Module
::Load
::Conditional qw
/check_install/;
27 if ( check_install
( module
=> 'Test::DBIx::Class' ) ) {
30 plan skip_all
=> "Need Test::DBIx::Class"
36 #use Test::DBIx::Class {}, 'Biblio';
37 use Test
::DBIx
::Class
; #No difference between these two invocations in time taken to execute tests.
43 [ qw
/ biblionumber datecreated timestamp / ],
49 my $db = Test
::MockModule
->new('Koha::Database');
50 $db->mock( _new_schema
=> sub { return Schema
(); } );
55 warning_is
{ @arr = AddBiblio
(undef, q{}) }
56 { carped
=> 'AddBiblio called with undefined record'},
57 "AddBiblio returns carped warning on undef record";
61 is
($elements, 0, 'Add Biblio returns empty array for undef record');
63 warning_is
{ $ret = ModBiblio
(undef, 0, '') }
64 { carped
=> 'No record passed to ModBiblio'},
65 "ModBiblio returns carped warning on undef record";
67 is
( $ret, 0, 'ModBiblio returns zero if not passed rec');
69 warning_is
{ $ret = BiblioAutoLink
(undef, q{}) }
70 { carped
=> 'Undefined record passed to BiblioAutoLink'},
71 "BiblioAutoLink returns carped warning on undef record";
73 is
( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
75 warning_is
{ $ret = GetRecordValue
('100', undef, q{}) }
76 { carped
=> 'GetRecordValue called with undefined record'},
77 "GetRecordValue returns carped warning on undef record";
79 ok
( !defined $ret, 'GetRecordValue returns undef if not passed rec');
81 warning_is
{ @arr = LinkBibHeadingsToAuthorities
(q{}, q{}) }
82 { carped
=> 'LinkBibHeadingsToAuthorities called on undefined bib record'},
83 "LinkBibHeadingsToAuthorities returns carped warning on undef record";
85 is
($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
87 warning_is
{ $ret = GetCOinSBiblio
() }
88 { carped
=> 'GetCOinSBiblio called with undefined record'},
89 "GetCOinSBiblio returns carped warning on undef record";
91 ok
( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
93 warning_is
{ $ret = GetMarcPrice
(undef, 'MARC21') }
94 { carped
=> 'GetMarcPrice called on undefined record'},
95 "GetMarcPrice returns carped warning on undef record";
97 ok
( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
99 warning_is
{ $ret = GetMarcQuantity
(undef, 'MARC21') }
100 { carped
=> 'GetMarcQuantity called on undefined record'},
101 "GetMarcQuantity returns carped warning on undef record";
103 ok
( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
105 warning_is
{ $ret = GetMarcControlnumber
() }
106 { carped
=> 'GetMarcControlnumber called on undefined record'},
107 "GetMarcControlnumber returns carped warning on undef record";
109 ok
( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
111 warning_is
{ $ret = GetMarcISBN
() }
112 { carped
=> 'GetMarcISBN called on undefined record'},
113 "GetMarcISBN returns carped warning on undef record";
115 ok
( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
117 warning_is
{ $ret = GetMarcISSN
() }
118 { carped
=> 'GetMarcISSN called on undefined record'},
119 "GetMarcISSN returns carped warning on undef record";
121 ok
( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
123 warning_is
{ $ret = GetMarcNotes
() }
124 { carped
=> 'GetMarcNotes called on undefined record'},
125 "GetMarcNotes returns carped warning on undef record";
127 ok
( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
129 warning_is
{ $ret = GetMarcSubjects
() }
130 { carped
=> 'GetMarcSubjects called on undefined record'},
131 "GetMarcSubjects returns carped warning on undef record";
133 ok
( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
135 warning_is
{ $ret = GetMarcAuthors
() }
136 { carped
=> 'GetMarcAuthors called on undefined record'},
137 "GetMarcAuthors returns carped warning on undef record";
139 ok
( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
141 warning_is
{ $ret = GetMarcUrls
() }
142 { carped
=> 'GetMarcUrls called on undefined record'},
143 "GetMarcUrls returns carped warning on undef record";
145 ok
( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
147 warning_is
{ $ret = GetMarcSeries
() }
148 { carped
=> 'GetMarcSeries called on undefined record'},
149 "GetMarcSeries returns carped warning on undef record";
151 ok
( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
153 warning_is
{ $ret = GetMarcHosts
() }
154 { carped
=> 'GetMarcHosts called on undefined record'},
155 "GetMarcHosts returns carped warning on undef record";
157 ok
( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
161 warning_is
{ $hash_ref = TransformMarcToKoha
( undef) }
162 { carped
=> 'TransformMarcToKoha called with undefined record'},
163 "TransformMarcToKoha returns carped warning on undef record";
165 isa_ok
( $hash_ref, 'HASH');
167 $elements = keys %{$hash_ref};
169 is
($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
171 warning_is
{ $ret = ModBiblioMarc
() }
172 { carped
=> 'ModBiblioMarc passed an undefined record'},
173 "ModBiblioMarc returns carped warning on undef record";
175 ok
( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
177 warning_is
{ $ret = RemoveAllNsb
() }
178 { carped
=> 'RemoveAllNsb called with undefined record'},
179 "RemoveAllNsb returns carped warning on undef record";
181 ok
( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
183 warning_is
{ $ret = GetMarcBiblio
() }
184 { carped
=> 'GetMarcBiblio called without parameters'},
185 "GetMarcBiblio returns carped warning on no parameters";
187 warning_is
{ $ret = GetMarcBiblio
({ biblionumber
=> undef }) }
188 { carped
=> 'GetMarcBiblio called with undefined biblionumber'},
189 "GetMarcBiblio returns carped warning on undef biblionumber";
191 ok
( !defined $ret, 'GetMarcBiblio returns undef if not passed a biblionumber');
193 warnings_like
{ $ret = UpdateTotalIssues
() }
194 [ { carped
=> qr/GetMarcBiblio called with undefined biblionumber/ },
195 { carped
=> qr/UpdateTotalIssues could not get biblio record/ } ],
196 "UpdateTotalIssues returns carped warnings if biblio record does not exist";
198 ok
( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');