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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-9 / +34 lines)
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
<<<<<<< HEAD
321
322
323
=======
324
        {
325
            name => 'subject',
326
            type => 'string',
327
            facet => 0,
328
            suggestible => 0,
329
            searchable => 1,
330
            sort => 1,
331
            marc_type => 'marc21',
332
            marc_field => '650(avxyz)',
333
        },
334
>>>>>>> Bug 23828: Unit tests
322
    );
335
    );
323
336
324
    my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
337
    my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
Lines 357-363 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
357
        MARC::Field->new('210', '', '', a => 'Title 1'),
370
        MARC::Field->new('210', '', '', a => 'Title 1'),
358
        MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'),
371
        MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'),
359
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
372
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
373
<<<<<<< HEAD
360
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'),
374
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'),
375
=======
376
        MARC::Field->new('650', '', '', a => 'Heading', z => 'Geohead', v => 'Formhead'),
377
        MARC::Field->new('650', '', '', a => 'Heading', x => 'Gensubhead', z => 'Geohead'),
378
>>>>>>> Bug 23828: Unit tests
361
        MARC::Field->new('999', '', '', c => '1234567'),
379
        MARC::Field->new('999', '', '', c => '1234567'),
362
        # '  ' for testing trimming of white space in boolean value callback:
380
        # '  ' for testing trimming of white space in boolean value callback:
363
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30', o => $callno, l => 3),
381
        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');
421
    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');
422
    is_deeply($docs->[0]->{author}, ['Author 1', 'Corp Author'], 'First document author field should be set correctly');
405
423
424
    is(scalar @{$docs->[0]->{subject}}, 2, 'First document subject field should contain two values');
425
    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');
426
406
    is(scalar @{$docs->[0]->{author__sort}}, 1, 'First document author__sort field should have a single value');
427
    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');
428
    is_deeply($docs->[0]->{author__sort}, ['Author 1 Corp Author'], 'First document author__sort field should be set correctly');
408
429
Lines 718-724 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t Link Here
718
739
719
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
740
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
720
741
721
    plan tests => 2;
742
    plan tests => 3;
722
743
723
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
744
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
724
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
745
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
Lines 738-744 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori Link Here
738
            searchable => 1,
759
            searchable => 1,
739
            sort => 0,
760
            sort => 0,
740
            marc_type => 'marc21',
761
            marc_type => 'marc21',
741
            marc_field => '150(ae)',
762
            marc_field => '150(aevxyz)',
742
        }
763
        }
743
    );
764
    );
744
765
Lines 778-793 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authori Link Here
778
799
779
    my $docs = $see->marc_records_to_documents($records);
800
    my $docs = $see->marc_records_to_documents($records);
780
801
781
    ok(
802
    is_deeply(
782
        any { $_ eq "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" }
803
        [ "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" ],
783
        @{$docs->[0]->{'match-heading'}},
804
        $docs->[0]->{'match-heading'},
784
        "First record match-heading should contain the correctly formatted heading"
805
        "First record match-heading should contain the correctly formatted heading"
785
    );
806
    );
786
    ok(
807
    is_deeply(
787
        any { $_ eq "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" }
808
        [ "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" ],
788
        @{$docs->[1]->{'match-heading'}},
809
        $docs->[1]->{'match-heading'},
789
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
810
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
790
    );
811
    );
812
    is_deeply(
813
        [ "Subject Genresubdiv Geosubdiv Generalsubdiv wrongsubdiv" ],
814
        $docs->[1]->{'match'} ,
815
        "Second record heading should contain the subfields with record order retained"
816
    );
791
};
817
};
792
818
793
$schema->storage->txn_rollback;
819
$schema->storage->txn_rollback;
794
- 

Return to bug 23828