Koha/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t
Chris Cormack 7b7b47ca68 Bug 12478 Increasing test Coverage for Koha::SearchEngine::Elasticsearch::Search
Before this patch it was 24.6%, after it is 64%

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
2016-04-26 20:20:13 +00:00

48 lines
1.7 KiB
Perl

# Copyright 2015 Catalyst IT
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use Test::More tests => 10; # last test to print
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
my $builder = Koha::SearchEngine::Elasticsearch::QueryBuilder->new( { index => 'mydb' } );
use_ok('Koha::SearchEngine::Elasticsearch::Search');
ok(
my $searcher = Koha::SearchEngine::Elasticsearch::Search->new(
{ 'nodes' => ['localhost:9200'], 'index' => 'mydb' }
),
'Creating a Koha::ElasticSearch::Search object'
);
is( $searcher->index, 'mydb', 'Testing basic accessor' );
ok( my $query = $builder->build_query('easy'), 'Build a search query');
ok( my $results = $searcher->search( $query) , 'Do a search ' );
ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' );
is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use');