Lines 20-28
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use FindBin; |
22 |
use FindBin; |
23 |
use Test::More tests => 3; |
23 |
use Test::More tests => 4; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
|
25 |
|
|
|
26 |
use C4::Context; |
26 |
use C4::Breeding; |
27 |
use C4::Breeding; |
27 |
use Koha::XSLT_Handler; |
28 |
use Koha::XSLT_Handler; |
28 |
|
29 |
|
Lines 49-54
subtest '_do_xslt_proc' => sub {
Link Here
|
49 |
plan tests => 7; |
50 |
plan tests => 7; |
50 |
test_do_xslt(); |
51 |
test_do_xslt(); |
51 |
}; |
52 |
}; |
|
|
53 |
#Group 4: testing _add_rowdata (part of Z3950Search) |
54 |
subtest '_add_rowdata' => sub { |
55 |
plan tests => 4; |
56 |
test_add_rowdata(); |
57 |
}; |
52 |
|
58 |
|
53 |
#------------------------------------------------------------------------------- |
59 |
#------------------------------------------------------------------------------- |
54 |
|
60 |
|
Lines 186-188
sub test_do_xslt {
Link Here
|
186 |
is ( $res[0]->subfield('245','a') eq 'Just a title', 1, |
192 |
is ( $res[0]->subfield('245','a') eq 'Just a title', 1, |
187 |
'At least the title is the same :)' ); |
193 |
'At least the title is the same :)' ); |
188 |
} |
194 |
} |
189 |
- |
195 |
|
|
|
196 |
sub test_add_rowdata { |
197 |
|
198 |
my $old_preference = C4::Context->preference("AdditionalFieldsInZ3950ResultSearch"); |
199 |
C4::Context->set_preference("AdditionalFieldsInZ3950ResultSearch",""); |
200 |
|
201 |
my $row = { |
202 |
biblionumber => 0, |
203 |
server => "testServer", |
204 |
breedingid => 0, |
205 |
}; |
206 |
|
207 |
my $biblio = MARC::Record->new(); |
208 |
$biblio->append_fields( |
209 |
MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title |
210 |
); |
211 |
|
212 |
my $returned_row = C4::Breeding::_add_rowdata($row,$biblio); |
213 |
|
214 |
is($returned_row->{title} ,"Just a title","_add_rowdata returns the title of a biblio"); |
215 |
is($returned_row->{addnumberfields}[0],undef,"_add_rowdata returns undef if it has no additionnal field"); |
216 |
|
217 |
C4::Context->set_preference("AdditionalFieldsInZ3950ResultSearch","245\$a"); |
218 |
|
219 |
$row = { |
220 |
biblionumber => 0, |
221 |
server => "testServer", |
222 |
breedingid => 0, |
223 |
}; |
224 |
$biblio = MARC::Record->new(); |
225 |
$biblio->append_fields( |
226 |
MARC::Field->new('245', ' ', ' ', a => 'Just a title'), #title |
227 |
); |
228 |
$returned_row = C4::Breeding::_add_rowdata($row,$biblio); |
229 |
|
230 |
is($returned_row->{title} ,"Just a title","_add_rowdata returns the title of a biblio"); |
231 |
is($returned_row->{addnumberfields}[0],"245\$a","_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference"); |
232 |
|
233 |
C4::Context->set_preference("AdditionalFieldsInZ3950ResultSearch",$old_preference); #resets the preferences to their original values |
234 |
} |