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

(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-7 / +33 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 => 56;
135
    plan tests => 58;
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 297-304 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
297
            sort => 1,
297
            sort => 1,
298
            marc_type => 'marc21',
298
            marc_type => 'marc21',
299
            marc_field => '952l',
299
            marc_field => '952l',
300
        },
300
          },
301
        {
301
          {
302
            name => 'copydate',
303
            type => 'year',
304
            facet => 0,
305
            suggestible => 0,
306
            searchable => 1,
307
            sort => 1,
308
            marc_type => 'marc21',
309
            marc_field => '260c',
310
          },
311
          {
302
            name => 'date-of-publication',
312
            name => 'date-of-publication',
303
            type => 'year',
313
            type => 'year',
304
            facet => 0,
314
            facet => 0,
Lines 347-352 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
347
        MARC::Field->new('210', '', '', a => 'Title 1'),
357
        MARC::Field->new('210', '', '', a => 'Title 1'),
348
        MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'),
358
        MARC::Field->new('240', '', '4', a => 'The uniform title with nonfiling indicator'),
349
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
359
        MARC::Field->new('245', '', '', a => 'Title:', b => 'first record'),
360
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => 'c1962'),
350
        MARC::Field->new('999', '', '', c => '1234567'),
361
        MARC::Field->new('999', '', '', c => '1234567'),
351
        # '  ' for testing trimming of white space in boolean value callback:
362
        # '  ' for testing trimming of white space in boolean value callback:
352
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30', o => $callno, l => 3),
363
        MARC::Field->new('952', '', '', 0 => '  ', g => '123.30', o => $callno, l => 3),
Lines 483-492 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
483
        'First document uniform_title__sort field should contain the title with the first four initial characters removed'
494
        'First document uniform_title__sort field should contain the title with the first four initial characters removed'
484
    );
495
    );
485
496
486
    # Tests for 'year' type and 'filter_callbacks'
497
    # Tests for 'year' type
487
    is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value');
498
    is(scalar @{$docs->[0]->{'date-of-publication'}}, 1, 'First document date-of-publication field should contain one value');
488
    is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly');
499
    is_deeply($docs->[0]->{'date-of-publication'}, ['1962'], 'First document date-of-publication field should be set correctly');
489
500
501
    is_deeply(
502
      $docs->[0]->{'copydate'},
503
      ['1962'],
504
      'First document copydate field should be set correctly'
505
    );
506
490
    # Second record:
507
    # Second record:
491
508
492
    is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value');
509
    is(scalar @{$docs->[1]->{author}}, 1, 'Second document author field should contain one value');
Lines 511-518 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' Link Here
511
        'Second document local_classification__sort field should be set correctly'
528
        'Second document local_classification__sort field should be set correctly'
512
    );
529
    );
513
530
514
    # Tests for 'year' type and 'filter_callbacks'
531
    # Tests for 'year' type
515
    ok(!(defined $docs->[1]->{'date-of-publication'}), "Second document invalid date-of-publication value should have been removed");
532
    is_deeply(
533
      $docs->[1]->{'copydate'},
534
      ['1963','2003'],
535
      'Second document copydate field should be set correctly'
536
    );
537
    is_deeply(
538
      $docs->[1]->{'date-of-publication'},
539
      ['1900'],
540
      'Second document date-of-publication field should be set correctly'
541
    );
516
542
517
    # Mappings marc_type:
543
    # Mappings marc_type:
518
544
Lines 647-652 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t Link Here
647
        MARC::Field->new('100', '', '', a => 'Author 2'),
673
        MARC::Field->new('100', '', '', a => 'Author 2'),
648
        # MARC::Field->new('210', '', '', a => 'Title 2'),
674
        # MARC::Field->new('210', '', '', a => 'Title 2'),
649
        # MARC::Field->new('245', '', '', a => 'Title: second record'),
675
        # MARC::Field->new('245', '', '', a => 'Title: second record'),
676
        MARC::Field->new('260', '', '', a => 'New York :', b => 'Ace ,', c => '1963-2003'),
650
        MARC::Field->new('999', '', '', c => '1234568'),
677
        MARC::Field->new('999', '', '', c => '1234568'),
651
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'),
678
        MARC::Field->new('952', '', '', 0 => 1, g => 'string where should be numeric'),
652
    );
679
    );
653
- 

Return to bug 24807