Lines 24-30
use Module::Load::Conditional qw/check_install/;
Link Here
|
24 |
|
24 |
|
25 |
BEGIN { |
25 |
BEGIN { |
26 |
if ( check_install( module => 'Test::DBIx::Class' ) ) { |
26 |
if ( check_install( module => 'Test::DBIx::Class' ) ) { |
27 |
plan tests => 10; |
27 |
plan tests => 12; |
28 |
} else { |
28 |
} else { |
29 |
plan skip_all => "Need Test::DBIx::Class" |
29 |
plan skip_all => "Need Test::DBIx::Class" |
30 |
} |
30 |
} |
Lines 62-67
sub _get_ccl_properties {
Link Here
|
62 |
phr 4=1 |
62 |
phr 4=1 |
63 |
fuzzy 5=103 |
63 |
fuzzy 5=103 |
64 |
ccode 1=8009 |
64 |
ccode 1=8009 |
|
|
65 |
nb 1=7 |
66 |
ns 1=8 |
65 |
); |
67 |
); |
66 |
return $config; |
68 |
return $config; |
67 |
} |
69 |
} |
Lines 148-153
subtest "test weighted not-autotruncated" => sub {
Link Here
|
148 |
|
150 |
|
149 |
t::lib::Mocks::mock_preference('QueryWeightFields', '1'); |
151 |
t::lib::Mocks::mock_preference('QueryWeightFields', '1'); |
150 |
t::lib::Mocks::mock_preference('QueryAutoTruncate', '0'); |
152 |
t::lib::Mocks::mock_preference('QueryAutoTruncate', '0'); |
|
|
153 |
t::lib::Mocks::mock_preference('QueryFuzzy', '1'); |
151 |
|
154 |
|
152 |
my $config = _get_ccl_properties(); |
155 |
my $config = _get_ccl_properties(); |
153 |
my $operators = [""]; |
156 |
my $operators = [""]; |
Lines 328-330
subtest "one and two weighted autotruncated" => sub {
Link Here
|
328 |
is($ccl_errpos,0); |
331 |
is($ccl_errpos,0); |
329 |
Net::Z3950::ZOOM::query_destroy($q); |
332 |
Net::Z3950::ZOOM::query_destroy($q); |
330 |
}; |
333 |
}; |
331 |
- |
334 |
|
|
|
335 |
subtest "test with ISBN variations" => sub { |
336 |
plan tests => 12; |
337 |
|
338 |
my $config = _get_ccl_properties(); |
339 |
my $operators = [""]; |
340 |
my $operands = ["1565926994"]; |
341 |
my $indexes = ["nb"]; |
342 |
my $limits = [""]; |
343 |
my $sort_by = [""]; |
344 |
my ($scan,$lang); |
345 |
|
346 |
foreach my $sample ( |
347 |
{ state => 0, query => 'nb=(rk=(1565926994)) ' }, |
348 |
{ state => 1, query => 'kw,wrdl=(rk=((nb=1-56592-699-4 OR nb=1-56592-699-4 OR nb=978-1-56592-699-8 OR nb=1565926994 OR nb=9781565926998))) ' }) |
349 |
{ |
350 |
t::lib::Mocks::mock_preference('SearchWithISBNVariations', $sample->{state}); |
351 |
# Test with disabled variatioms |
352 |
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = |
353 |
C4::Search::buildQuery($operators,$operands,$indexes,$limits,$sort_by,$scan,$lang); |
354 |
say 'Q: > ', $query; |
355 |
is($error,undef,"Error is correct"); |
356 |
is($query,$sample->{query},'Search ISBN when variations is '.$sample->{state}); |
357 |
my $q = Net::Z3950::ZOOM::query_create(); |
358 |
my ($ccl_errcode, $ccl_errstr, $ccl_errpos) = (0,"",0); |
359 |
my $res = Net::Z3950::ZOOM::query_ccl2rpn($q, $query, $config, |
360 |
$ccl_errcode, $ccl_errstr, $ccl_errpos |
361 |
); |
362 |
is($res,0,"created CCL2RPN query"); |
363 |
is($ccl_errcode,0); |
364 |
is($ccl_errstr,""); |
365 |
is($ccl_errpos,0); |
366 |
Net::Z3950::ZOOM::query_destroy($q); |
367 |
} |
368 |
|
369 |
}; |
370 |
|
371 |
subtest "test with ISSN variations" => sub { |
372 |
plan tests => 12; |
373 |
|
374 |
my $config = _get_ccl_properties(); |
375 |
my $operators = [""]; |
376 |
my $operands = ["2434561X"]; |
377 |
my $indexes = ["ns"]; |
378 |
my $limits = [""]; |
379 |
my $sort_by = [""]; |
380 |
my ($scan,$lang); |
381 |
|
382 |
foreach my $sample ( |
383 |
{ state => 0, query => 'ns=(rk=(2434561X)) ' }, |
384 |
{ state => 1, query => 'kw,wrdl=(rk=((ns=2434-561X OR ns=2434561X))) ' }) |
385 |
{ |
386 |
t::lib::Mocks::mock_preference('SearchWithISSNVariations', $sample->{state}); |
387 |
# Test with disabled variatioms |
388 |
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = |
389 |
C4::Search::buildQuery($operators,$operands,$indexes,$limits,$sort_by,$scan,$lang); |
390 |
say 'Q: > ', $query; |
391 |
is($error,undef,"Error is correct"); |
392 |
is($query,$sample->{query},'Search ISSN when variations is '.$sample->{state}); |
393 |
my $q = Net::Z3950::ZOOM::query_create(); |
394 |
my ($ccl_errcode, $ccl_errstr, $ccl_errpos) = (0,"",0); |
395 |
my $res = Net::Z3950::ZOOM::query_ccl2rpn($q, $query, $config, |
396 |
$ccl_errcode, $ccl_errstr, $ccl_errpos |
397 |
); |
398 |
is($res,0,"created CCL2RPN query"); |
399 |
is($ccl_errcode,0); |
400 |
is($ccl_errstr,""); |
401 |
is($ccl_errpos,0); |
402 |
Net::Z3950::ZOOM::query_destroy($q); |
403 |
} |
404 |
|
405 |
}; |