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

(-)a/t/db_dependent/Koha_Elasticsearch_Indexer.t (-7 / +17 lines)
Lines 60-66 SKIP: { Link Here
60
60
61
subtest '_convert_marc_to_json() tests' => sub {
61
subtest '_convert_marc_to_json() tests' => sub {
62
62
63
    plan tests => 2;
63
    plan tests => 4;
64
64
65
    $schema->storage->txn_begin;
65
    $schema->storage->txn_begin;
66
66
Lines 113-124 subtest '_convert_marc_to_json() tests' => sub { Link Here
113
        MARC::Field->new( '110', '', '', 'a' => 'Corp Author' ),
113
        MARC::Field->new( '110', '', '', 'a' => 'Corp Author' ),
114
        MARC::Field->new( '245', '', '', 'a' => 'Title' ),
114
        MARC::Field->new( '245', '', '', 'a' => 'Title' ),
115
    );
115
    );
116
    my @records = ( $marc_record );
116
    my $marc_record_2 = MARC::Record->new();
117
    $marc_record_2->append_fields(
118
        MARC::Field->new( '001', '1234567' ),
119
        MARC::Field->new( '020', '', '', 'a' => '1234567890123' ),
120
        MARC::Field->new( '100', '', '', 'a' => 'Author' ),
121
        MARC::Field->new( '245', '', '', 'a' => 'Title' ),
122
    );
123
    my @records = ( $marc_record, $marc_record_2 );
124
125
    my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' })->_convert_marc_to_json( \@records );
126
    my $conv = $importer->next();
127
    is( $conv->{author}[0], "Author", "First mapped author should be 100a");
128
    is( $conv->{author}[1], "Corp Author", "Second mapped author should be 110a");
117
129
118
    my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' });
130
    $conv = $importer->next();
119
    my $conv = $importer->_convert_marc_to_json( \@records )->next();
131
    is( $conv->{author}[0], "Author", "First mapped author should be 100a");
120
    is( $conv->{author}[0][0], "Author", "First mapped author should be 100a");
132
    is( scalar @{$conv->{author}} , 1, "We should map field only if exists, shouldn't add extra nulls");
121
    is( $conv->{author}[1][0], "Corp Author", "Second mapped author should be 110a");
122
133
123
    $schema->storage->txn_rollback;
134
    $schema->storage->txn_rollback;
124
};
135
};
125
- 

Return to bug 19581