Koha/t/searchengine/004_config/load_config.t
Jonathan Druart 9509062072 Bug 10298: Adapt existing code
set_solr and set_zebra is not really useful. It is preferable to use
mock_preference directly.

To test:
1/ Launch Solr
2/ prove -r t/searchengine/
It should produce:
% prove -r t/searchengine/
t/searchengine/000_conn/conn.t ........... ok
t/searchengine/001_search/search_base.t .. ok
t/searchengine/002_index/index_base.t .... IndexRecord called with biblio 2
Indexing biblio 2
t/searchengine/002_index/index_base.t .... ok
t/searchengine/003_query/buildquery.t .... ok
t/searchengine/004_config/load_config.t .. ok
All tests successful.
Files=5, Tests=21,  4 wallclock secs ( 0.03 usr  0.01 sys +  2.74 cusr
0.20 csys =  2.98 CPU)
Result: PASS

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Had to get Solr going again to test this, man .. they could make that
easier

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-08-09 16:36:17 +00:00

53 lines
1.8 KiB
Perl

use Modern::Perl;
use Test::More;
use FindBin qw($Bin);
use C4::Context;
use Koha::SearchEngine;
use t::lib::Mocks;
t::lib::Mocks::mock_preference('SearchEngine', 'Solr');
my $se = Koha::SearchEngine->new;
is( $se->name, "Solr", "Test searchengine name eq Solr" );
my $config = $se->config;
$config->set_config_filename( "$FindBin::Bin/../indexes.yaml" );
my $ressource_types = $config->ressource_types;
is ( grep ( /^biblio$/, @$ressource_types ), 1, "Ressource type biblio must to be defined" );
is ( grep ( /^authority$/, @$ressource_types ), 1, "Ressource type authority must to be defined" );
my $indexes = $config->indexes;
is ( scalar(@$indexes), 3, "There are 3 indexes configured" );
my $index1 = @$indexes[0];
is ( $index1->{code}, 'title', "My index first have code=title");
is ( $index1->{label}, 'Title', "My index first have label=Title");
is ( $index1->{type}, 'ste', "My index first have type=ste");
is ( $index1->{ressource_type}, 'biblio', "My index first have ressource_type=biblio");
is ( $index1->{sortable}, '1', "My index first have sortable=1");
is ( $index1->{mandatory}, '1', "My index first have mandatory=1");
eq_array ( $index1->{mappings}, ["200\$a", "4..\$t"], "My first index have mappings=[200\$a,4..\$t]");
system( qq{/bin/cp $FindBin::Bin/../indexes.yaml /tmp/indexes.yaml} );
$config->set_config_filename( "/tmp/indexes.yaml" );
$indexes = $config->indexes;
my $new_index = {
code => 'isbn',
label => 'ISBN',
type => 'str',
ressource_type => 'biblio',
sortable => 0,
mandatory => 0
};
push @$indexes, $new_index;
$config->indexes( $indexes );
$indexes = $config->indexes;
my $isbn_index = $config->index( 'isbn' );
is( $isbn_index->{code}, 'isbn', 'Index isbn has been written' );
my $sortable_indexes = $config->sortable_indexes;
is ( @$sortable_indexes, 2, "There are 2 sortable indexes" );
done_testing;