|
Lines 22-29
use Test::MockModule;
Link Here
|
| 22 |
|
22 |
|
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
| 24 |
use MARC::Record; |
24 |
use MARC::Record; |
| 25 |
use Koha::SearchEngine::Elasticsearch::Indexer; |
|
|
| 26 |
use JSON::XS; |
| 27 |
|
25 |
|
| 28 |
my $schema = Koha::Database->schema; |
26 |
my $schema = Koha::Database->schema; |
| 29 |
|
27 |
|
|
Lines 31-37
use_ok('Koha::SearchEngine::Elasticsearch');
Link Here
|
| 31 |
|
29 |
|
| 32 |
subtest 'get_fixer_rules() tests' => sub { |
30 |
subtest 'get_fixer_rules() tests' => sub { |
| 33 |
|
31 |
|
| 34 |
plan tests => 47; |
32 |
plan tests => 45; |
| 35 |
|
33 |
|
| 36 |
$schema->storage->txn_begin; |
34 |
$schema->storage->txn_begin; |
| 37 |
|
35 |
|
|
Lines 79-99
subtest 'get_fixer_rules() tests' => sub {
Link Here
|
| 79 |
}, |
77 |
}, |
| 80 |
); |
78 |
); |
| 81 |
|
79 |
|
| 82 |
my $marc_record = MARC::Record->new(); |
|
|
| 83 |
$marc_record->append_fields( |
| 84 |
MARC::Field->new( '001', '1234567' ), |
| 85 |
MARC::Field->new( '020', '', '', 'a' => '1234567890123' ), |
| 86 |
MARC::Field->new( '100', '', '', 'a' => 'Author' ), |
| 87 |
MARC::Field->new( '110', '', '', 'a' => 'Corp Author' ), |
| 88 |
MARC::Field->new( '245', '', '', 'a' => 'Title' ), |
| 89 |
); |
| 90 |
my @records = ( $marc_record ); |
| 91 |
|
| 92 |
my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' }); |
| 93 |
my $conv = $importer->_convert_marc_to_json( \@records )->next(); |
| 94 |
is( $conv->{author}[0][0], "Author", "First mapped author should be 100a"); |
| 95 |
is( $conv->{author}[1][0], "Corp Author", "Second mapped author should be 110a"); |
| 96 |
|
| 97 |
my $result = $see->get_fixer_rules(); |
80 |
my $result = $see->get_fixer_rules(); |
| 98 |
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)}); |
| 99 |
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', -split => 1)}); |