Bug 16155: Adjust a few other tests
[koha.git] / t / db_dependent / Koha_SearchEngine_Elasticsearch_Search.t
1 # Copyright 2015 Catalyst IT
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.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17 use strict;
18 use warnings;
19
20 use Test::More tests => 10;    # last test to print
21 use Koha::SearchEngine::Elasticsearch::QueryBuilder;
22
23 my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
24
25 use_ok('Koha::SearchEngine::Elasticsearch::Search');
26
27 ok(
28     my $searcher = Koha::SearchEngine::Elasticsearch::Search->new(
29         { 'nodes' => ['localhost:9200'], 'index' => 'mydb' }
30     ),
31     'Creating a Koha::ElasticSearch::Search object'
32 );
33
34 is( $searcher->index, 'mydb', 'Testing basic accessor' );
35
36 ok( my $query = $builder->build_query('easy'), 'Build a search query');
37
38 ok( my $results = $searcher->search( $query) , 'Do a search ' );
39
40 ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
41
42 is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
43
44 ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
45
46 ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' );
47
48 is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');