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 => 59;
135
    plan tests => 61;
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 718-724 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t Link Here
718
732
719
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
733
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
720
734
721
    plan tests => 2;
735
    plan tests => 3;
722
736
723
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
737
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
724
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
738
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 738-744 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori Link Here
738
            searchable => 1,
752
            searchable => 1,
739
            sort => 0,
753
            sort => 0,
740
            marc_type => 'marc21',
754
            marc_type => 'marc21',
741
            marc_field => '150(ae)',
755
            marc_field => '150(aevxyz)',
742
        }
756
        }
743
    );
757
    );
744
758
Lines 778-793 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori Link Here
778
792
779
    my $docs = $see->marc_records_to_documents($records);
793
    my $docs = $see->marc_records_to_documents($records);
780
794
781
    ok(
795
    is_deeply(
782
        any { $_ eq "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" }
796
        [ "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" ],
783
        @{$docs->[0]->{'match-heading'}},
797
        $docs->[0]->{'match-heading'},
784
        "First record match-heading should contain the correctly formatted heading"
798
        "First record match-heading should contain the correctly formatted heading"
785
    );
799
    );
786
    ok(
800
    is_deeply(
787
        any { $_ eq "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" }
801
        [ "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" ],
788
        @{$docs->[1]->{'match-heading'}},
802
        $docs->[1]->{'match-heading'},
789
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
803
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
790
    );
804
    );
805
    is_deeply(
806
        [ "Subject Genresubdiv Geosubdiv Generalsubdiv wrongsubdiv" ],
807
        $docs->[1]->{'match'} ,
808
        "Second record heading should contain the subfields with record order retained"
809
    );
791
};
810
};
792
811
793
$schema->storage->txn_rollback;
812
$schema->storage->txn_rollback;
794
- 

Return to bug 23828