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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-11 / +29 lines)
Lines 132-138 subtest 'get_elasticsearch_mappings() tests' => sub { Link Here
132
132
133
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
133
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub {
134
134
135
    plan tests => 61;
135
    plan tests => 63;
136
136
137
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
137
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
138
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
138
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 318-324 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
318
            marc_type => 'marc21',
318
            marc_type => 'marc21',
319
            marc_field => '008_/7-10',
319
            marc_field => '008_/7-10',
320
        },
320
        },
321
321
        {
322
            name => 'subject',
323
            type => 'string',
324
            facet => 0,
325
            suggestible => 0,
326
            searchable => 1,
327
            sort => 1,
328
            marc_type => 'marc21',
329
            marc_field => '650(avxyz)',
330
        },
322
    );
331
    );
323
332
324
    my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
333
    my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
Lines 358-363 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
358
        MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'),
367
        MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'),
359
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
368
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
360
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'),
369
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'),
370
        MARC::Field->new('650', '', '', a => 'Heading', z => 'Geohead', v => 'Formhead'),
371
        MARC::Field->new('650', '', '', a => 'Heading', x => 'Gensubhead', z => 'Geohead'),
361
        MARC::Field->new('999', '', '', c => '1234567'),
372
        MARC::Field->new('999', '', '', c => '1234567'),
362
        # '  ' for testing trimming of white space in boolean value callback:
373
        # '  ' for testing trimming of white space in boolean value callback:
363
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30', o => $callno, l => 3),
374
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30', o => $callno, l => 3),
Lines 403-408 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
403
    is(scalar @{$docs->[0]->{author}}, 2, 'First document author field should contain two values');
414
    is(scalar @{$docs->[0]->{author}}, 2, 'First document author field should contain two values');
404
    is_deeply($docs->[0]->{author}, ['Author 1', 'Corp Author'], 'First document author field should be set correctly');
415
    is_deeply($docs->[0]->{author}, ['Author 1', 'Corp Author'], 'First document author field should be set correctly');
405
416
417
    is(scalar @{$docs->[0]->{subject}}, 2, 'First document subject field should contain two values');
418
    is_deeply($docs->[0]->{subject}, ['Heading Geohead Formhead', 'Heading Gensubhead Geohead'], 'First document asubject field should be set correctly, record order preserved for grouped subfield mapping');
419
406
    is(scalar @{$docs->[0]->{author__sort}}, 1, 'First document author__sort field should have a single value');
420
    is(scalar @{$docs->[0]->{author__sort}}, 1, 'First document author__sort field should have a single value');
407
    is_deeply($docs->[0]->{author__sort}, ['Author 1 Corp Author'], 'First document author__sort field should be set correctly');
421
    is_deeply($docs->[0]->{author__sort}, ['Author 1 Corp Author'], 'First document author__sort field should be set correctly');
408
422
Lines 733-739 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t Link Here
733
747
734
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
748
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
735
749
736
    plan tests => 2;
750
    plan tests => 3;
737
751
738
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
752
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
739
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
753
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 753-759 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori Link Here
753
            searchable => 1,
767
            searchable => 1,
754
            sort => 0,
768
            sort => 0,
755
            marc_type => 'marc21',
769
            marc_type => 'marc21',
756
            marc_field => '150(ae)',
770
            marc_field => '150(aevxyz)',
757
        }
771
        }
758
    );
772
    );
759
773
Lines 793-808 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori Link Here
793
807
794
    my $docs = $see->marc_records_to_documents($records);
808
    my $docs = $see->marc_records_to_documents($records);
795
809
796
    ok(
810
    is_deeply(
797
        any { $_ eq "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" }
811
        [ "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" ],
798
        @{$docs->[0]->{'match-heading'}},
812
        $docs->[0]->{'match-heading'},
799
        "First record match-heading should contain the correctly formatted heading"
813
        "First record match-heading should contain the correctly formatted heading"
800
    );
814
    );
801
    ok(
815
    is_deeply(
802
        any { $_ eq "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" }
816
        [ "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" ],
803
        @{$docs->[1]->{'match-heading'}},
817
        $docs->[1]->{'match-heading'},
804
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
818
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
805
    );
819
    );
820
    is_deeply(
821
        [ "Subject Genresubdiv Geosubdiv Generalsubdiv wrongsubdiv" ],
822
        $docs->[1]->{'match'} ,
823
        "Second record heading should contain the subfields with record order retained"
824
    );
806
};
825
};
807
826
808
$schema->storage->txn_rollback;
827
$schema->storage->txn_rollback;
809
- 

Return to bug 23828