View | Details | Raw Unified | Return to bug 29632
Collapse All | Expand All

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-5 / +47 lines)
Lines 128-141 subtest 'get_elasticsearch_settings() tests' => sub { Link Here
128
128
129
subtest 'get_elasticsearch_mappings() tests' => sub {
129
subtest 'get_elasticsearch_mappings() tests' => sub {
130
130
131
    plan tests => 1;
131
    plan tests => 3;
132
132
133
    my $mappings;
133
    my $mappings;
134
134
135
    # test reading mappings
135
    my @mappings = (
136
    my $es = Koha::SearchEngine::Elasticsearch->new( {index => $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX} );
136
        {
137
    $mappings = $es->get_elasticsearch_mappings();
137
            name => 'cn-sort',
138
            type => 'callnumber',
139
            facet => 0,
140
            suggestible => 0,
141
            searchable => 1,
142
            sort => 1,
143
            marc_type => 'marc21',
144
            marc_field => '001',
145
        },
146
        {
147
            name => 'isbn',
148
            type => 'string',
149
            facet => 0,
150
            suggestible => 0,
151
            searchable => 1,
152
            sort => 1,
153
            marc_type => 'marc21',
154
            marc_field => '020a',
155
        },
156
    );
157
    my $search_engine_module = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
158
    $search_engine_module->mock('_foreach_mapping', sub {
159
        my ($self, $sub) = @_;
160
161
        foreach my $map (@mappings) {
162
            $sub->(
163
                $map->{name},
164
                $map->{type},
165
                $map->{facet},
166
                $map->{suggestible},
167
                $map->{sort},
168
                $map->{searchable},
169
                $map->{marc_type},
170
                $map->{marc_field}
171
            );
172
        }
173
    });
174
175
    my $search_engine_elasticsearch = Koha::SearchEngine::Elasticsearch::Search->new({ index => $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX });
176
    $mappings = $search_engine_elasticsearch->get_elasticsearch_mappings();
177
178
    is( $mappings->{properties}{"cn-sort__sort"}{index}, 'false', 'Field mappings parsed correctly for sort for callnumber type' );
179
    is( $mappings->{properties}{"cn-sort__sort"}{numeric}, 'false', 'Field mappings parsed correctly for sort for callnumber type' );
138
    is( $mappings->{properties}{isbn__sort}{index}, 'false', 'Field mappings parsed correctly' );
180
    is( $mappings->{properties}{isbn__sort}{index}, 'false', 'Field mappings parsed correctly' );
181
139
};
182
};
140
183
141
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
184
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
142
- 

Return to bug 29632