6 |
use Test::More tests => 35; |
use Test::More tests => 35; |
7 |
|
|
8 |
BEGIN { |
BEGIN { |
9 |
use_ok( 'WebPAC::Test' ); |
use lib 'lib'; |
10 |
use_ok( 'WebPAC::Output::SWISH' ); |
use_ok( 'WebPAC::Test' ); |
11 |
use_ok( 'SWISH::API' ); |
use_ok( 'WebPAC::Output::SWISH' ); |
12 |
|
use_ok( 'SWISH::API' ); |
13 |
} |
} |
14 |
|
|
15 |
my $path = "$abs_path/kino/"; |
my $path = "$abs_path/kino/"; |
16 |
|
|
17 |
ok(my $out = new WebPAC::Output::SWISH( |
ok(my $out = new WebPAC::Output::SWISH({ |
18 |
database => 'test', |
database => 'test', |
19 |
%LOG |
%LOG |
20 |
), "new"); |
}), "new"); |
21 |
|
|
22 |
|
ok( $out->init, 'init' ); |
23 |
|
|
24 |
my $ds = { |
my $ds = { |
25 |
'Source' => { |
'Source' => { |
27 |
'search' => [ 'tko zna' ] |
'search' => [ 'tko zna' ] |
28 |
}, |
}, |
29 |
'ID' => { |
'ID' => { |
30 |
'search' => 'id', |
'search' => [ 'id' ], |
31 |
}, |
}, |
32 |
'Array' => { |
'Array' => { |
33 |
'search' => [ qw/a1 a2 s3 a4 a5/ ], |
'search' => [ qw/a1 a2 s3 a4 a5/ ], |
37 |
}, |
}, |
38 |
}; |
}; |
39 |
|
|
|
throws_ok { $out->add( ) } qr/need id/, 'add without params'; |
|
|
throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds'; |
|
|
|
|
40 |
ok( $out->add( 42, $ds ), 'add 42' ); |
ok( $out->add( 42, $ds ), 'add 42' ); |
41 |
|
|
42 |
my @strange = ( qw/čajđinica odmašćivanje žabokrečina šuma/ ); |
my @strange = ( qw/čajđinica odmašćivanje žabokrečina šuma/ ); |
53 |
my $swish = SWISH::API->new( $out->index_path ); |
my $swish = SWISH::API->new( $out->index_path ); |
54 |
$swish->abort_last_error if $swish->Error; |
$swish->abort_last_error if $swish->Error; |
55 |
|
|
56 |
my $results = $swish->search( $query_string ); |
my $results = $swish->query( $query_string ); |
57 |
|
|
58 |
my $total_hits = $results->hits; |
my $total_hits = $results->hits; |
59 |
|
|