6 use Test::More tests => 35;
10 use_ok( 'WebPAC::Test' );
11 use_ok( 'WebPAC::Output::SWISH' );
12 use_ok( 'SWISH::API' );
15 my $path = "$abs_path/kino/";
17 ok(my $out = new WebPAC::Output::SWISH({
22 ok( $out->init, 'init' );
27 'search' => [ 'tko zna' ]
33 'search' => [ qw/a1 a2 s3 a4 a5/ ],
36 'search' => [ 'foo' ],
40 ok( $out->add( 42, $ds ), 'add 42' );
42 my @strange = ( qw/èajðinica odma¹æivanje ¾abokreèina ¹uma/ );
44 ok( $out->add( 99, { foo => { search => [ @strange ] } } ), 'add 99' );
46 ok( $out->add( 100, { foo => { search => [ qw/foo bar baz/ ] } } ), 'add 100' );
48 ok( $out->finish, 'finish' );
51 my ( $query_string, $expected_hits ) = @_;
53 my $swish = SWISH::API->new( $out->index_path );
54 $swish->abort_last_error if $swish->Error;
56 my $results = $swish->query( $query_string );
58 my $total_hits = $results->hits;
60 ok( $total_hits, "search '$query_string'" );
62 diag "Total hits: $total_hits\n" if $debug;
64 cmp_ok( $total_hits, '==', $expected_hits, 'total_hits' );
66 while ( my $hit = $results->next_result ) {
67 diag dump($hit) if $debug;
72 test_search( 'foo', 2 );
74 test_search( $_, 1 ) foreach @strange;