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

(-)a/t/Koha/SearchEngine/Elasticsearch.t (-6 / +10 lines)
Lines 145-151 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
145
            suggestible => 1,
145
            suggestible => 1,
146
            sort => 1,
146
            sort => 1,
147
            marc_type => 'marc21',
147
            marc_type => 'marc21',
148
            marc_field => '245a',
148
            marc_field => '245(ab)ab',
149
        },
149
        },
150
        {
150
        {
151
            name => 'unimarc_title',
151
            name => 'unimarc_title',
Lines 228-234 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
228
        MARC::Field->new('100', '', '', a => 'Author 1'),
228
        MARC::Field->new('100', '', '', a => 'Author 1'),
229
        MARC::Field->new('110', '', '', a => 'Corp Author'),
229
        MARC::Field->new('110', '', '', a => 'Corp Author'),
230
        MARC::Field->new('210', '', '', a => 'Title 1'),
230
        MARC::Field->new('210', '', '', a => 'Title 1'),
231
        MARC::Field->new('245', '', '', a => 'Title: first record'),
231
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
232
        MARC::Field->new('999', '', '', c => '1234567'),
232
        MARC::Field->new('999', '', '', c => '1234567'),
233
        # '  ' for testing trimming of white space in boolean value callback:
233
        # '  ' for testing trimming of white space in boolean value callback:
234
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30'),
234
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30'),
Lines 261-268 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
261
    is(scalar @{$docs->[0][1]->{author__sort}}, 2, 'First document author__sort field should have two values');
261
    is(scalar @{$docs->[0][1]->{author__sort}}, 2, 'First document author__sort field should have two values');
262
    is_deeply($docs->[0][1]->{author__sort}, ['Author 1', 'Corp Author'], 'First document author__sort field should be set correctly');
262
    is_deeply($docs->[0][1]->{author__sort}, ['Author 1', 'Corp Author'], 'First document author__sort field should be set correctly');
263
263
264
    is(scalar @{$docs->[0][1]->{title__sort}}, 1, 'First document title__sort field should have one value');
264
    is(scalar @{$docs->[0][1]->{title__sort}}, 3, 'First document title__sort field should have three values');
265
    is_deeply($docs->[0][1]->{title__sort}, ['Title: first record'], 'First document title__sort field should be set correctly');
265
    is_deeply($docs->[0][1]->{title__sort}, ['Title:', 'first record', 'Title: first record'], 'First document title__sort field should be set correctly');
266
266
267
    is(scalar @{$docs->[0][1]->{author__suggestion}}, 2, 'First document author__suggestion field should contain two values');
267
    is(scalar @{$docs->[0][1]->{author__suggestion}}, 2, 'First document author__suggestion field should contain two values');
268
    is_deeply(
268
    is_deeply(
Lines 278-287 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
278
        'First document author__suggestion field should be set correctly'
278
        'First document author__suggestion field should be set correctly'
279
    );
279
    );
280
280
281
    is(scalar @{$docs->[0][1]->{title__suggestion}}, 1, 'First document title__suggestion field should contain one value');
281
    is(scalar @{$docs->[0][1]->{title__suggestion}}, 3, 'First document title__suggestion field should contain three values');
282
    is_deeply(
282
    is_deeply(
283
        $docs->[0][1]->{title__suggestion},
283
        $docs->[0][1]->{title__suggestion},
284
        [{ 'input' => 'Title: first record' }],
284
        [
285
            { 'input' => 'Title:' },
286
            { 'input' => 'first record' },
287
            { 'input' => 'Title: first record' }
288
        ],
285
        'First document title__suggestion field should be set correctly'
289
        'First document title__suggestion field should be set correctly'
286
    );
290
    );
287
291
(-)a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t (-26 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 15;
20
use Test::More tests => 13;
21
use t::lib::Mocks;
21
use t::lib::Mocks;
22
22
23
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
23
use Koha::SearchEngine::Elasticsearch::QueryBuilder;
Lines 50-57 SKIP: { Link Here
50
50
51
    ok( my $results = $searcher->search( $query) , 'Do a search ' );
51
    ok( my $results = $searcher->search( $query) , 'Do a search ' );
52
52
53
    ok( my $marc = $searcher->json2marc( $results->first ), 'Convert JSON to MARC');
54
55
    is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
53
    is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results ');
56
54
57
    ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
55
    ok ($results = $searcher->search_compat( $query ), 'Test search_compat' );
Lines 69-96 SKIP: { Link Here
69
    is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value');
67
    is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value');
70
}
68
}
71
69
72
subtest 'json2marc' => sub {
73
    plan tests => 4;
74
    my $leader = '00626nam a2200193   4500';
75
    my $_001 = 42;
76
    my $_010a = '123456789';
77
    my $_010d = 145;
78
    my $_200a = 'a title';
79
    my $json = [ # It's not a JSON, see the POD of json2marc
80
        [ 'LDR', undef, undef, '_', $leader ],
81
        [ '001', undef, undef, '_', $_001 ],
82
        [ '010', ' ', ' ', 'a', $_010a, 'd', $_010d ],
83
        [ '200', '1', ' ', 'a', $_200a, ], # Yes UNIMARC but we don't mind here
84
    ];
85
86
    my $marc = $searcher->json2marc( $json );
87
    is( $marc->leader, $leader, );
88
    is( $marc->field('001')->data, $_001, );
89
    is( $marc->subfield('010', 'a'), $_010a, );
90
    is( $marc->subfield('200', 'a'), $_200a, );
91
92
};
93
94
subtest 'build_query tests' => sub {
70
subtest 'build_query tests' => sub {
95
    plan tests => 24;
71
    plan tests => 24;
96
72
97
- 

Return to bug 19893