View | Details | Raw Unified | Return to bug 12570
Collapse All | Expand All

(-)a/t/Biblio.t (-26 / +101 lines)
Lines 1-73 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
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.
9
#
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.
2
#
14
#
3
use strict;
15
# You should have received a copy of the GNU General Public License
4
use warnings;
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
5
17
6
use Test::More tests => 22;
18
use Modern::Perl;
19
20
use Test::More tests => 42;
21
use Test::Warn;
7
22
8
BEGIN {
23
BEGIN {
9
        use_ok('C4::Biblio');
24
        use_ok('C4::Biblio');
10
}
25
}
11
26
12
# test returns if undef record passed
27
my @arr;
13
# carp messages appear on stdout
28
my $ret;
29
30
warning_is { @arr = AddBiblio(undef, q{}) }
31
           { carped => 'AddBiblio called with undefined record'},
32
           "AddBiblio returns carped warning on undef record";
14
33
15
my @arr = AddBiblio(undef, q{});
16
my $elements = @arr;
34
my $elements = @arr;
17
35
18
is($elements, 0, 'Add Biblio returns empty array for undef record');
36
is($elements, 0, 'Add Biblio returns empty array for undef record');
19
37
20
my $ret = ModBiblio(undef, 0, '');
38
warning_is { $ret = ModBiblio(undef, 0, '') }
39
           { carped => 'No record passed to ModBiblio'},
40
           "ModBiblio returns carped warning on undef record";
21
41
22
is( $ret, 0, 'ModBiblio returns zero if not passed rec');
42
is( $ret, 0, 'ModBiblio returns zero if not passed rec');
23
43
24
$ret = BiblioAutoLink(undef, q{});
44
warning_is { $ret = BiblioAutoLink(undef, q{}) }
45
           { carped => 'Undefined record passed to BiblioAutoLink'},
46
           "BiblioAutoLink returns carped warning on undef record";
25
47
26
is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
48
is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
27
49
28
$ret = GetRecordValue('100', undef, q{});
50
warning_is { $ret = GetRecordValue('100', undef, q{}) }
51
           { carped => 'GetRecordValue called with undefined record'},
52
           "GetRecordValue returns carped warning on undef record";
53
29
ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
54
ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
30
55
31
@arr = LinkBibHeadingsToAuthorities(q{}, q{});
56
warning_is { @arr = LinkBibHeadingsToAuthorities(q{}, q{}) }
57
           { carped => 'LinkBibHeadingsToAuthorities called on undefined bib record'},
58
           "LinkBibHeadingsToAuthorities returns carped warning on undef record";
59
32
is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
60
is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
33
61
34
$ret = GetCOinSBiblio();
62
warning_is { $ret = GetCOinSBiblio() }
63
           { carped => 'GetCOinSBiblio called with undefined record'},
64
           "GetCOinSBiblio returns carped warning on undef record";
65
35
ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
66
ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
36
67
37
$ret = GetMarcPrice(undef, 'MARC21');
68
warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
69
           { carped => 'GetMarcPrice called on undefined record'},
70
           "GetMarcPrice returns carped warning on undef record";
71
38
ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
72
ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
39
73
40
$ret = GetMarcQuantity(undef, 'MARC21');
74
warning_is { $ret = GetMarcQuantity(undef, 'MARC21') }
75
           { carped => 'GetMarcQuantity called on undefined record'},
76
           "GetMarcQuantity returns carped warning on undef record";
77
41
ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
78
ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
42
79
43
$ret = GetMarcControlnumber();
80
warning_is { $ret = GetMarcControlnumber() }
81
           { carped => 'GetMarcControlnumber called on undefined record'},
82
           "GetMarcControlnumber returns carped warning on undef record";
83
44
ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
84
ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
45
85
46
$ret = GetMarcISBN();
86
warning_is { $ret = GetMarcISBN() }
87
           { carped => 'GetMarcISBN called on undefined record'},
88
           "GetMarcISBN returns carped warning on undef record";
89
47
ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
90
ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
48
91
49
$ret = GetMarcISSN();
92
warning_is { $ret = GetMarcISSN() }
93
           { carped => 'GetMarcISSN called on undefined record'},
94
           "GetMarcISSN returns carped warning on undef record";
95
50
ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
96
ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
51
97
52
$ret = GetMarcNotes();
98
warning_is { $ret = GetMarcNotes() }
99
           { carped => 'GetMarcNotes called on undefined record'},
100
           "GetMarcNotes returns carped warning on undef record";
101
53
ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
102
ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
54
103
55
$ret = GetMarcSubjects();
104
warning_is { $ret = GetMarcSubjects() }
105
           { carped => 'GetMarcSubjects called on undefined record'},
106
           "GetMarcSubjects returns carped warning on undef record";
107
56
ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
108
ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
57
109
58
$ret = GetMarcAuthors();
110
warning_is { $ret = GetMarcAuthors() }
111
           { carped => 'GetMarcAuthors called on undefined record'},
112
           "GetMarcAuthors returns carped warning on undef record";
113
59
ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
114
ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
60
115
61
$ret = GetMarcUrls();
116
warning_is { $ret = GetMarcUrls() }
117
           { carped => 'GetMarcUrls called on undefined record'},
118
           "GetMarcUrls returns carped warning on undef record";
119
62
ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
120
ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
63
121
64
$ret = GetMarcSeries();
122
warning_is { $ret = GetMarcSeries() }
123
           { carped => 'GetMarcSeries called on undefined record'},
124
           "GetMarcSeries returns carped warning on undef record";
125
65
ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
126
ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
66
127
67
$ret = GetMarcHosts();
128
warning_is { $ret = GetMarcHosts() }
129
           { carped => 'GetMarcHosts called on undefined record'},
130
           "GetMarcHosts returns carped warning on undef record";
131
68
ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
132
ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
69
133
70
my $hash_ref = TransformMarcToKoha(undef, undef);
134
my $hash_ref;
135
136
warning_is { $hash_ref = TransformMarcToKoha(undef, undef) }
137
           { carped => 'TransformMarcToKoha called with undefined record'},
138
           "TransformMarcToKoha returns carped warning on undef record";
71
139
72
isa_ok( $hash_ref, 'HASH');
140
isa_ok( $hash_ref, 'HASH');
73
141
Lines 75-82 $elements = keys %{$hash_ref}; Link Here
75
143
76
is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
144
is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
77
145
78
$ret = ModBiblioMarc();
146
warning_is { $ret = ModBiblioMarc() }
147
           { carped => 'ModBiblioMarc passed an undefined record'},
148
           "ModBiblioMarc returns carped warning on undef record";
149
79
ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
150
ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
80
151
81
$ret = RemoveAllNsb();
152
warning_is { $ret = RemoveAllNsb() }
153
           { carped => 'RemoveAllNsb called with undefined record'},
154
           "RemoveAllNsb returns carped warning on undef record";
155
82
ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
156
ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
83
- 
157
158
1;

Return to bug 12570