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

(-)a/t/db_dependent/Koha_Elasticsearch.t (-6 / +6 lines)
Lines 79-89 subtest 'get_fixer_rules() tests' => sub { Link Here
79
79
80
    my $result = $see->get_fixer_rules();
80
    my $result = $see->get_fixer_rules();
81
    is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', -split => 1)});
81
    is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', -split => 1)});
82
    is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet', -split => 1)});
82
    is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet.$append', -split => 1)});
83
    is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')});
83
    is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')});
84
    is( $result->[3], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', -split => 1)});
84
    is( $result->[3], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', -split => 1)});
85
    is( $result->[4], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', -split => 1)});
85
    is( $result->[4], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', -split => 1)});
86
    is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet', -split => 1)});
86
    is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet.$append', -split => 1)});
87
    is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')});
87
    is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')});
88
    is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', -split => 1)});
88
    is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', -split => 1)});
89
    is( $result->[8], q{move_field(_id,es_id)});
89
    is( $result->[8], q{move_field(_id,es_id)});
Lines 92-103 subtest 'get_fixer_rules() tests' => sub { Link Here
92
    $mappings[1]->{type}  = 'boolean';
92
    $mappings[1]->{type}  = 'boolean';
93
    $result = $see->get_fixer_rules();
93
    $result = $see->get_fixer_rules();
94
    is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', -split => 1)});
94
    is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', -split => 1)});
95
    is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet', -split => 1)});
95
    is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet.$append', -split => 1)});
96
    is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')});
96
    is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')});
97
    is( $result->[3], q{unless exists('} . $mappings[0]->{name} . q{') add_field('} . $mappings[0]->{name} . q{', 0) end});
97
    is( $result->[3], q{unless exists('} . $mappings[0]->{name} . q{') add_field('} . $mappings[0]->{name} . q{', 0) end});
98
    is( $result->[4], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', -split => 1)});
98
    is( $result->[4], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', -split => 1)});
99
    is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', -split => 1)});
99
    is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', -split => 1)});
100
    is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet', -split => 1)});
100
    is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet.$append', -split => 1)});
101
    is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')});
101
    is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')});
102
    is( $result->[8], q{unless exists('} . $mappings[1]->{name} . q{') add_field('} . $mappings[1]->{name} . q{', 0) end});
102
    is( $result->[8], q{unless exists('} . $mappings[1]->{name} . q{') add_field('} . $mappings[1]->{name} . q{', 0) end});
103
    is( $result->[9], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', -split => 1)});
103
    is( $result->[9], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', -split => 1)});
Lines 107-118 subtest 'get_fixer_rules() tests' => sub { Link Here
107
    $mappings[1]->{type}  = 'sum';
107
    $mappings[1]->{type}  = 'sum';
108
    $result = $see->get_fixer_rules();
108
    $result = $see->get_fixer_rules();
109
    is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', )});
109
    is( $result->[0], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{.$append', )});
110
    is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet', )});
110
    is( $result->[1], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__facet.$append', )});
111
    is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')});
111
    is( $result->[2], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__suggestion.input.$append')});
112
    is( $result->[3], q{sum('} . $mappings[0]->{name} . q{')});
112
    is( $result->[3], q{sum('} . $mappings[0]->{name} . q{')});
113
    is( $result->[4], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', )});
113
    is( $result->[4], q{marc_map('} . $mappings[0]->{marc_field} . q{','} . $mappings[0]->{name} . q{__sort', )});
114
    is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', )});
114
    is( $result->[5], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{.$append', )});
115
    is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet', )});
115
    is( $result->[6], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__facet.$append', )});
116
    is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')});
116
    is( $result->[7], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__suggestion.input.$append')});
117
    is( $result->[8], q{sum('} . $mappings[1]->{name} . q{')});
117
    is( $result->[8], q{sum('} . $mappings[1]->{name} . q{')});
118
    is( $result->[9], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', )});
118
    is( $result->[9], q{marc_map('} . $mappings[1]->{marc_field} . q{','} . $mappings[1]->{name} . q{__sort', )});
(-)a/t/db_dependent/Koha_Elasticsearch_Indexer.t (-2 / +85 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 => 13;
64
64
65
    $schema->storage->txn_begin;
65
    $schema->storage->txn_begin;
66
66
Lines 117-125 subtest '_convert_marc_to_json() tests' => sub { Link Here
117
117
118
    my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' });
118
    my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' });
119
    my $conv = $importer->_convert_marc_to_json( \@records )->next();
119
    my $conv = $importer->_convert_marc_to_json( \@records )->next();
120
    is( scalar @{$conv->{author}}, 2, q{Two authors indexed});
120
    is( $conv->{author}[0][0], "Author", "First mapped author should be 100a");
121
    is( $conv->{author}[0][0], "Author", "First mapped author should be 100a");
121
    is( $conv->{author}[1][0], "Corp Author", "Second mapped author should be 110a");
122
    is( $conv->{author}[1][0], "Corp Author", "Second mapped author should be 110a");
122
123
124
    is( scalar @{$conv->{author__facet}}, 2, q{Two author facets});
125
    is( $conv->{author__facet}[0][0], "Author", "First mapped author facet should be 100a");
126
    is( $conv->{author__facet}[1][0], "Corp Author", "Second mapped author facet should be 110a");
127
128
    @mappings = (
129
        {
130
            name => 'author',
131
            type => 'string',
132
            facet => 1,
133
            suggestible => 1,
134
            sort => '~',
135
            marc_type => 'marc21',
136
            marc_field => '100a',
137
        },
138
        {
139
            name => 'author',
140
            type => 'string',
141
            facet => 0,
142
            suggestible => 1,
143
            sort => '~',
144
            marc_type => 'marc21',
145
            marc_field => '110a',
146
        },
147
    );
148
149
    $conv = $importer->_convert_marc_to_json( \@records )->next();
150
151
    is( scalar @{$conv->{author__facet}}, 1, q{Only one author facet});
152
    is( $conv->{author__facet}[0][0], "Author", "Only author facet should be 100a");
153
    is( $conv->{author__facet}[1], undef, "No facet for 110a");
154
155
    @mappings = (
156
        {
157
            name => 'author',
158
            type => 'string',
159
            facet => 0,
160
            suggestible => 1,
161
            sort => '~',
162
            marc_type => 'marc21',
163
            marc_field => '100a',
164
        },
165
        {
166
            name => 'author',
167
            type => 'string',
168
            facet => 1,
169
            suggestible => 1,
170
            sort => '~',
171
            marc_type => 'marc21',
172
            marc_field => '110a',
173
        },
174
    );
175
176
    $conv = $importer->_convert_marc_to_json( \@records )->next();
177
178
    is( scalar @{$conv->{author__facet}}, 1, q{Only one author facet});
179
    is( $conv->{author__facet}[0][0], "Corp Author", "Only author facet should be 110a");
180
    is( $conv->{author__facet}[1], undef, "No facet for 100a");
181
182
    @mappings = (
183
        {
184
            name => 'author',
185
            type => 'string',
186
            facet => 0,
187
            suggestible => 1,
188
            sort => '~',
189
            marc_type => 'marc21',
190
            marc_field => '100a',
191
        },
192
        {
193
            name => 'author',
194
            type => 'string',
195
            facet => 0,
196
            suggestible => 1,
197
            sort => '~',
198
            marc_type => 'marc21',
199
            marc_field => '110a',
200
        },
201
    );
202
203
    $conv = $importer->_convert_marc_to_json( \@records )->next();
204
205
    is( $conv->{author__facet}, undef, q{No author facet});
206
123
    $schema->storage->txn_rollback;
207
    $schema->storage->txn_rollback;
124
};
208
};
125
209
126
- 

Return to bug 18610