6 use Koha::SearchEngine;
9 t::lib::Mocks::mock_preference('SearchEngine', 'Solr');
10 my $se = Koha::SearchEngine->new;
11 is( $se->name, "Solr", "Test searchengine name eq Solr" );
13 my $config = $se->config;
14 $config->set_config_filename( "$FindBin::Bin/../indexes.yaml" );
15 my $ressource_types = $config->ressource_types;
16 is ( grep ( /^biblio$/, @$ressource_types ), 1, "Ressource type biblio must to be defined" );
17 is ( grep ( /^authority$/, @$ressource_types ), 1, "Ressource type authority must to be defined" );
19 my $indexes = $config->indexes;
20 is ( scalar(@$indexes), 3, "There are 3 indexes configured" );
22 my $index1 = @$indexes[0];
23 is ( $index1->{code}, 'title', "My index first have code=title");
24 is ( $index1->{label}, 'Title', "My index first have label=Title");
25 is ( $index1->{type}, 'ste', "My index first have type=ste");
26 is ( $index1->{ressource_type}, 'biblio', "My index first have ressource_type=biblio");
27 is ( $index1->{sortable}, '1', "My index first have sortable=1");
28 is ( $index1->{mandatory}, '1', "My index first have mandatory=1");
29 eq_array ( $index1->{mappings}, ["200\$a", "4..\$t"], "My first index have mappings=[200\$a,4..\$t]");
31 system( qq{/bin/cp $FindBin::Bin/../indexes.yaml /tmp/indexes.yaml} );
32 $config->set_config_filename( "/tmp/indexes.yaml" );
33 $indexes = $config->indexes;
38 ressource_type => 'biblio',
42 push @$indexes, $new_index;
43 $config->indexes( $indexes );
45 $indexes = $config->indexes;
47 my $isbn_index = $config->index( 'isbn' );
48 is( $isbn_index->{code}, 'isbn', 'Index isbn has been written' );
50 my $sortable_indexes = $config->sortable_indexes;
51 is ( @$sortable_indexes, 2, "There are 2 sortable indexes" );